[Cs-dev] Performance thread using the csound api in c.
| Date | 2010-04-27 03:34 |
| From | Josh Brown |
| Subject | [Cs-dev] Performance thread using the csound api in c. |
Hello, not sure if I'm at the appropriate place but can anyone tell me why I don't get any sound with this program:
#include "H/csound.h"
#include
uintptr_t csThread(void *clientData);
typedef struct {
int result; //result of csoundCompile()
CSOUND* csound; //instane of Csound
int PERF_STATUS; //tells us if Csound is running
}userData;
//------------------------------------------------------------
int main(int argc, char *argv[])
{
int userInput=200;
void* ThreadID;
userData* ud;
ud = (userData *)malloc(sizeof(userData));
MYFLT* pvalue;
ud->csound=csoundCreate(NULL);
csoundInitialize(&argc, &argv, 0);
ud->result=csoundCompile(ud->csound,argc,argv);
if(!ud->result)
{
ud->PERF_STATUS=1;
ThreadID = csoundCreateThread(csThread, (void*)ud);
}
else
{
printf("csoundCompiled returned an error");
return 0;
}
printf("\nEnter a pitch in Hz(0 to Exit) and type return\n");
while(userInput!=0)
{
if(csoundGetChannelPtr(ud->csound, &pvalue, "pitch", CSOUND_INPUT_CHANNEL | CSOUND_CONTROL_CHANNEL)==0);
*pvalue = (MYFLT)userInput;
scanf("%d", &userInput);
printf("Okay, %d\n",userInput);
}
ud->PERF_STATUS=0;
return ud->result;
}
//-------------------------------------------------------------
//definition of our performance thread function
uintptr_t csThread(void *data)
{
userData* udata = (userData*)data;
if(!udata->result)
{
while((csoundPerformKsmps(udata->csound) == 0)
&&(udata->PERF_STATUS==1));
csoundDestroy(udata->csound);
}
udata->PERF_STATUS = 0;
return 1;
}
//--------------------------------------------------------------------------------------------
... I load this instrument file and get no sound:
instr 1
kval chnget "pitch"
a1 oscil 10000, kval, 1
out a1
endin
_________________________________________________________________
http://clk.atdmt.com/UKM/go/195013117/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |
| Date | 2010-04-27 08:38 |
| From | Victor.Lazzarini@nuim.ie |
| Subject | Re: [Cs-dev] Performance thread using the csound api in c. |
| Attachments | None None None None |
| Date | 2010-04-27 09:59 |
| From | Victor Lazzarini |
| Subject | Re: [Cs-dev] Performance thread using the csound api in c. |
Just tried that program here and it plays sound OK. On 27 Apr 2010, at 08:38, Victor.Lazzarini@nuim.ie wrote: > Do you have a score line to activate the instrument? > If not, you can add > > csoundInputMessage(csound, "i1 0 10000"); > > just before you start the thread. > > Victor > > ----- Original Message ----- > From: Josh Brown |
| Date | 2010-04-27 21:38 |
| From | Josh Brown |
| Subject | Re: [Cs-dev] Performance thread using the csound api in c. |
I couldn't get it to work. Am I doing something wrong?
----------------------------------------
> From: Victor.Lazzarini@nuim.ie
> To: csound-devel@lists.sourceforge.net
> Date: Tue, 27 Apr 2010 09:59:44 +0100
> Subject: Re: [Cs-dev] Performance thread using the csound api in c.
>
> Just tried that program here and it plays sound OK.
> On 27 Apr 2010, at 08:38, Victor.Lazzarini@nuim.ie wrote:
>
>> Do you have a score line to activate the instrument?
>> If not, you can add
>>
>> csoundInputMessage(csound, "i1 0 10000");
>>
>> just before you start the thread.
>>
>> Victor
>>
>> ----- Original Message -----
>> From: Josh Brown
>> Date: Tuesday, April 27, 2010 3:34 am
>> Subject: [Cs-dev] Performance thread using the csound api in c.
>> To: csound-devel@lists.sourceforge.net
>>
>>>
>>> Hello, not sure if I'm at the appropriate place but can anyone
>>> tell me why I don't get any sound with this program:
>>>
>>> #include "H/csound.h"
>>>
>>> #include
>>> uintptr_t csThread(void *clientData);
>>> typedef struct {
>>>
>>> int
>>> result; //result of csoundCompile()
>>>
>>> CSOUND*
>>> csound; //instane of Csound
>>>
>>> int
>>> PERF_STATUS; //tells us if Csound is running
>>>
>>> }userData;
>>> //------------------------------------------------------------
>>>
>>> int main(int argc, char *argv[])
>>>
>>> {
>>>
>>> int userInput=200;
>>>
>>> void* ThreadID;
>>>
>>> userData* ud;
>>>
>>> ud = (userData *)malloc(sizeof(userData));
>>>
>>> MYFLT* pvalue;
>>>
>>> ud->csound=csoundCreate(NULL);
>>>
>>> csoundInitialize(&argc, &argv, 0);
>>>
>>> ud->result=csoundCompile(ud->csound,argc,argv);
>>>
>>> if(!ud->result)
>>>
>>> {
>>>
>>> ud->PERF_STATUS=1;
>>>
>>> ThreadID = csoundCreateThread(csThread, (void*)ud);
>>>
>>> }
>>>
>>> else
>>>
>>> {
>>>
>>> printf("csoundCompiled returned an error");
>>>
>>> return 0;
>>>
>>> }
>>>
>>> printf("\nEnter a pitch in Hz(0 to Exit) and type return\n");
>>>
>>> while(userInput!=0)
>>>
>>> {
>>>
>>> if(csoundGetChannelPtr(ud-
>>>>csound, &pvalue, "pitch", CSOUND_INPUT_CHANNEL |
>>> CSOUND_CONTROL_CHANNEL)==0);
>>> *pvalue = (MYFLT)userInput;
>>>
>>> scanf("%d", &userInput);
>>>
>>> printf("Okay, %d\n",userInput);
>>>
>>> }
>>>
>>> ud->PERF_STATUS=0;
>>>
>>> return ud->result;
>>>
>>> }
>>>
>>> //-------------------------------------------------------------
>>>
>>> //definition of our performance thread function
>>>
>>> uintptr_t csThread(void *data)
>>>
>>> {
>>>
>>> userData* udata
>>> = (userData*)data;
>>>
>>> if(!udata->result)
>>>
>>> {
>>>
>>> while((csoundPerformKsmps(udata->csound) == 0)
>>>
>>> &&(udata->PERF_STATUS==1));
>>>
>>> csoundDestroy(udata->csound);
>>>
>>> }
>>>
>>> udata-
>>>>PERF_STATUS = 0;
>>>
>>> return 1;
>>>
>>> }
>>>
>>> //---------------------------------------------------------------
>>> -----------------------------
>>>
>>> ... I load this instrument file and get no sound:
>>>
>>> instr 1
>>>
>>> kval chnget "pitch"
>>>
>>> a1 oscil 10000, kval, 1
>>>
>>> out a1
>>>
>>> endin
>>>
>>> _________________________________________________________________
>>> http://clk.atdmt.com/UKM/go/195013117/direct/01/
>>> We want to hear all your funny, exciting and crazy Hotmail
>>> stories. Tell us now
>>> -----------------------------------------------------------------
>>> -------------
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> Dr Victor Lazzarini, Senior Lecturer, Dept. of Music,
>> National University of Ireland, Maynooth
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
_________________________________________________________________
http://clk.atdmt.com/UKM/go/197222280/direct/01/
Do you have a story that started on Hotmail? Tell us now
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |
| Date | 2010-04-28 10:26 |
| From | Victor Lazzarini |
| Subject | Re: [Cs-dev] Performance thread using the csound api in c. |
| Attachments | csth.csd None None |
What happens exactly? I used this CSD with it and it plays perfectly:
On 27 Apr 2010, at 21:38, Josh Brown wrote:
>
> I couldn't get it to work. Am I doing something wrong?
>
> ----------------------------------------
>> From: Victor.Lazzarini@nuim.ie
>> To: csound-devel@lists.sourceforge.net
>> Date: Tue, 27 Apr 2010 09:59:44 +0100
>> Subject: Re: [Cs-dev] Performance thread using the csound api in c.
>>
>> Just tried that program here and it plays sound OK.
>> On 27 Apr 2010, at 08:38, Victor.Lazzarini@nuim.ie wrote:
>>
>>> Do you have a score line to activate the instrument?
>>> If not, you can add
>>>
>>> csoundInputMessage(csound, "i1 0 10000");
>>>
>>> just before you start the thread.
>>>
>>> Victor
>>>
>>> ----- Original Message -----
>>> From: Josh Brown
>>> Date: Tuesday, April 27, 2010 3:34 am
>>> Subject: [Cs-dev] Performance thread using the csound api in c.
>>> To: csound-devel@lists.sourceforge.net
>>>
>>>>
>>>> Hello, not sure if I'm at the appropriate place but can anyone
>>>> tell me why I don't get any sound with this program:
>>>>
>>>> #include "H/csound.h"
>>>>
>>>> #include
>>>> uintptr_t csThread(void *clientData);
>>>> typedef struct {
>>>>
>>>> int
>>>> result; //result of csoundCompile()
>>>>
>>>> CSOUND*
>>>> csound; //instane of Csound
>>>>
>>>> int
>>>> PERF_STATUS; //tells us if Csound is running
>>>>
>>>> }userData;
>>>> //------------------------------------------------------------
>>>>
>>>> int main(int argc, char *argv[])
>>>>
>>>> {
>>>>
>>>> int userInput=200;
>>>>
>>>> void* ThreadID;
>>>>
>>>> userData* ud;
>>>>
>>>> ud = (userData *)malloc(sizeof(userData));
>>>>
>>>> MYFLT* pvalue;
>>>>
>>>> ud->csound=csoundCreate(NULL);
>>>>
>>>> csoundInitialize(&argc, &argv, 0);
>>>>
>>>> ud->result=csoundCompile(ud->csound,argc,argv);
>>>>
>>>> if(!ud->result)
>>>>
>>>> {
>>>>
>>>> ud->PERF_STATUS=1;
>>>>
>>>> ThreadID = csoundCreateThread(csThread, (void*)ud);
>>>>
>>>> }
>>>>
>>>> else
>>>>
>>>> {
>>>>
>>>> printf("csoundCompiled returned an error");
>>>>
>>>> return 0;
>>>>
>>>> }
>>>>
>>>> printf("\nEnter a pitch in Hz(0 to Exit) and type return\n");
>>>>
>>>> while(userInput!=0)
>>>>
>>>> {
>>>>
>>>> if(csoundGetChannelPtr(ud-
>>>>> csound, &pvalue, "pitch", CSOUND_INPUT_CHANNEL |
>>>> CSOUND_CONTROL_CHANNEL)==0);
>>>> *pvalue = (MYFLT)userInput;
>>>>
>>>> scanf("%d", &userInput);
>>>>
>>>> printf("Okay, %d\n",userInput);
>>>>
>>>> }
>>>>
>>>> ud->PERF_STATUS=0;
>>>>
>>>> return ud->result;
>>>>
>>>> }
>>>>
>>>> //-------------------------------------------------------------
>>>>
>>>> //definition of our performance thread function
>>>>
>>>> uintptr_t csThread(void *data)
>>>>
>>>> {
>>>>
>>>> userData* udata
>>>> = (userData*)data;
>>>>
>>>> if(!udata->result)
>>>>
>>>> {
>>>>
>>>> while((csoundPerformKsmps(udata->csound) == 0)
>>>>
>>>> &&(udata->PERF_STATUS==1));
>>>>
>>>> csoundDestroy(udata->csound);
>>>>
>>>> }
>>>>
>>>> udata-
>>>>> PERF_STATUS = 0;
>>>>
>>>> return 1;
>>>>
>>>> }
>>>>
>>>> //---------------------------------------------------------------
>>>> -----------------------------
>>>>
>>>> ... I load this instrument file and get no sound:
>>>>
>>>> instr 1
>>>>
>>>> kval chnget "pitch"
>>>>
>>>> a1 oscil 10000, kval, 1
>>>>
>>>> out a1
>>>>
>>>> endin
>>>>
>>>> _________________________________________________________________
>>>> http://clk.atdmt.com/UKM/go/195013117/direct/01/
>>>> We want to hear all your funny, exciting and crazy Hotmail
>>>> stories. Tell us now
>>>> -----------------------------------------------------------------
>>>> -------------
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> Dr Victor Lazzarini, Senior Lecturer, Dept. of Music,
>>> National University of Ireland, Maynooth
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> _________________________________________________________________
> http://clk.atdmt.com/UKM/go/197222280/direct/01/
> Do you have a story that started on Hotmail? Tell us now
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
|