[Csnd-dev] three questions on ftable GEN Plugins
Date | 2019-04-03 22:10 |
From | Oscar Pablo Di Liscia |
Subject | [Csnd-dev] three questions on ftable GEN Plugins |
I'm just starting to code a GEN Plugin to store the raw data of the ATS analysis files, plus some additional data in a function table. As I am planning to compute and store in the function table this aditional data that is not present in the ats files, I can't use the GEN01 for that purpose. So, just to give a try, I compiled the following code, which is adapted from Victor Lazarini example on his article: "Extensions to the Csound Language: from User-Defined to Plugin Opcodes and Beyond." /////////////////////////////////////////////////////////////////////////////////////////////////////////////// static void genats_func(CSOUND *csound, FUNC *ftp, FGDATA *ff) { /* the function table */ MYFLT *fp = ftp->ftable; int32_t nvals, nargs; nvals = ff->flen; nargs = ff->e.pcnt - 4; csound->Message(csound, Str("genats: len:%d nargs:%d \n"), nvals, nargs); return; } static NGFENS localfgens[] = { { "genats", (void(*)(void))genats_func}, { NULL, NULL} }; #define S sizeof static OENTRY *localops = NULL; FLINKAGE /////////////////////////////////////////////////////////////////////////////////////////////////////////////// Compiling it, I got the following warning: genats.c:41:13: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types] { "genats", (void(*)(void))genats_func}, ^ genats.c:41:13: note: (near initialization for 'localfgens[0].fn') Question 1: The coded compiled and the binary file was generated. However, what's the reason of such warning, and how significant could it be on the issues I will mention in questions 2 and 3? (Though I'm not familiar with the Csound API, in c programming parlance "incompatible pointer type", doesn't sound good to me, and it looks likely may produce some messy results...). Question 2: Invoking the generated GEN routine using Csound, this way: f1 0 0 "genats" 1 0 100 I got this message from Csound: "ftable 1: deferred size for GENs 1, 2, 23, 28 or 49 only" Can I code a GEN Plugin with deferred size? How so? Question 3: Invoking the generated GEN routine using Csound, this way (non-deferred size): f1 0 1024 "genats" 1 0 100 I got no errors, but the code: csound->Message(csound, Str("genats: len:%d nargs:%d \n"), nvals, nargs); Is ignored and nothing is printed. Why? Any help will be welcome. Pablo -- Dr. Oscar Pablo Di Liscia Profesor Titular Director Programa de Investigación "Sistemas Temporales y Síntesis Espacial en el Arte Sonoro" http://stseas.web.unq.edu.ar/ Director Colección Editorial "Música y Ciencia" Escuela Universitaria de Artes Universidad Nacional de Quilmes |
Date | 2019-04-04 21:23 |
From | Guillermo Senna |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
Hi Pablo, I'm not an expert, but I built a GEN plugin some time ago. On 3/4/19 18:10, Oscar Pablo Di Liscia wrote: > I'm just starting to code a GEN Plugin to store the raw data of the > ATS analysis files, plus some additional data in a function table. > As I am planning to compute and store in the function table this > aditional data that is not present in the ats files, > I can't use the GEN01 for that purpose. > So, just to give a try, I compiled the following code, which is > adapted from Victor Lazarini example on his article: > "Extensions to the Csound Language: from User-Defined to Plugin > Opcodes and Beyond." > /////////////////////////////////////////////////////////////////////////////////////////////////////////////// > static void genats_func(CSOUND *csound, FUNC *ftp, FGDATA *ff) > { > /* the function table */ > MYFLT *fp = ftp->ftable; > int32_t nvals, nargs; > > nvals = ff->flen; > nargs = ff->e.pcnt - 4; > csound->Message(csound, Str("genats: len:%d nargs:%d \n"), nvals, nargs); > > return; > } > > static NGFENS localfgens[] = { > { "genats", (void(*)(void))genats_func}, > { NULL, NULL} > }; > #define S sizeof > static OENTRY *localops = NULL; > FLINKAGE > /////////////////////////////////////////////////////////////////////////////////////////////////////////////// > > Compiling it, I got the following warning: > genats.c:41:13: warning: initialization from incompatible pointer type > [-Wincompatible-pointer-types] > { "genats", (void(*)(void))genats_func}, > ^ > genats.c:41:13: note: (near initialization for 'localfgens[0].fn') > > Question 1: The coded compiled and the binary file was generated. > However, what's the reason of such warning, > and how significant could it be on the issues I will mention in > questions 2 and 3? > (Though I'm not familiar with the Csound API, in c programming > parlance "incompatible pointer type", doesn't sound good to me, > and it looks likely may produce some messy results...). You can try with: static NGFENS localfgens[] = { { "genats", genats_func}, { NULL, NULL} }; FLINKAGE_BUILTIN(localfgens) But the function signature that I used was also different: static int32_t quadbeziertable (FGDATA *ff, FUNC *ftp) { int32_t nvals, nargs; MYFLT *fp = ftp->ftable; CSOUND *csound = ff->csound; nvals = ff->flen; nargs = ff->e.pcnt - 4; ... > > Question 2: Invoking the generated GEN routine using Csound, this way: > f1 0 0 "genats" 1 0 100 > I got this message from Csound: > "ftable 1: deferred size for GENs 1, 2, 23, 28 or 49 only" > Can I code a GEN Plugin with deferred size? How so? Probably not right now (?). I think you are hitting this: https://github.com/csound/csound/blob/16dc423d3914bf6a857b7b0c7db8d00dfab247b7/Engine/fgens.c#L230 > > Question 3: Invoking the generated GEN routine using Csound, this way > (non-deferred size): > f1 0 1024 "genats" 1 0 100 > I got no errors, but the code: > csound->Message(csound, Str("genats: len:%d nargs:%d \n"), nvals, nargs); > Is ignored and nothing is printed. Why? Maybe trying the above first will help. > > Any help will be welcome. > Pablo > |
Date | 2019-04-04 21:45 |
From | john |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
> Question 2: Invoking the generated GEN routine using Csound, this way: > f1 0 0 "genats" 1 0 100 > I got this message from Csound: > "ftable 1: deferred size for GENs 1, 2, 23, 28 or 49 only" > Can I code a GEN Plugin with deferred size? How so? Deferred allocaton is only available for that list of opcodes. As far as I remember I did not make any way of a user-defined named opcode could be added to that list. I will see if I can think of a way of doing it. |
Date | 2019-04-05 20:00 |
From | Oscar Pablo Di Liscia |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
Well many thanks, Guillermo and John for your feedback. John, I think that could be great to have a way of implementing GEN routines with deferred allocation. In the mean time, I suppose that what I could do is to create a new ATS file format that holds the data desired as well and to read this using GEN 01. Best Pablo El jueves, 4 de abril de 2019, john <jpff@codemist.co.uk> escribió: Question 2: Invoking the generated GEN routine using Csound, this way: -- Dr. Oscar Pablo Di Liscia Profesor Titular Director Programa de Investigación "Sistemas Temporales y Síntesis Espacial en el Arte Sonoro" http://stseas.web.unq.edu.ar/ Director Colección Editorial "Música y Ciencia" Escuela Universitaria de Artes Universidad Nacional de Quilmes Argentina |
Date | 2019-04-06 20:23 |
From | john |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
I have been locking at the code.... It might be (is) easy to allow a length of zero in a named Gen -- i.e. plugin gen and the implementation would need to check for the zero and act accordingly. Would that suffice? ==John On Fri, 5 Apr 2019, Oscar Pablo Di Liscia wrote: > Well many thanks, Guillermo and John for your feedback.John, I think that > could be great to have a way of implementing GEN routines with deferred > allocation. > In the mean time, I suppose that what I could do is to create a new ATS file > format that holds the data desired as well and to read this using GEN 01. > Best > Pablo > > El jueves, 4 de abril de 2019, john |
Date | 2019-04-06 23:46 |
From | Oscar Pablo Di Liscia |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
Many thanks John, it looks like it will be fine. So, I suppose I would have to compute the desired length and to use the Csound API function: int csoundFTAlloc(CSOUND *csound, int tableNum, int len) To allocate and use the needed memory. I´m I right? Many thanks El sáb., 6 abr. 2019 a las 16:23, john ( |
Date | 2019-04-07 21:18 |
From | john |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
As far as I understand stuff you are correct. I have made the simple change in the code but have not tested ittotally yet. I would mean adding hecks to the current gen plugins as well. Will do this during the week.. On Sat, 6 Apr 2019, Oscar Pablo Di Liscia wrote: > Many thanks John, it looks like it will be fine. > So, I suppose I would have to compute the desired length and to use > the Csound API function: > int csoundFTAlloc(CSOUND *csound, int tableNum, int len) > To allocate and use the needed memory. > I´m I right? > Many thanks > > El sáb., 6 abr. 2019 a las 16:23, john ( |
Date | 2019-04-08 00:39 |
From | Oscar Pablo Di Liscia |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
Many thanks again John. El domingo, 7 de abril de 2019, john <jpff@codemist.co.uk> escribió: As far as I understand stuff you are correct. I have made the simple change in the code but have not tested ittotally yet. I would mean adding hecks to the current gen plugins as well. Will do this during the week.. -- Dr. Oscar Pablo Di Liscia Profesor Titular Director Programa de Investigación "Sistemas Temporales y Síntesis Espacial en el Arte Sonoro" http://stseas.web.unq.edu.ar/ Director Colección Editorial "Música y Ciencia" Escuela Universitaria de Artes Universidad Nacional de Quilmes Argentina |
Date | 2019-04-08 08:38 |
From | John ff |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
Code committed
Sent from TypeApp
On 8 Apr 2019, at 00:40, Oscar Pablo Di Liscia <oscarpablodiliscia@gmail.com> wrote: Many thanks again John. |
Date | 2019-04-08 13:55 |
From | Oscar Pablo Di Liscia |
Subject | Re: [Csnd-dev] three questions on ftable GEN Plugins |
Great. I will try this. El lunes, 8 de abril de 2019, John ff <jpff@codemist.co.uk> escribió:
-- Dr. Oscar Pablo Di Liscia Profesor Titular Director Programa de Investigación "Sistemas Temporales y Síntesis Espacial en el Arte Sonoro" http://stseas.web.unq.edu.ar/ Director Colección Editorial "Música y Ciencia" Escuela Universitaria de Artes Universidad Nacional de Quilmes Argentina |