[Csnd] Need some help with array data opcodes
Date | 2025-03-05 09:17 |
From | Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> |
Subject | [Csnd] Need some help with array data opcodes |
Hello everybody! I’m still having troubles with developing a Opcode that generates a-array output and is handling it’s internal data with arrays. I can’t get my seg-faults to solve. I’m still on Csound 6, because these opcodes need to run at a few systems where it’s not possible yet to update these do Csound7. This is the link to the file: https://github.com/PvonN/Xine/blob/main/src/array_opcodes.c I can’t get this to work: - writing to a-array output - handle tem data inside the opcode with arrays Maybe someone has the time and patients to help me through this and can check what i do wrong there? I would be endlessly greatfull. All the best, Philipp Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2025-03-05 09:26 |
From | Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Need some help with array data opcodes |
- Audio Arrays: The data is organised as blocks of ksmps MYFLTs, instead of single MYFLTs in k- and i- arrays. So you just have to navigate the array memory with the proper offsets. I’m not quite sure about what you want to know in your second question. ======================== Prof. Victor Lazzarini Maynooth University Ireland > On 5 Mar 2025, at 09:17, Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> wrote: > > *Warning* > > This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe. > > Hello everybody! > > I’m still having troubles with developing a Opcode that generates a-array output and is handling it’s internal data with arrays. I can’t get my seg-faults to solve. > I’m still on Csound 6, because these opcodes need to run at a few systems where it’s not possible yet to update these do Csound7. > > This is the link to the file: > https://github.com/PvonN/Xine/blob/main/src/array_opcodes.c > > I can’t get this to work: > - writing to a-array output > - handle tem data inside the opcode with arrays > > Maybe someone has the time and patients to help me through this and can check what i do wrong there? I would be endlessly greatfull. > > All the best, > Philipp > Csound mailing list > Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND > Send bugs reports to > https://github.com/csound/csound/issues > Discussions of bugs and features can be posted here Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2025-03-05 09:46 |
From | Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Need some help with array data opcodes |
So, no ARRAYDAT involved for this? I also thought i have to init these output arrays like this: /* init output arrays */ p->n_voices = *p->n_particles; tabinit(csound, p->aout_x, p->n_voices); tabinit(csound, p->aout_y, p->n_voices); tabinit(csound, p->aout_z, p->n_voices); To my second point: i have sine parallel computation in this opcode, why i thought about saving these values for the next process cycle in a array. I thought i need AUXCH for this and did the init like this: /* init value arrays */ csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->x_in)); memset(p->x_in.auxp, 0, sizeof(MYFLT)*p->n_voices); csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->y_in)); memset(p->y_in.auxp, 0, sizeof(MYFLT)*p->n_voices); csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->z_in)); memset(p->z_in.auxp, 0, sizeof(MYFLT)*p->n_voices); csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->x_vals)); memset(p->x_vals.auxp, 0, sizeof(MYFLT)*p->n_voices); csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->y_vals)); memset(p->y_vals.auxp, 0, sizeof(MYFLT)*p->n_voices); csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->z_vals)); memset(p->z_vals.auxp, 0, sizeof(MYFLT)*p->n_voices); But i can’t get the data correctly saved after the processing loop. > Am 05.03.2025 um 10:26 schrieb Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>: > > - Audio Arrays: > > The data is organised as blocks of ksmps MYFLTs, instead of single MYFLTs in k- and i- arrays. So you > just have to navigate the array memory with the proper offsets. > > I’m not quite sure about what you want to know in your second question. > ======================== > Prof. Victor Lazzarini > Maynooth University > Ireland > >> On 5 Mar 2025, at 09:17, Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> wrote: >> >> *Warning* >> >> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe. >> >> Hello everybody! >> >> I’m still having troubles with developing a Opcode that generates a-array output and is handling it’s internal data with arrays. I can’t get my seg-faults to solve. >> I’m still on Csound 6, because these opcodes need to run at a few systems where it’s not possible yet to update these do Csound7. >> >> This is the link to the file: >> https://github.com/PvonN/Xine/blob/main/src/array_opcodes.c >> >> I can’t get this to work: >> - writing to a-array output >> - handle tem data inside the opcode with arrays >> >> Maybe someone has the time and patients to help me through this and can check what i do wrong there? I would be endlessly greatfull. >> >> All the best, >> Philipp >> Csound mailing list >> Csound@listserv.heanet.ie >> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND >> Send bugs reports to >> https://github.com/csound/csound/issues >> Discussions of bugs and features can be posted here > > > Csound mailing list > Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND > Send bugs reports to > https://github.com/csound/csound/issues > Discussions of bugs and features can be posted here Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2025-03-05 09:56 |
From | vlz |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Need some help with array data opcodes |
What I mean is that the data field in ARRAYDAT holds ksmps blocks for each array item, if you are using an audio array. If you want to put data in the AUXCH memory you’ve allocated, just use the pointer, e.g. p->x_in.auxp to access that memory. You can then use memcpy or assignment in a loop, depending on the source of the data. Does that make sense? > On 5 Mar 2025, at 09:46, Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> wrote: > > So, no ARRAYDAT involved for this? > > I also thought i have to init these output arrays like this: > > /* init output arrays */ > p->n_voices = *p->n_particles; > tabinit(csound, p->aout_x, p->n_voices); > tabinit(csound, p->aout_y, p->n_voices); > tabinit(csound, p->aout_z, p->n_voices); > > > To my second point: > i have sine parallel computation in this opcode, why i thought about saving these values for the next process cycle in a array. > > I thought i need AUXCH for this and did the init like this: > > /* init value arrays */ > csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->x_in)); > memset(p->x_in.auxp, 0, sizeof(MYFLT)*p->n_voices); > csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->y_in)); > memset(p->y_in.auxp, 0, sizeof(MYFLT)*p->n_voices); > csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->z_in)); > memset(p->z_in.auxp, 0, sizeof(MYFLT)*p->n_voices); > csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->x_vals)); > memset(p->x_vals.auxp, 0, sizeof(MYFLT)*p->n_voices); > csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->y_vals)); > memset(p->y_vals.auxp, 0, sizeof(MYFLT)*p->n_voices); > csound->AuxAlloc(csound, sizeof(MYFLT) * p->n_voices, &(p->z_vals)); > memset(p->z_vals.auxp, 0, sizeof(MYFLT)*p->n_voices); > > But i can’t get the data correctly saved after the processing loop. > > >> Am 05.03.2025 um 10:26 schrieb Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>: >> >> - Audio Arrays: >> >> The data is organised as blocks of ksmps MYFLTs, instead of single MYFLTs in k- and i- arrays. So you >> just have to navigate the array memory with the proper offsets. >> >> I’m not quite sure about what you want to know in your second question. >> ======================== >> Prof. Victor Lazzarini >> Maynooth University >> Ireland >> >>> On 5 Mar 2025, at 09:17, Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> wrote: >>> >>> *Warning* >>> >>> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe. >>> >>> Hello everybody! >>> >>> I’m still having troubles with developing a Opcode that generates a-array output and is handling it’s internal data with arrays. I can’t get my seg-faults to solve. >>> I’m still on Csound 6, because these opcodes need to run at a few systems where it’s not possible yet to update these do Csound7. >>> >>> This is the link to the file: >>> https://github.com/PvonN/Xine/blob/main/src/array_opcodes.c >>> >>> I can’t get this to work: >>> - writing to a-array output >>> - handle tem data inside the opcode with arrays >>> >>> Maybe someone has the time and patients to help me through this and can check what i do wrong there? I would be endlessly greatfull. >>> >>> All the best, >>> Philipp >>> Csound mailing list >>> Csound@listserv.heanet.ie >>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND >>> Send bugs reports to >>> https://github.com/csound/csound/issues >>> Discussions of bugs and features can be posted here >> >> >> Csound mailing list >> Csound@listserv.heanet.ie >> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND >> Send bugs reports to >> https://github.com/csound/csound/issues >> Discussions of bugs and features can be posted here > > Csound mailing list > Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND > Send bugs reports to > https://github.com/csound/csound/issues > Discussions of bugs and features can be posted here Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2025-03-05 11:05 |
From | Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Need some help with array data opcodes |
So in my struct i declare `ARRAYDAT *my_out_array;` In my init function i allocate memory for this via `tabinit(csound, p->my_out_array, array_size);` In my processing function i declaring, initilizing and casting to MYFLT like this `MYFLT my_out_array = (MYFLT*)p->my_out_array->data; And after this i just can write to it with the right offset? Or am i doing something wrong there? > Am 05.03.2025 um 10:56 schrieb vlz |
Date | 2025-03-05 11:38 |
From | Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Need some help with array data opcodes |
yes, something like that: ARRAYDAT *array; ... tabinit(csound, p->array, size); // size in items, tabinit allocates enough memory for the array type used ... MYFLT *array = (MYFLT *) p->array; then for(k = 0 ; k < size; k++) { // for each elem in array for(n = offset; n < nsmps; n++) { // ksmps loop array[k*ksmps + n] = … } } See for example how diskin does it when scaling the output (diskin2.c:1979): /* apply 0dBFS scale */ for (chn = 0; chn < p->nChannels; chn++) for (nn = offset; nn < nsmps; nn++) aOut[chn*ksmps+nn] *= csound->e0dbfs; ======================== Prof. Victor Lazzarini Maynooth University Ireland > On 5 Mar 2025, at 11:05, Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> wrote: > > So in my struct i declare `ARRAYDAT *my_out_array;` > > In my init function i allocate memory for this via > `tabinit(csound, p->my_out_array, array_size);` > > In my processing function i declaring, initilizing and casting to MYFLT like this > `MYFLT my_out_array = (MYFLT*)p->my_out_array->data; > > And after this i just can write to it with the right offset? > > Or am i doing something wrong there? > >> Am 05.03.2025 um 10:56 schrieb vlz |
Date | 2025-03-05 18:58 |
From | Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Need some help with array data opcodes |
Thanks Victor. This is clear now. Is my take on AUXCH right? in my struct: AUXCH arraydata; in my init function: csound->AuxAlloc(csound, sizeof(MYFLT) * size_of_array, &(p->arraydata)); memset(p->arraydara.auxp, 0, sizeof(MYFLT) * size_of_array); writing data to the array in my processing function: MYFLT *array = (MYFLT *) p->arraydata; for (int i = 0; i < size_of_array; i++){ array[i] = my_value; } > Am 05.03.2025 um 12:38 schrieb Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>: > > yes, something like that: > > ARRAYDAT *array; > > ... > tabinit(csound, p->array, size); // size in items, tabinit allocates enough memory for the array type used > > ... > MYFLT *array = (MYFLT *) p->array; > > then > > for(k = 0 ; k < size; k++) { // for each elem in array > for(n = offset; n < nsmps; n++) { // ksmps loop > array[k*ksmps + n] = … > } > } > > > See for example how diskin does it when scaling the output (diskin2.c:1979): > > > /* apply 0dBFS scale */ > for (chn = 0; chn < p->nChannels; chn++) > for (nn = offset; nn < nsmps; nn++) > aOut[chn*ksmps+nn] *= csound->e0dbfs; > > > ======================== > Prof. Victor Lazzarini > Maynooth University > Ireland > >> On 5 Mar 2025, at 11:05, Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> wrote: >> >> So in my struct i declare `ARRAYDAT *my_out_array;` >> >> In my init function i allocate memory for this via >> `tabinit(csound, p->my_out_array, array_size);` >> >> In my processing function i declaring, initilizing and casting to MYFLT like this >> `MYFLT my_out_array = (MYFLT*)p->my_out_array->data; >> >> And after this i just can write to it with the right offset? >> >> Or am i doing something wrong there? >> >>> Am 05.03.2025 um 10:56 schrieb vlz |
Date | 2025-03-05 20:50 |
From | vlz |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Need some help with array data opcodes |
Just a small change MYFLT *array = (MYFLT *) p->arraydata.auxp; Prof. Victor Lazzarini Maynooth University Ireland > On 5 Mar 2025, at 18:58, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote: > > Thanks Victor. This is clear now. > > Is my take on AUXCH right? > > in my struct: > AUXCH arraydata; > > in my init function: > csound->AuxAlloc(csound, sizeof(MYFLT) * size_of_array, &(p->arraydata)); > memset(p->arraydara.auxp, 0, sizeof(MYFLT) * size_of_array); > > writing data to the array in my processing function: > MYFLT *array = (MYFLT *) p->arraydata; > for (int i = 0; i < size_of_array; i++){ > array[i] = my_value; > } > >> Am 05.03.2025 um 12:38 schrieb Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>: >> >> yes, something like that: >> >> ARRAYDAT *array; >> >> ... >> tabinit(csound, p->array, size); // size in items, tabinit allocates enough memory for the array type used >> >> ... >> MYFLT *array = (MYFLT *) p->array; >> >> then >> >> for(k = 0 ; k < size; k++) { // for each elem in array >> for(n = offset; n < nsmps; n++) { // ksmps loop >> array[k*ksmps + n] = … >> } >> } >> >> >> See for example how diskin does it when scaling the output (diskin2.c:1979): >> >> >> /* apply 0dBFS scale */ >> for (chn = 0; chn < p->nChannels; chn++) >> for (nn = offset; nn < nsmps; nn++) >> aOut[chn*ksmps+nn] *= csound->e0dbfs; >> >> >> ======================== >> Prof. Victor Lazzarini >> Maynooth University >> Ireland >> >>>> On 5 Mar 2025, at 11:05, Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> wrote: >>> >>> So in my struct i declare `ARRAYDAT *my_out_array;` >>> >>> In my init function i allocate memory for this via >>> `tabinit(csound, p->my_out_array, array_size);` >>> >>> In my processing function i declaring, initilizing and casting to MYFLT like this >>> `MYFLT my_out_array = (MYFLT*)p->my_out_array->data; >>> >>> And after this i just can write to it with the right offset? >>> >>> Or am i doing something wrong there? >>> >>>> Am 05.03.2025 um 10:56 schrieb vlz |
Date | 2025-03-06 20:18 |
From | Philipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE> |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] Need some help with array data opcodes |
Thanks Victor again. But i can’t solve it. I double checked it twice, but something i am missing. My processing function isn’t even starting. My init function is starting and finishing. hmmm. maybe someone has time to check my code? https://github.com/PvonN/Xine/blob/main/src/array_opcodes.c All the best, Philipp > Am 05.03.2025 um 21:50 schrieb vlz |