|
Hi list,
Does alwayson only work with names instruments? If so, is there an equivalent for regular instruments? Thanks, Alex
|
|
hi,
for me
alwayson 1 ; or similar
works perfectly
tarmo
On Monday 11 June 2012 12:25:43 Alex Weiss wrote: Hi list, Does alwayson only work with names instruments? If so, is there an equivalent for regular instruments? Thanks, Alex |
|
Hm, strange. This doesn't work for me:
alwayson 1 instr 1 asigL, asigR ins kamp invalue "0" outs asigL*kamp, asigR*kamp endin Am I doing something wrong? Alex On Mon, Jun 11, 2012 at 12:37 PM, Tarmo Johannes <[hidden email]> wrote:
|
|
i have no problems to run this.
what's your error message? joachim Am 11.06.2012 21:44, schrieb Alex Weiss: > alwayson 1 > > instr 1 > > asigL, asigR ins > > kamp invalue "0" > > outs asigL*kamp, asigR*kamp > > endin > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
No error message, the score just finishes immediately.
Alex
On Mon, Jun 11, 2012 at 1:24 PM, joachim heintz <[hidden email]> wrote: i have no problems to run this. |
|
Hello,
I am trying to write a sequencer and I am having difficulties scoring more than one note at a time using the csound API. Any help with this much appreciated. Below is the code, followed by the sender, followed by the receiver. ======================================================CODE================================================================= #include<stdio.h> #include<csound/csound.h> //performance thread function prototype uintptr_t csThread(void *clientData); //userData structure declaration struct userData { int result; CSOUND* sender[50]; CSOUND* receiver[50]; int PERF_STATUS[50]; double *psend[50]; double *precv[50]; int ksmps[50]; long startSample[50]; long endSample[50]; }; int main(int argc, char **argv){ void* ThreadID; struct userData* ud; ud = (struct userData *)malloc(sizeof(struct userData)); // sender, receiver instances char sar[40], kar[40]; int res,i; // set sender argvs char ** senderargv = malloc(sizeof (char *) * 3); senderargv[0] = malloc(sizeof(char)*6); senderargv[0] = "csound"; senderargv[1] = malloc(sizeof(char)*10); senderargv[1] = "sender.csd"; senderargv[2] = malloc(sizeof(char)*2); senderargv[2] = "-n"; // create instances ud->sender[0] = csoundCreate(NULL); ud->receiver[0] = csoundCreate(NULL); // compile sender // retrieve kr& sr csoundPreCompile(ud->sender[0]); //NOTE: Returns CSOUND_SUCCESS on success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. csoundCompile(ud->sender[0], 3, senderargv); sprintf(sar, "--sample-rate=%d", (int)csoundGetSr(ud->sender[0])); sprintf(kar, "--control-rate=%d", (int)csoundGetKr(ud->sender[0])); // set receiver argvs char ** receiverargv = malloc(sizeof (char *) * 4);; receiverargv[0] = malloc(sizeof(char)*6); receiverargv[0] = "csound"; receiverargv[1] = malloc(sizeof(char)*12); receiverargv[1] = "receiver.csd"; receiverargv[2] = malloc(sizeof(char)*40); receiverargv[2] = kar; receiverargv[3] = malloc(sizeof(char)*40); receiverargv[3] = sar; printf("-------------------> %s %s\n",receiverargv[2],receiverargv[3]); // compile receiver // force kr& sr csoundPreCompile(ud->receiver[0]); //NOTE: Returns CSOUND_SUCCESS on success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. csoundCompile(ud->receiver[0], 4, receiverargv); // get send and receive buffers ud->ksmps[0] = csoundGetKsmps(ud->sender[0]); ud->psend[0] = malloc(sizeof(double)*ud->ksmps[0]); ud->precv[0] = malloc(sizeof(double)*ud->ksmps[0]); ud->psend[0] = csoundGetSpout(ud->sender[0]); ud->precv[0] = csoundGetSpin(ud->receiver[0]); char *string = malloc(csoundGetStrVarMaxLen(ud->sender[0])); /* One complete performance cycle. */ int result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &string, "filename", CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL); strcpy(string, "clar.wav"); //printf("\n\n\n%d\n\n\n",(int)*sampleLength); ThreadID = csoundCreateThread(csThread, (void*)ud); double *sampleLength; sampleLength = malloc(sizeof(double)); *sampleLength = 0; while (*sampleLength == 0){ result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &sampleLength, "samplelength", CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL); } printf("\n\n\n\n%f\n\n\n\n",*sampleLength); fflush(stdout); ud->startSample[0] = 0; ud->endSample[0] = *sampleLength * (int)csoundGetSr(ud->sender[0]); double *samplerInput = malloc(sizeof(double)*3); samplerInput[0]=1; samplerInput[1]=0; samplerInput[2]=(double)(ud->endSample[0] - ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput, 3); csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput, 3); ////////////////////////////// I'M TRYING TO SCORE > 1 NOTE! TO THE SENDER AND RECEIVER: //////////////////////////////////////////////////////////////// double *samplerInput2 = malloc(sizeof(double)*3); samplerInput2[0]=1; samplerInput2[1]=2; samplerInput2[2]=(double)(ud->endSample[0] - ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput2, 3); csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput2, 3); while(ud->PERF_STATUS[0] != 0); } uintptr_t csThread(void *data) { struct userData* udata = (struct userData*)data; udata->PERF_STATUS[0] = 1; if(!udata->result) { long numOfSamples = 0; // fill first ksmps vector int i; udata->result = csoundPerformKsmps(udata->sender[0]); while(!udata->result && udata->PERF_STATUS[0] == 1){ // copy sender output to receiver input for(i=0; i < udata->ksmps[0]; i++) { if ( numOfSamples < udata->startSample[0] ) i = 0; else if (numOfSamples < udata->endSample[0]) udata->precv[0][i] = udata->psend[0][i]; if ( numOfSamples > udata->endSample[0] ) { udata->PERF_STATUS[0]=0; break; } ++numOfSamples; //printf("%d\n",numOfSamples); //fflush(stdout); } // process ksmps vectors udata->result = csoundPerformKsmps(udata->receiver[0]); if(!udata->result) udata->result = csoundPerformKsmps(udata->sender[0]); } // ); csoundDestroy(udata->sender[0]); csoundDestroy(udata->receiver[0]); } udata->PERF_STATUS[0] = 0; return 1; } ====================================================SENDER=================================================================== <CsoundSynthesizer> <CsOptions> -d </CsOptions> <CsInstruments> sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 0dbfs = 1 instr 1 S1 chnget "filename" a1 diskin2 S1, 1, 0, 1, 0, 32 out a1 endin instr 2 S1 chnget "filename" ilen filelen S1 printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen chnset ilen, "samplelength" printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen ;event_i "i", 2, 0, ilen endin </CsInstruments> <CsScore> i 2 0 1 e </CsScore> </CsoundSynthesizer> =================================================RECEIVER====================================================================== <CsoundSynthesizer> <CsOptions> -+rtaudio=pulse -odac </CsOptions> <CsInstruments> sr=44100 nchnls=1 0dbfs=1 ksmps=10 instr 1 a2 in out a2 endin instr 2 endin </CsInstruments> <CsScore> i2 0 1 e </CsScore> </CsoundSynthesizer> Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
Why do you need to have a sender and a receiver?
On 12 Jun 2012, at 03:46, Josh Branning wrote: > Hello, > > I am trying to write a sequencer and I am having difficulties scoring > more than one note at a time using the csound API. Any help with this > much appreciated. Below is the code, followed by the sender, followed by > the receiver. > > ======================================================CODE================================================================= > > #include<stdio.h> > #include<csound/csound.h> > > //performance thread function prototype > uintptr_t csThread(void *clientData); > > //userData structure declaration > struct userData { > int result; > CSOUND* sender[50]; > CSOUND* receiver[50]; > int PERF_STATUS[50]; > double *psend[50]; > double *precv[50]; > int ksmps[50]; > long startSample[50]; > long endSample[50]; > }; > > > int main(int argc, char **argv){ > > void* ThreadID; > struct userData* ud; > ud = (struct userData *)malloc(sizeof(struct userData)); > > // sender, receiver instances > > char sar[40], kar[40]; > int res,i; > > // set sender argvs > char ** senderargv = malloc(sizeof (char *) * 3); > senderargv[0] = malloc(sizeof(char)*6); > senderargv[0] = "csound"; > senderargv[1] = malloc(sizeof(char)*10); > senderargv[1] = "sender.csd"; > senderargv[2] = malloc(sizeof(char)*2); > senderargv[2] = "-n"; > > // create instances > ud->sender[0] = csoundCreate(NULL); > ud->receiver[0] = csoundCreate(NULL); > > // compile sender > // retrieve kr& sr > csoundPreCompile(ud->sender[0]); //NOTE: Returns CSOUND_SUCCESS on > success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. > csoundCompile(ud->sender[0], 3, senderargv); > sprintf(sar, "--sample-rate=%d", (int)csoundGetSr(ud->sender[0])); > sprintf(kar, "--control-rate=%d", (int)csoundGetKr(ud->sender[0])); > > // set receiver argvs > char ** receiverargv = malloc(sizeof (char *) * 4);; > receiverargv[0] = malloc(sizeof(char)*6); > receiverargv[0] = "csound"; > receiverargv[1] = malloc(sizeof(char)*12); > receiverargv[1] = "receiver.csd"; > receiverargv[2] = malloc(sizeof(char)*40); > receiverargv[2] = kar; > receiverargv[3] = malloc(sizeof(char)*40); > receiverargv[3] = sar; > > printf("-------------------> %s %s\n",receiverargv[2],receiverargv[3]); > > // compile receiver > // force kr& sr > csoundPreCompile(ud->receiver[0]); //NOTE: Returns CSOUND_SUCCESS on > success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. > csoundCompile(ud->receiver[0], 4, receiverargv); > > // get send and receive buffers > ud->ksmps[0] = csoundGetKsmps(ud->sender[0]); > ud->psend[0] = malloc(sizeof(double)*ud->ksmps[0]); > ud->precv[0] = malloc(sizeof(double)*ud->ksmps[0]); > ud->psend[0] = csoundGetSpout(ud->sender[0]); > ud->precv[0] = csoundGetSpin(ud->receiver[0]); > > char *string = malloc(csoundGetStrVarMaxLen(ud->sender[0])); > /* One complete performance cycle. */ > int result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &string, > "filename", > CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL); > strcpy(string, "clar.wav"); > > //printf("\n\n\n%d\n\n\n",(int)*sampleLength); > > ThreadID = csoundCreateThread(csThread, (void*)ud); > > double *sampleLength; > sampleLength = malloc(sizeof(double)); > *sampleLength = 0; > while (*sampleLength == 0){ > result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &sampleLength, > "samplelength", CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL); > } > printf("\n\n\n\n%f\n\n\n\n",*sampleLength); > fflush(stdout); > > ud->startSample[0] = 0; > ud->endSample[0] = *sampleLength * (int)csoundGetSr(ud->sender[0]); > > double *samplerInput = malloc(sizeof(double)*3); > samplerInput[0]=1; > samplerInput[1]=0; > samplerInput[2]=(double)(ud->endSample[0] - > ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); > > csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput, 3); > csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput, 3); > > ////////////////////////////// I'M TRYING TO SCORE > 1 NOTE! TO THE > SENDER AND RECEIVER: > //////////////////////////////////////////////////////////////// > > double *samplerInput2 = malloc(sizeof(double)*3); > samplerInput2[0]=1; > samplerInput2[1]=2; > samplerInput2[2]=(double)(ud->endSample[0] - > ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); > > csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput2, 3); > csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput2, 3); > > while(ud->PERF_STATUS[0] != 0); > > } > > uintptr_t csThread(void *data) > { > struct userData* udata = (struct userData*)data; > udata->PERF_STATUS[0] = 1; > if(!udata->result) > { > long numOfSamples = 0; > // fill first ksmps vector > int i; > udata->result = csoundPerformKsmps(udata->sender[0]); > while(!udata->result && udata->PERF_STATUS[0] == 1){ > // copy sender output to receiver input > for(i=0; i < udata->ksmps[0]; i++) > { > if ( numOfSamples < udata->startSample[0] ) i = 0; > else if (numOfSamples < udata->endSample[0]) udata->precv[0][i] = > udata->psend[0][i]; > if ( numOfSamples > udata->endSample[0] ) { > udata->PERF_STATUS[0]=0; > break; > } > ++numOfSamples; > //printf("%d\n",numOfSamples); > //fflush(stdout); > } > // process ksmps vectors > udata->result = csoundPerformKsmps(udata->receiver[0]); > if(!udata->result) udata->result = csoundPerformKsmps(udata->sender[0]); > } > // ); > csoundDestroy(udata->sender[0]); > csoundDestroy(udata->receiver[0]); > } > udata->PERF_STATUS[0] = 0; > return 1; > } > > ====================================================SENDER=================================================================== > <CsoundSynthesizer> > <CsOptions> > -d > </CsOptions> > <CsInstruments> > > sr = 44100 > kr = 4410 > ksmps = 10 > nchnls = 1 > 0dbfs = 1 > > instr 1 > S1 chnget "filename" > a1 diskin2 S1, 1, 0, 1, 0, 32 > out a1 > endin > > instr 2 > S1 chnget "filename" > ilen filelen S1 > printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen > chnset ilen, "samplelength" > printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen > ;event_i "i", 2, 0, ilen > endin > > </CsInstruments> > <CsScore> > i 2 0 1 > e > </CsScore> > </CsoundSynthesizer> > > =================================================RECEIVER====================================================================== > <CsoundSynthesizer> > <CsOptions> > -+rtaudio=pulse -odac > </CsOptions> > <CsInstruments> > sr=44100 > nchnls=1 > 0dbfs=1 > ksmps=10 > > instr 1 > a2 in > out a2 > > endin > > instr 2 > endin > > </CsInstruments> > <CsScore> > i2 0 1 > e > </CsScore> > </CsoundSynthesizer> > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
On 12/06/12 10:00, Victor Lazzarini wrote:
> Why do you need to have a sender and a receiver? > > > On 12 Jun 2012, at 03:46, Josh Branning wrote: > >> Hello, >> >> I am trying to write a sequencer and I am having difficulties scoring >> more than one note at a time using the csound API. Any help with this >> much appreciated. Below is the code, followed by the sender, followed by >> the receiver. >> >> ======================================================CODE================================================================= >> >> #include<stdio.h> >> #include<csound/csound.h> >> >> //performance thread function prototype >> uintptr_t csThread(void *clientData); >> >> //userData structure declaration >> struct userData { >> int result; >> CSOUND* sender[50]; >> CSOUND* receiver[50]; >> int PERF_STATUS[50]; >> double *psend[50]; >> double *precv[50]; >> int ksmps[50]; >> long startSample[50]; >> long endSample[50]; >> }; >> >> >> int main(int argc, char **argv){ >> >> void* ThreadID; >> struct userData* ud; >> ud = (struct userData *)malloc(sizeof(struct userData)); >> >> // sender, receiver instances >> >> char sar[40], kar[40]; >> int res,i; >> >> // set sender argvs >> char ** senderargv = malloc(sizeof (char *) * 3); >> senderargv[0] = malloc(sizeof(char)*6); >> senderargv[0] = "csound"; >> senderargv[1] = malloc(sizeof(char)*10); >> senderargv[1] = "sender.csd"; >> senderargv[2] = malloc(sizeof(char)*2); >> senderargv[2] = "-n"; >> >> // create instances >> ud->sender[0] = csoundCreate(NULL); >> ud->receiver[0] = csoundCreate(NULL); >> >> // compile sender >> // retrieve kr& sr >> csoundPreCompile(ud->sender[0]); //NOTE: Returns CSOUND_SUCCESS on >> success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. >> csoundCompile(ud->sender[0], 3, senderargv); >> sprintf(sar, "--sample-rate=%d", (int)csoundGetSr(ud->sender[0])); >> sprintf(kar, "--control-rate=%d", (int)csoundGetKr(ud->sender[0])); >> >> // set receiver argvs >> char ** receiverargv = malloc(sizeof (char *) * 4);; >> receiverargv[0] = malloc(sizeof(char)*6); >> receiverargv[0] = "csound"; >> receiverargv[1] = malloc(sizeof(char)*12); >> receiverargv[1] = "receiver.csd"; >> receiverargv[2] = malloc(sizeof(char)*40); >> receiverargv[2] = kar; >> receiverargv[3] = malloc(sizeof(char)*40); >> receiverargv[3] = sar; >> >> printf("-------------------> %s %s\n",receiverargv[2],receiverargv[3]); >> >> // compile receiver >> // force kr& sr >> csoundPreCompile(ud->receiver[0]); //NOTE: Returns CSOUND_SUCCESS on >> success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. >> csoundCompile(ud->receiver[0], 4, receiverargv); >> >> // get send and receive buffers >> ud->ksmps[0] = csoundGetKsmps(ud->sender[0]); >> ud->psend[0] = malloc(sizeof(double)*ud->ksmps[0]); >> ud->precv[0] = malloc(sizeof(double)*ud->ksmps[0]); >> ud->psend[0] = csoundGetSpout(ud->sender[0]); >> ud->precv[0] = csoundGetSpin(ud->receiver[0]); >> >> char *string = malloc(csoundGetStrVarMaxLen(ud->sender[0])); >> /* One complete performance cycle. */ >> int result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &string, >> "filename", >> CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL); >> strcpy(string, "clar.wav"); >> >> //printf("\n\n\n%d\n\n\n",(int)*sampleLength); >> >> ThreadID = csoundCreateThread(csThread, (void*)ud); >> >> double *sampleLength; >> sampleLength = malloc(sizeof(double)); >> *sampleLength = 0; >> while (*sampleLength == 0){ >> result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &sampleLength, >> "samplelength", CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL); >> } >> printf("\n\n\n\n%f\n\n\n\n",*sampleLength); >> fflush(stdout); >> >> ud->startSample[0] = 0; >> ud->endSample[0] = *sampleLength * (int)csoundGetSr(ud->sender[0]); >> >> double *samplerInput = malloc(sizeof(double)*3); >> samplerInput[0]=1; >> samplerInput[1]=0; >> samplerInput[2]=(double)(ud->endSample[0] - >> ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); >> >> csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput, 3); >> csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput, 3); >> >> ////////////////////////////// I'M TRYING TO SCORE > 1 NOTE! TO THE >> SENDER AND RECEIVER: >> //////////////////////////////////////////////////////////////// >> >> double *samplerInput2 = malloc(sizeof(double)*3); >> samplerInput2[0]=1; >> samplerInput2[1]=2; >> samplerInput2[2]=(double)(ud->endSample[0] - >> ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); >> >> csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput2, 3); >> csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput2, 3); >> >> while(ud->PERF_STATUS[0] != 0); >> >> } >> >> uintptr_t csThread(void *data) >> { >> struct userData* udata = (struct userData*)data; >> udata->PERF_STATUS[0] = 1; >> if(!udata->result) >> { >> long numOfSamples = 0; >> // fill first ksmps vector >> int i; >> udata->result = csoundPerformKsmps(udata->sender[0]); >> while(!udata->result && udata->PERF_STATUS[0] == 1){ >> // copy sender output to receiver input >> for(i=0; i < udata->ksmps[0]; i++) >> { >> if ( numOfSamples < udata->startSample[0] ) i = 0; >> else if (numOfSamples < udata->endSample[0]) udata->precv[0][i] = >> udata->psend[0][i]; >> if ( numOfSamples > udata->endSample[0] ) { >> udata->PERF_STATUS[0]=0; >> break; >> } >> ++numOfSamples; >> //printf("%d\n",numOfSamples); >> //fflush(stdout); >> } >> // process ksmps vectors >> udata->result = csoundPerformKsmps(udata->receiver[0]); >> if(!udata->result) udata->result = csoundPerformKsmps(udata->sender[0]); >> } >> // ); >> csoundDestroy(udata->sender[0]); >> csoundDestroy(udata->receiver[0]); >> } >> udata->PERF_STATUS[0] = 0; >> return 1; >> } >> >> ====================================================SENDER=================================================================== >> <CsoundSynthesizer> >> <CsOptions> >> -d >> </CsOptions> >> <CsInstruments> >> >> sr = 44100 >> kr = 4410 >> ksmps = 10 >> nchnls = 1 >> 0dbfs = 1 >> >> instr 1 >> S1 chnget "filename" >> a1 diskin2 S1, 1, 0, 1, 0, 32 >> out a1 >> endin >> >> instr 2 >> S1 chnget "filename" >> ilen filelen S1 >> printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen >> chnset ilen, "samplelength" >> printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen >> ;event_i "i", 2, 0, ilen >> endin >> >> </CsInstruments> >> <CsScore> >> i 2 0 1 >> e >> </CsScore> >> </CsoundSynthesizer> >> >> =================================================RECEIVER====================================================================== >> <CsoundSynthesizer> >> <CsOptions> >> -+rtaudio=pulse -odac >> </CsOptions> >> <CsInstruments> >> sr=44100 >> nchnls=1 >> 0dbfs=1 >> ksmps=10 >> >> instr 1 >> a2 in >> out a2 >> >> endin >> >> instr 2 >> endin >> >> </CsInstruments> >> <CsScore> >> i2 0 1 >> e >> </CsScore> >> </CsoundSynthesizer> >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >> > > Dr Victor Lazzarini > Senior Lecturer > Dept. of Music > NUI Maynooth Ireland > tel.: +353 1 708 3545 > Victor dot Lazzarini AT nuim dot ie > > > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > sound. I've also tried csoundSleep in the sequencer, to score just one note at a time, but it doesn't work very well. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
When I was doing someting similar I distinguished to need for a note with
a separate "now do it" message. But I was using channels and avoiding event except from the csound. Basically one needs to be aware of k-cycles ==John ff > On 12/06/12 10:00, Victor Lazzarini wrote: >> Why do you need to have a sender and a receiver? >> >> >> On 12 Jun 2012, at 03:46, Josh Branning wrote: >> >>> Hello, >>> >>> I am trying to write a sequencer and I am having difficulties scoring >>> more than one note at a time using the csound API. Any help with this >>> much appreciated. Below is the code, followed by the sender, followed >>> by >>> the receiver. >>> >>> Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
In reply to this post by Josh Branning
I don't know if `csoundScoreEventAbsolute' is useful in this case
http://csound.1045644.n5.nabble.com/csoundScoreEventAbsolute-td5608496.html tito Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
In reply to this post by Josh Branning
I think you should send your events before you start the thread. The problem might be synchronisation.
You should also avoid access issues by calling csoundScoreEvent() only from a yield callback, if you have csoundPerformKsmps() called in a separate thread. Or alternatively, you can use the CsoundPerformanceThread() class, which provides the services for this kind of thing. Victor On 12 Jun 2012, at 13:47, Josh Branning wrote: > On 12/06/12 10:00, Victor Lazzarini wrote: >> Why do you need to have a sender and a receiver? >> >> >> On 12 Jun 2012, at 03:46, Josh Branning wrote: >> >>> Hello, >>> >>> I am trying to write a sequencer and I am having difficulties scoring >>> more than one note at a time using the csound API. Any help with this >>> much appreciated. Below is the code, followed by the sender, followed by >>> the receiver. >>> >>> ======================================================CODE================================================================= >>> >>> #include<stdio.h> >>> #include<csound/csound.h> >>> >>> //performance thread function prototype >>> uintptr_t csThread(void *clientData); >>> >>> //userData structure declaration >>> struct userData { >>> int result; >>> CSOUND* sender[50]; >>> CSOUND* receiver[50]; >>> int PERF_STATUS[50]; >>> double *psend[50]; >>> double *precv[50]; >>> int ksmps[50]; >>> long startSample[50]; >>> long endSample[50]; >>> }; >>> >>> >>> int main(int argc, char **argv){ >>> >>> void* ThreadID; >>> struct userData* ud; >>> ud = (struct userData *)malloc(sizeof(struct userData)); >>> >>> // sender, receiver instances >>> >>> char sar[40], kar[40]; >>> int res,i; >>> >>> // set sender argvs >>> char ** senderargv = malloc(sizeof (char *) * 3); >>> senderargv[0] = malloc(sizeof(char)*6); >>> senderargv[0] = "csound"; >>> senderargv[1] = malloc(sizeof(char)*10); >>> senderargv[1] = "sender.csd"; >>> senderargv[2] = malloc(sizeof(char)*2); >>> senderargv[2] = "-n"; >>> >>> // create instances >>> ud->sender[0] = csoundCreate(NULL); >>> ud->receiver[0] = csoundCreate(NULL); >>> >>> // compile sender >>> // retrieve kr& sr >>> csoundPreCompile(ud->sender[0]); //NOTE: Returns CSOUND_SUCCESS on >>> success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. >>> csoundCompile(ud->sender[0], 3, senderargv); >>> sprintf(sar, "--sample-rate=%d", (int)csoundGetSr(ud->sender[0])); >>> sprintf(kar, "--control-rate=%d", (int)csoundGetKr(ud->sender[0])); >>> >>> // set receiver argvs >>> char ** receiverargv = malloc(sizeof (char *) * 4);; >>> receiverargv[0] = malloc(sizeof(char)*6); >>> receiverargv[0] = "csound"; >>> receiverargv[1] = malloc(sizeof(char)*12); >>> receiverargv[1] = "receiver.csd"; >>> receiverargv[2] = malloc(sizeof(char)*40); >>> receiverargv[2] = kar; >>> receiverargv[3] = malloc(sizeof(char)*40); >>> receiverargv[3] = sar; >>> >>> printf("-------------------> %s %s\n",receiverargv[2],receiverargv[3]); >>> >>> // compile receiver >>> // force kr& sr >>> csoundPreCompile(ud->receiver[0]); //NOTE: Returns CSOUND_SUCCESS on >>> success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. >>> csoundCompile(ud->receiver[0], 4, receiverargv); >>> >>> // get send and receive buffers >>> ud->ksmps[0] = csoundGetKsmps(ud->sender[0]); >>> ud->psend[0] = malloc(sizeof(double)*ud->ksmps[0]); >>> ud->precv[0] = malloc(sizeof(double)*ud->ksmps[0]); >>> ud->psend[0] = csoundGetSpout(ud->sender[0]); >>> ud->precv[0] = csoundGetSpin(ud->receiver[0]); >>> >>> char *string = malloc(csoundGetStrVarMaxLen(ud->sender[0])); >>> /* One complete performance cycle. */ >>> int result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &string, >>> "filename", >>> CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL); >>> strcpy(string, "clar.wav"); >>> >>> //printf("\n\n\n%d\n\n\n",(int)*sampleLength); >>> >>> ThreadID = csoundCreateThread(csThread, (void*)ud); >>> >>> double *sampleLength; >>> sampleLength = malloc(sizeof(double)); >>> *sampleLength = 0; >>> while (*sampleLength == 0){ >>> result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &sampleLength, >>> "samplelength", CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL); >>> } >>> printf("\n\n\n\n%f\n\n\n\n",*sampleLength); >>> fflush(stdout); >>> >>> ud->startSample[0] = 0; >>> ud->endSample[0] = *sampleLength * (int)csoundGetSr(ud->sender[0]); >>> >>> double *samplerInput = malloc(sizeof(double)*3); >>> samplerInput[0]=1; >>> samplerInput[1]=0; >>> samplerInput[2]=(double)(ud->endSample[0] - >>> ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); >>> >>> csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput, 3); >>> csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput, 3); >>> >>> ////////////////////////////// I'M TRYING TO SCORE > 1 NOTE! TO THE >>> SENDER AND RECEIVER: >>> //////////////////////////////////////////////////////////////// >>> >>> double *samplerInput2 = malloc(sizeof(double)*3); >>> samplerInput2[0]=1; >>> samplerInput2[1]=2; >>> samplerInput2[2]=(double)(ud->endSample[0] - >>> ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); >>> >>> csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput2, 3); >>> csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput2, 3); >>> >>> while(ud->PERF_STATUS[0] != 0); >>> >>> } >>> >>> uintptr_t csThread(void *data) >>> { >>> struct userData* udata = (struct userData*)data; >>> udata->PERF_STATUS[0] = 1; >>> if(!udata->result) >>> { >>> long numOfSamples = 0; >>> // fill first ksmps vector >>> int i; >>> udata->result = csoundPerformKsmps(udata->sender[0]); >>> while(!udata->result && udata->PERF_STATUS[0] == 1){ >>> // copy sender output to receiver input >>> for(i=0; i < udata->ksmps[0]; i++) >>> { >>> if ( numOfSamples < udata->startSample[0] ) i = 0; >>> else if (numOfSamples < udata->endSample[0]) udata->precv[0][i] = >>> udata->psend[0][i]; >>> if ( numOfSamples > udata->endSample[0] ) { >>> udata->PERF_STATUS[0]=0; >>> break; >>> } >>> ++numOfSamples; >>> //printf("%d\n",numOfSamples); >>> //fflush(stdout); >>> } >>> // process ksmps vectors >>> udata->result = csoundPerformKsmps(udata->receiver[0]); >>> if(!udata->result) udata->result = csoundPerformKsmps(udata->sender[0]); >>> } >>> // ); >>> csoundDestroy(udata->sender[0]); >>> csoundDestroy(udata->receiver[0]); >>> } >>> udata->PERF_STATUS[0] = 0; >>> return 1; >>> } >>> >>> ====================================================SENDER=================================================================== >>> <CsoundSynthesizer> >>> <CsOptions> >>> -d >>> </CsOptions> >>> <CsInstruments> >>> >>> sr = 44100 >>> kr = 4410 >>> ksmps = 10 >>> nchnls = 1 >>> 0dbfs = 1 >>> >>> instr 1 >>> S1 chnget "filename" >>> a1 diskin2 S1, 1, 0, 1, 0, 32 >>> out a1 >>> endin >>> >>> instr 2 >>> S1 chnget "filename" >>> ilen filelen S1 >>> printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen >>> chnset ilen, "samplelength" >>> printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen >>> ;event_i "i", 2, 0, ilen >>> endin >>> >>> </CsInstruments> >>> <CsScore> >>> i 2 0 1 >>> e >>> </CsScore> >>> </CsoundSynthesizer> >>> >>> =================================================RECEIVER====================================================================== >>> <CsoundSynthesizer> >>> <CsOptions> >>> -+rtaudio=pulse -odac >>> </CsOptions> >>> <CsInstruments> >>> sr=44100 >>> nchnls=1 >>> 0dbfs=1 >>> ksmps=10 >>> >>> instr 1 >>> a2 in >>> out a2 >>> >>> endin >>> >>> instr 2 >>> endin >>> >>> </CsInstruments> >>> <CsScore> >>> i2 0 1 >>> e >>> </CsScore> >>> </CsoundSynthesizer> >>> >>> >>> Send bugs reports to the Sourceforge bug tracker >>> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >>> Discussions of bugs and features can be posted here >>> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >>> >> >> Dr Victor Lazzarini >> Senior Lecturer >> Dept. of Music >> NUI Maynooth Ireland >> tel.: +353 1 708 3545 >> Victor dot Lazzarini AT nuim dot ie >> >> >> >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >> > The sender is also used for displaying a waveform independently, without > sound. > > I've also tried csoundSleep in the sequencer, to score just one note at > a time, but it doesn't work very well. > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
On 12/06/12 14:43, Victor Lazzarini wrote:
> I think you should send your events before you start the thread. The problem might be synchronisation. The problem was synchronisation. > You should also avoid access issues by calling csoundScoreEvent() only from a yield callback, if you > have csoundPerformKsmps() called in a separate thread. > > Or alternatively, you can use the CsoundPerformanceThread() class, which provides the services for this kind of thing. This sounds like a good idea, but I'm trying to write the whole thing in C, rather than C++. Is there a C version of CsoundPerformanceThread()? > > Victor > > Thanks for the replies, Josh. > On 12 Jun 2012, at 13:47, Josh Branning wrote: > >> On 12/06/12 10:00, Victor Lazzarini wrote: >>> Why do you need to have a sender and a receiver? >>> >>> >>> On 12 Jun 2012, at 03:46, Josh Branning wrote: >>> >>>> Hello, >>>> >>>> I am trying to write a sequencer and I am having difficulties scoring >>>> more than one note at a time using the csound API. Any help with this >>>> much appreciated. Below is the code, followed by the sender, followed by >>>> the receiver. >>>> >>>> ======================================================CODE================================================================= >>>> >>>> #include<stdio.h> >>>> #include<csound/csound.h> >>>> >>>> //performance thread function prototype >>>> uintptr_t csThread(void *clientData); >>>> >>>> //userData structure declaration >>>> struct userData { >>>> int result; >>>> CSOUND* sender[50]; >>>> CSOUND* receiver[50]; >>>> int PERF_STATUS[50]; >>>> double *psend[50]; >>>> double *precv[50]; >>>> int ksmps[50]; >>>> long startSample[50]; >>>> long endSample[50]; >>>> }; >>>> >>>> >>>> int main(int argc, char **argv){ >>>> >>>> void* ThreadID; >>>> struct userData* ud; >>>> ud = (struct userData *)malloc(sizeof(struct userData)); >>>> >>>> // sender, receiver instances >>>> >>>> char sar[40], kar[40]; >>>> int res,i; >>>> >>>> // set sender argvs >>>> char ** senderargv = malloc(sizeof (char *) * 3); >>>> senderargv[0] = malloc(sizeof(char)*6); >>>> senderargv[0] = "csound"; >>>> senderargv[1] = malloc(sizeof(char)*10); >>>> senderargv[1] = "sender.csd"; >>>> senderargv[2] = malloc(sizeof(char)*2); >>>> senderargv[2] = "-n"; >>>> >>>> // create instances >>>> ud->sender[0] = csoundCreate(NULL); >>>> ud->receiver[0] = csoundCreate(NULL); >>>> >>>> // compile sender >>>> // retrieve kr& sr >>>> csoundPreCompile(ud->sender[0]); //NOTE: Returns CSOUND_SUCCESS on >>>> success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. >>>> csoundCompile(ud->sender[0], 3, senderargv); >>>> sprintf(sar, "--sample-rate=%d", (int)csoundGetSr(ud->sender[0])); >>>> sprintf(kar, "--control-rate=%d", (int)csoundGetKr(ud->sender[0])); >>>> >>>> // set receiver argvs >>>> char ** receiverargv = malloc(sizeof (char *) * 4);; >>>> receiverargv[0] = malloc(sizeof(char)*6); >>>> receiverargv[0] = "csound"; >>>> receiverargv[1] = malloc(sizeof(char)*12); >>>> receiverargv[1] = "receiver.csd"; >>>> receiverargv[2] = malloc(sizeof(char)*40); >>>> receiverargv[2] = kar; >>>> receiverargv[3] = malloc(sizeof(char)*40); >>>> receiverargv[3] = sar; >>>> >>>> printf("-------------------> %s %s\n",receiverargv[2],receiverargv[3]); >>>> >>>> // compile receiver >>>> // force kr& sr >>>> csoundPreCompile(ud->receiver[0]); //NOTE: Returns CSOUND_SUCCESS on >>>> success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. >>>> csoundCompile(ud->receiver[0], 4, receiverargv); >>>> >>>> // get send and receive buffers >>>> ud->ksmps[0] = csoundGetKsmps(ud->sender[0]); >>>> ud->psend[0] = malloc(sizeof(double)*ud->ksmps[0]); >>>> ud->precv[0] = malloc(sizeof(double)*ud->ksmps[0]); >>>> ud->psend[0] = csoundGetSpout(ud->sender[0]); >>>> ud->precv[0] = csoundGetSpin(ud->receiver[0]); >>>> >>>> char *string = malloc(csoundGetStrVarMaxLen(ud->sender[0])); >>>> /* One complete performance cycle. */ >>>> int result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &string, >>>> "filename", >>>> CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL); >>>> strcpy(string, "clar.wav"); >>>> >>>> //printf("\n\n\n%d\n\n\n",(int)*sampleLength); >>>> >>>> ThreadID = csoundCreateThread(csThread, (void*)ud); >>>> >>>> double *sampleLength; >>>> sampleLength = malloc(sizeof(double)); >>>> *sampleLength = 0; >>>> while (*sampleLength == 0){ >>>> result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &sampleLength, >>>> "samplelength", CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL); >>>> } >>>> printf("\n\n\n\n%f\n\n\n\n",*sampleLength); >>>> fflush(stdout); >>>> >>>> ud->startSample[0] = 0; >>>> ud->endSample[0] = *sampleLength * (int)csoundGetSr(ud->sender[0]); >>>> >>>> double *samplerInput = malloc(sizeof(double)*3); >>>> samplerInput[0]=1; >>>> samplerInput[1]=0; >>>> samplerInput[2]=(double)(ud->endSample[0] - >>>> ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); >>>> >>>> csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput, 3); >>>> csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput, 3); >>>> >>>> ////////////////////////////// I'M TRYING TO SCORE > 1 NOTE! TO THE >>>> SENDER AND RECEIVER: >>>> //////////////////////////////////////////////////////////////// >>>> >>>> double *samplerInput2 = malloc(sizeof(double)*3); >>>> samplerInput2[0]=1; >>>> samplerInput2[1]=2; >>>> samplerInput2[2]=(double)(ud->endSample[0] - >>>> ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); >>>> >>>> csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput2, 3); >>>> csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput2, 3); >>>> >>>> while(ud->PERF_STATUS[0] != 0); >>>> >>>> } >>>> >>>> uintptr_t csThread(void *data) >>>> { >>>> struct userData* udata = (struct userData*)data; >>>> udata->PERF_STATUS[0] = 1; >>>> if(!udata->result) >>>> { >>>> long numOfSamples = 0; >>>> // fill first ksmps vector >>>> int i; >>>> udata->result = csoundPerformKsmps(udata->sender[0]); >>>> while(!udata->result && udata->PERF_STATUS[0] == 1){ >>>> // copy sender output to receiver input >>>> for(i=0; i < udata->ksmps[0]; i++) >>>> { >>>> if ( numOfSamples < udata->startSample[0] ) i = 0; >>>> else if (numOfSamples < udata->endSample[0]) udata->precv[0][i] = >>>> udata->psend[0][i]; >>>> if ( numOfSamples > udata->endSample[0] ) { >>>> udata->PERF_STATUS[0]=0; >>>> break; >>>> } >>>> ++numOfSamples; >>>> //printf("%d\n",numOfSamples); >>>> //fflush(stdout); >>>> } >>>> // process ksmps vectors >>>> udata->result = csoundPerformKsmps(udata->receiver[0]); >>>> if(!udata->result) udata->result = csoundPerformKsmps(udata->sender[0]); >>>> } >>>> // ); >>>> csoundDestroy(udata->sender[0]); >>>> csoundDestroy(udata->receiver[0]); >>>> } >>>> udata->PERF_STATUS[0] = 0; >>>> return 1; >>>> } >>>> >>>> ====================================================SENDER=================================================================== >>>> <CsoundSynthesizer> >>>> <CsOptions> >>>> -d >>>> </CsOptions> >>>> <CsInstruments> >>>> >>>> sr = 44100 >>>> kr = 4410 >>>> ksmps = 10 >>>> nchnls = 1 >>>> 0dbfs = 1 >>>> >>>> instr 1 >>>> S1 chnget "filename" >>>> a1 diskin2 S1, 1, 0, 1, 0, 32 >>>> out a1 >>>> endin >>>> >>>> instr 2 >>>> S1 chnget "filename" >>>> ilen filelen S1 >>>> printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen >>>> chnset ilen, "samplelength" >>>> printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen >>>> ;event_i "i", 2, 0, ilen >>>> endin >>>> >>>> </CsInstruments> >>>> <CsScore> >>>> i 2 0 1 >>>> e >>>> </CsScore> >>>> </CsoundSynthesizer> >>>> >>>> =================================================RECEIVER====================================================================== >>>> <CsoundSynthesizer> >>>> <CsOptions> >>>> -+rtaudio=pulse -odac >>>> </CsOptions> >>>> <CsInstruments> >>>> sr=44100 >>>> nchnls=1 >>>> 0dbfs=1 >>>> ksmps=10 >>>> >>>> instr 1 >>>> a2 in >>>> out a2 >>>> >>>> endin >>>> >>>> instr 2 >>>> endin >>>> >>>> </CsInstruments> >>>> <CsScore> >>>> i2 0 1 >>>> e >>>> </CsScore> >>>> </CsoundSynthesizer> >>>> >>>> >>>> Send bugs reports to the Sourceforge bug tracker >>>> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >>>> Discussions of bugs and features can be posted here >>>> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >>>> >>> >>> Dr Victor Lazzarini >>> Senior Lecturer >>> Dept. of Music >>> NUI Maynooth Ireland >>> tel.: +353 1 708 3545 >>> Victor dot Lazzarini AT nuim dot ie >>> >>> >>> >>> >>> >>> Send bugs reports to the Sourceforge bug tracker >>> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >>> Discussions of bugs and features can be posted here >>> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >>> >> The sender is also used for displaying a waveform independently, without >> sound. >> >> I've also tried csoundSleep in the sequencer, to score just one note at >> a time, but it doesn't work very well. >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >> > > Dr Victor Lazzarini > Senior Lecturer > Dept. of Music > NUI Maynooth Ireland > tel.: +353 1 708 3545 > Victor dot Lazzarini AT nuim dot ie > > > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
No, there isn't but you can look at the source code and reimplement it in C.
Victor On 12 Jun 2012, at 16:27, Josh Branning wrote: > On 12/06/12 14:43, Victor Lazzarini wrote: >> I think you should send your events before you start the thread. The problem might be synchronisation. > > The problem was synchronisation. > >> You should also avoid access issues by calling csoundScoreEvent() only from a yield callback, if you >> have csoundPerformKsmps() called in a separate thread. >> >> Or alternatively, you can use the CsoundPerformanceThread() class, which provides the services for this kind of thing. > > This sounds like a good idea, but I'm trying to write the whole thing in > C, rather than C++. Is there a C version of CsoundPerformanceThread()? > >> >> Victor >> >> > > Thanks for the replies, > > Josh. > >> On 12 Jun 2012, at 13:47, Josh Branning wrote: >> >>> On 12/06/12 10:00, Victor Lazzarini wrote: >>>> Why do you need to have a sender and a receiver? >>>> >>>> >>>> On 12 Jun 2012, at 03:46, Josh Branning wrote: >>>> >>>>> Hello, >>>>> >>>>> I am trying to write a sequencer and I am having difficulties scoring >>>>> more than one note at a time using the csound API. Any help with this >>>>> much appreciated. Below is the code, followed by the sender, followed by >>>>> the receiver. >>>>> >>>>> ======================================================CODE================================================================= >>>>> >>>>> #include<stdio.h> >>>>> #include<csound/csound.h> >>>>> >>>>> //performance thread function prototype >>>>> uintptr_t csThread(void *clientData); >>>>> >>>>> //userData structure declaration >>>>> struct userData { >>>>> int result; >>>>> CSOUND* sender[50]; >>>>> CSOUND* receiver[50]; >>>>> int PERF_STATUS[50]; >>>>> double *psend[50]; >>>>> double *precv[50]; >>>>> int ksmps[50]; >>>>> long startSample[50]; >>>>> long endSample[50]; >>>>> }; >>>>> >>>>> >>>>> int main(int argc, char **argv){ >>>>> >>>>> void* ThreadID; >>>>> struct userData* ud; >>>>> ud = (struct userData *)malloc(sizeof(struct userData)); >>>>> >>>>> // sender, receiver instances >>>>> >>>>> char sar[40], kar[40]; >>>>> int res,i; >>>>> >>>>> // set sender argvs >>>>> char ** senderargv = malloc(sizeof (char *) * 3); >>>>> senderargv[0] = malloc(sizeof(char)*6); >>>>> senderargv[0] = "csound"; >>>>> senderargv[1] = malloc(sizeof(char)*10); >>>>> senderargv[1] = "sender.csd"; >>>>> senderargv[2] = malloc(sizeof(char)*2); >>>>> senderargv[2] = "-n"; >>>>> >>>>> // create instances >>>>> ud->sender[0] = csoundCreate(NULL); >>>>> ud->receiver[0] = csoundCreate(NULL); >>>>> >>>>> // compile sender >>>>> // retrieve kr& sr >>>>> csoundPreCompile(ud->sender[0]); //NOTE: Returns CSOUND_SUCCESS on >>>>> success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. >>>>> csoundCompile(ud->sender[0], 3, senderargv); >>>>> sprintf(sar, "--sample-rate=%d", (int)csoundGetSr(ud->sender[0])); >>>>> sprintf(kar, "--control-rate=%d", (int)csoundGetKr(ud->sender[0])); >>>>> >>>>> // set receiver argvs >>>>> char ** receiverargv = malloc(sizeof (char *) * 4);; >>>>> receiverargv[0] = malloc(sizeof(char)*6); >>>>> receiverargv[0] = "csound"; >>>>> receiverargv[1] = malloc(sizeof(char)*12); >>>>> receiverargv[1] = "receiver.csd"; >>>>> receiverargv[2] = malloc(sizeof(char)*40); >>>>> receiverargv[2] = kar; >>>>> receiverargv[3] = malloc(sizeof(char)*40); >>>>> receiverargv[3] = sar; >>>>> >>>>> printf("-------------------> %s %s\n",receiverargv[2],receiverargv[3]); >>>>> >>>>> // compile receiver >>>>> // force kr& sr >>>>> csoundPreCompile(ud->receiver[0]); //NOTE: Returns CSOUND_SUCCESS on >>>>> success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured. >>>>> csoundCompile(ud->receiver[0], 4, receiverargv); >>>>> >>>>> // get send and receive buffers >>>>> ud->ksmps[0] = csoundGetKsmps(ud->sender[0]); >>>>> ud->psend[0] = malloc(sizeof(double)*ud->ksmps[0]); >>>>> ud->precv[0] = malloc(sizeof(double)*ud->ksmps[0]); >>>>> ud->psend[0] = csoundGetSpout(ud->sender[0]); >>>>> ud->precv[0] = csoundGetSpin(ud->receiver[0]); >>>>> >>>>> char *string = malloc(csoundGetStrVarMaxLen(ud->sender[0])); >>>>> /* One complete performance cycle. */ >>>>> int result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &string, >>>>> "filename", >>>>> CSOUND_INPUT_CHANNEL | CSOUND_STRING_CHANNEL); >>>>> strcpy(string, "clar.wav"); >>>>> >>>>> //printf("\n\n\n%d\n\n\n",(int)*sampleLength); >>>>> >>>>> ThreadID = csoundCreateThread(csThread, (void*)ud); >>>>> >>>>> double *sampleLength; >>>>> sampleLength = malloc(sizeof(double)); >>>>> *sampleLength = 0; >>>>> while (*sampleLength == 0){ >>>>> result = csoundGetChannelPtr(ud->sender[0], (MYFLT **) &sampleLength, >>>>> "samplelength", CSOUND_OUTPUT_CHANNEL | CSOUND_CONTROL_CHANNEL); >>>>> } >>>>> printf("\n\n\n\n%f\n\n\n\n",*sampleLength); >>>>> fflush(stdout); >>>>> >>>>> ud->startSample[0] = 0; >>>>> ud->endSample[0] = *sampleLength * (int)csoundGetSr(ud->sender[0]); >>>>> >>>>> double *samplerInput = malloc(sizeof(double)*3); >>>>> samplerInput[0]=1; >>>>> samplerInput[1]=0; >>>>> samplerInput[2]=(double)(ud->endSample[0] - >>>>> ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); >>>>> >>>>> csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput, 3); >>>>> csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput, 3); >>>>> >>>>> ////////////////////////////// I'M TRYING TO SCORE > 1 NOTE! TO THE >>>>> SENDER AND RECEIVER: >>>>> //////////////////////////////////////////////////////////////// >>>>> >>>>> double *samplerInput2 = malloc(sizeof(double)*3); >>>>> samplerInput2[0]=1; >>>>> samplerInput2[1]=2; >>>>> samplerInput2[2]=(double)(ud->endSample[0] - >>>>> ud->startSample[0])/(int)csoundGetSr(ud->sender[0]); >>>>> >>>>> csoundScoreEvent(ud->sender[0], 'i', (MYFLT *) samplerInput2, 3); >>>>> csoundScoreEvent(ud->receiver[0], 'i', (MYFLT *) samplerInput2, 3); >>>>> >>>>> while(ud->PERF_STATUS[0] != 0); >>>>> >>>>> } >>>>> >>>>> uintptr_t csThread(void *data) >>>>> { >>>>> struct userData* udata = (struct userData*)data; >>>>> udata->PERF_STATUS[0] = 1; >>>>> if(!udata->result) >>>>> { >>>>> long numOfSamples = 0; >>>>> // fill first ksmps vector >>>>> int i; >>>>> udata->result = csoundPerformKsmps(udata->sender[0]); >>>>> while(!udata->result && udata->PERF_STATUS[0] == 1){ >>>>> // copy sender output to receiver input >>>>> for(i=0; i < udata->ksmps[0]; i++) >>>>> { >>>>> if ( numOfSamples < udata->startSample[0] ) i = 0; >>>>> else if (numOfSamples < udata->endSample[0]) udata->precv[0][i] = >>>>> udata->psend[0][i]; >>>>> if ( numOfSamples > udata->endSample[0] ) { >>>>> udata->PERF_STATUS[0]=0; >>>>> break; >>>>> } >>>>> ++numOfSamples; >>>>> //printf("%d\n",numOfSamples); >>>>> //fflush(stdout); >>>>> } >>>>> // process ksmps vectors >>>>> udata->result = csoundPerformKsmps(udata->receiver[0]); >>>>> if(!udata->result) udata->result = csoundPerformKsmps(udata->sender[0]); >>>>> } >>>>> // ); >>>>> csoundDestroy(udata->sender[0]); >>>>> csoundDestroy(udata->receiver[0]); >>>>> } >>>>> udata->PERF_STATUS[0] = 0; >>>>> return 1; >>>>> } >>>>> >>>>> ====================================================SENDER=================================================================== >>>>> <CsoundSynthesizer> >>>>> <CsOptions> >>>>> -d >>>>> </CsOptions> >>>>> <CsInstruments> >>>>> >>>>> sr = 44100 >>>>> kr = 4410 >>>>> ksmps = 10 >>>>> nchnls = 1 >>>>> 0dbfs = 1 >>>>> >>>>> instr 1 >>>>> S1 chnget "filename" >>>>> a1 diskin2 S1, 1, 0, 1, 0, 32 >>>>> out a1 >>>>> endin >>>>> >>>>> instr 2 >>>>> S1 chnget "filename" >>>>> ilen filelen S1 >>>>> printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen >>>>> chnset ilen, "samplelength" >>>>> printf_i ">>>>>>>>>>>>>>>>>>>> %f <<<<<<<<<<<<<<<<<<\n", 1, ilen >>>>> ;event_i "i", 2, 0, ilen >>>>> endin >>>>> >>>>> </CsInstruments> >>>>> <CsScore> >>>>> i 2 0 1 >>>>> e >>>>> </CsScore> >>>>> </CsoundSynthesizer> >>>>> >>>>> =================================================RECEIVER====================================================================== >>>>> <CsoundSynthesizer> >>>>> <CsOptions> >>>>> -+rtaudio=pulse -odac >>>>> </CsOptions> >>>>> <CsInstruments> >>>>> sr=44100 >>>>> nchnls=1 >>>>> 0dbfs=1 >>>>> ksmps=10 >>>>> >>>>> instr 1 >>>>> a2 in >>>>> out a2 >>>>> >>>>> endin >>>>> >>>>> instr 2 >>>>> endin >>>>> >>>>> </CsInstruments> >>>>> <CsScore> >>>>> i2 0 1 >>>>> e >>>>> </CsScore> >>>>> </CsoundSynthesizer> >>>>> >>>>> >>>>> Send bugs reports to the Sourceforge bug tracker >>>>> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >>>>> Discussions of bugs and features can be posted here >>>>> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >>>>> >>>> >>>> Dr Victor Lazzarini >>>> Senior Lecturer >>>> Dept. of Music >>>> NUI Maynooth Ireland >>>> tel.: +353 1 708 3545 >>>> Victor dot Lazzarini AT nuim dot ie >>>> >>>> >>>> >>>> >>>> >>>> Send bugs reports to the Sourceforge bug tracker >>>> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >>>> Discussions of bugs and features can be posted here >>>> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >>>> >>> The sender is also used for displaying a waveform independently, without >>> sound. >>> >>> I've also tried csoundSleep in the sequencer, to score just one note at >>> a time, but it doesn't work very well. >>> >>> >>> Send bugs reports to the Sourceforge bug tracker >>> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >>> Discussions of bugs and features can be posted here >>> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >>> >> >> Dr Victor Lazzarini >> Senior Lecturer >> Dept. of Music >> NUI Maynooth Ireland >> tel.: +353 1 708 3545 >> Victor dot Lazzarini AT nuim dot ie >> >> >> >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >> > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
In reply to this post by Josh Branning
> This sounds like a good idea, but I'm trying to write the whole thing in
> C, rather than C++. Is there a C version of CsoundPerformanceThread()? No. You will need to implement your own thread but its not difficult. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
Why C instead of C++?
Regards, Mike On Tue, Jun 12, 2012 at 11:36 AM, Rory Walsh <[hidden email]> wrote: >> This sounds like a good idea, but I'm trying to write the whole thing in >> C, rather than C++. Is there a C version of CsoundPerformanceThread()? > > No. You will need to implement your own thread but its not difficult. > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > -- Michael Gogins Irreducible Productions http://www.michael-gogins.com Michael dot Gogins at gmail dot com Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
In reply to this post by rory walsh
On 12/06/12 16:36, Rory Walsh wrote:
>> This sounds like a good idea, but I'm trying to write the whole thing in >> C, rather than C++. Is there a C version of CsoundPerformanceThread()? > > No. You will need to implement your own thread but its not difficult. > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > it. Where should I start if I want to implement my own thread? Josh. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
The way you were doing in your own code is a good start. What you need to do to complement this is:
1) protect the csoundPerformKsmps() calls, so that they happen at different times to other Csound API calls in the other thread(s), esp. things like csoundScoreEvent() and csoundInputMessage(), but also channel access is probably good to protect. 2) one of the ways you can do this is by setting up a yield callback with csoundSetYieldCallback(), which gets called by csound after performKsmps() has done its job. You can put calls to csoundScoreEvent() etc. 3) the CsoundPerformanceThread() class does this by using a similar approach: it fills a queue with events requested (using CsoundPerformanceThread::inputMessage() etc) and then 'fires' these (in calls to csoundInputMessage() etc) in between performKsmps() calls. Regards Victor On 12 Jun 2012, at 20:31, Josh Branning wrote: > On 12/06/12 16:36, Rory Walsh wrote: >>> This sounds like a good idea, but I'm trying to write the whole thing in >>> C, rather than C++. Is there a C version of CsoundPerformanceThread()? >> >> No. You will need to implement your own thread but its not difficult. >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >> > I've had a look at the source code and I cannot make no head nor tail of > it. Where should I start if I want to implement my own thread? > > Josh. > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
On 12/06/12 20:49, Victor Lazzarini wrote:
> The way you were doing in your own code is a good start. What you need to do to complement this is: > > 1) protect the csoundPerformKsmps() calls, so that they happen at different times to other Csound API calls in > the other thread(s), esp. things like csoundScoreEvent() and csoundInputMessage(), but also channel access is probably good to protect. > > 2) one of the ways you can do this is by setting up a yield callback with csoundSetYieldCallback(), which gets called > by csound after performKsmps() has done its job. You can put calls to csoundScoreEvent() etc. > > 3) the CsoundPerformanceThread() class does this by using a similar approach: it fills a queue with events requested > (using CsoundPerformanceThread::inputMessage() etc) and then 'fires' these (in calls to csoundInputMessage() etc) in > between performKsmps() calls. > > Regards > > Victor > > On 12 Jun 2012, at 20:31, Josh Branning wrote: > >> On 12/06/12 16:36, Rory Walsh wrote: >>>> This sounds like a good idea, but I'm trying to write the whole thing in >>>> C, rather than C++. Is there a C version of CsoundPerformanceThread()? >>> >>> No. You will need to implement your own thread but its not difficult. >>> >>> >>> Send bugs reports to the Sourceforge bug tracker >>> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >>> Discussions of bugs and features can be posted here >>> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >>> >> I've had a look at the source code and I cannot make no head nor tail of >> it. Where should I start if I want to implement my own thread? >> >> Josh. >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email [hidden email] with body "unsubscribe csound" >> > > Dr Victor Lazzarini > Senior Lecturer > Dept. of Music > NUI Maynooth Ireland > tel.: +353 1 708 3545 > Victor dot Lazzarini AT nuim dot ie > > > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email [hidden email] with body "unsubscribe csound" > Thanks Victor, I'll have a go at this. :) Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
In reply to this post by Alex Weiss
Hi,
It might be related to your Csound version. Recent versions will run indefinitely instead of ending immediately if there is no score, so you might need to add something like: e 3600 in your score. Cheers, Andrés On Mon, Jun 11, 2012 at 3:42 PM, Alex Weiss <[hidden email]> wrote: > No error message, the score just finishes immediately. > > Alex > > > On Mon, Jun 11, 2012 at 1:24 PM, joachim heintz <[hidden email]> wrote: >> >> i have no problems to run this. >> what's your error message? >> joachim >> >> Am 11.06.2012 21:44, schrieb Alex Weiss: >> > alwayson 1 >> > >> > instr 1 >> > >> > asigL, asigR ins >> > >> > kamp invalue "0" >> > >> > outs asigL*kamp, asigR*kamp >> > >> > endin >> > >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email [hidden email] with body "unsubscribe >> csound" >> > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email [hidden email] with body "unsubscribe csound" |
|
In reply to this post by Alex Weiss
What is your score?
|
| Powered by Nabble | Edit this page |
