On Saturday 20 July 2013 at 14:58, jpff@cs.bath.ac.uk wrote:
Are you asking for tabensure to be made avalable of something else? Notsure I understandHey,So I was able to write an opcode using the following syntax, dynamicallycreating a new array.kArr1[] init 5kArr2[] init 5kNewArray[] add kArr1, kArr2The new array structure is created but the arrayMemberSize, sizes, dataand dimension members are 0 or NULL. I used a csound->Calloc to create thearray->sizes array and the array->data array. Then I used acsound->RegisterDeinitCallback to call a csound->Free on these two arrays.I also filled in the arrayMemberSize and dimensions members. It all seemsto be working ok. I was able to pass the newly created array to adifferent opcode and it worked as expected.As far as I can see there are two cases for dynamically allocating newarray variables, creating arrays that are copies of the input arguments inthe case of addition, subtraction, element wise multiplication etc.Then there are cases for creating specifically sized arrays. In the caseof matrix multiplication, diskin style opcodes and numerous other casesI'm sure.So you could have a function like array copy:void array_copy(ARRAYDAT *source, ARRAYDAT *destination);Actually copy may not be the best name for that as you would really justbe duplicating the dimensions and sizes of the array but i'm sure a bettername could be chosen.And a straight up array allocation like maybe:void array_alloc(ARRAYDAT *array, int dimensions, int arrayMemberSize, int*sizes);Cheers,EdOn Friday 19 July 2013 at 23:03, Steven Yi wrote:Hi Ed,Having reusable array utility functions sounds handy. Maybe it'sworth prototyping API functions here on the list?As for the dimensions, yeah, that's what my other email from a fewdays ago was all about. I think right now the semantic analyzerallows for any dimension array to match against an array argspecifier. My proposal was to make k[] only match one dimensionk-arrays, and k[][] to only match against two-dimension k-arrays, etc.No one has really replied to that other email and I've beenpre-occupied with other work; I'll probably go and implement theproposal once I'm finished with the other work.Thanks!stevenOn Fri, Jul 19, 2013 at 8:07 AM, Edward Costello<edwardcostello@gmail.com (mailto:edwardcostello@gmail.com)> wrote:Thanks Steven,Yeah on closer inspection I noticed those functions were static, soyeahI'll have a look and just emulate what is being done in thosefunctions.So am I right in thinking that generally, as it is supported now, allarraysneed to be initialised using the init opcode before usage? It would beniceto have an array initialiser built in to the api, for things likewritingopcodes like diskin opening samples to an array output, without havingtoquery how many samples are in the file etc. or things like matrix tomatrixmultiplication where an output with the correct dimensions isautomaticallygenerated.Another thing I am confused about is the opcode arguments for arrayopcodes,does "k[]" mean a one dimensional argument and "k[][]" mean a 2dimensional?You can use a one dimensional array on an argument that takes a"k[][]" andvice-versa and no error is reported.--Edward CostelloOn Thursday 18 July 2013 at 18:45, Steven Yi wrote:Hi Ed,I think the ARRAYDAT should already be created by the compiler by thetime you see it in your opcode. However, it's dimensions and data maynot be initialized, which you may need to then modify yourself. I'mnot sure about needing a deinit callback. I don't know what thestandard practice is for freeing up memory for variables; perhaps weneed to add a var_free function to CS_TYPE to automatically handlethat...Otherwise, I'd look at Opcodes/arrays.c and use the functions Johnwrote as a model.Good luck!stevenOn Wed, Jul 17, 2013 at 10:06 AM, Edward Costello<edwardcostello@gmail.com (mailto:edwardcostello@gmail.com)> wrote:Hi,When creating a custom array opcode, for instance one that takes 2arrays asinput and give 1 array as output, in the initialisation function fortheopcode, when creating the output array does one create an ARRAYINITstructand pass that to the array_init function? Conversely is there a needto callthe array_del function from a RegisterDeinitCallback?Thanks--Edward Costello------------------------------------------------------------------------------See everything from the browser to the database with AppDynamicsGet end-to-end visibility with application monitoring from AppDynamicsIsolate bottlenecks and diagnose root cause in seconds.Start your free trial of AppDynamics Pro today!_______________________________________________Csound-devel mailing list------------------------------------------------------------------------------See everything from the browser to the database with AppDynamicsGet end-to-end visibility with application monitoring from AppDynamicsIsolate bottlenecks and diagnose root cause in seconds.Start your free trial of AppDynamics Pro today!_______________________________________________Csound-devel mailing list------------------------------------------------------------------------------See everything from the browser to the database with AppDynamicsGet end-to-end visibility with application monitoring from AppDynamicsIsolate bottlenecks and diagnose root cause in seconds.Start your free trial of AppDynamics Pro today!_______________________________________________Csound-devel mailing list------------------------------------------------------------------------------See everything from the browser to the database with AppDynamicsGet end-to-end visibility with application monitoring from AppDynamicsIsolate bottlenecks and diagnose root cause in seconds.Start your free trial of AppDynamics Pro today!_______________________________________________Csound-devel mailing list------------------------------------------------------------------------------See everything from the browser to the database with AppDynamicsGet end-to-end visibility with application monitoring from AppDynamicsIsolate bottlenecks and diagnose root cause in seconds.Start your free trial of AppDynamics Pro today!Csound-devel mailing list------------------------------------------------------------------------------See everything from the browser to the database with AppDynamicsGet end-to-end visibility with application monitoring from AppDynamicsIsolate bottlenecks and diagnose root cause in seconds.Start your free trial of AppDynamics Pro today!_______________________________________________Csound-devel mailing list