Csound Csound-dev Csound-tekno Search About

csound.h and API Questions

Date2016-03-23 00:09
FromEmmett Palaima
Subjectcsound.h and API Questions
Hi, I'm trying to do some work with the csound api, running performance threads of csound, but I'm having trouble including the csound.h file referenced in the examples.


Does anyone know where I would get that from or what directory to add it to in order to get the examples to work. Additionally, how does one control which csd file is being run in a performance thread? That is not really clear to me from the article. 

Here is the example I copied and was trying to run, 
I get the error: 'csound/csound.h file not found

 #include <stdio.h> 
#include <csound/csound.h> 

uintptr_t csThread(void *clientData); 

typedef struct { 
  int result; 
  CSOUND *csound; 
  int PERF_STATUS; 
} userData; 

int main(int argc, char *argv[]) 
{
  int finish;
  void *ThreadID; 
  userData *ud; 
  ud = (userData *)malloc(sizeof(userData));  
  MYFLT *pvalue; 
  ud->csound = csoundCreate(NULL);  
  ud->result = csoundCompile(ud->csound, argc, argv); 

  if (!ud->result) {  
    ud->PERF_STATUS = 1; 
    ThreadID = csoundCreateThread(csThread, (void *)ud); 
  } 
  else { 
    return 1; 
  }  

  /* keep performing until user types a number and presses enter */
  scanf("%d", &finish);
  ud->PERF_STATUS = 0; 
  csoundDestroy(ud->csound); 
  free(ud);  
  return 0; 
} 

/* 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; 
}  
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

Date2016-03-23 07:52
FromFrancois PINOT
SubjectRe: csound.h and API Questions
Have you tried #include <csound.h>? The path to the include files might vary on different platforms.

2016-03-23 1:09 GMT+01:00 Emmett Palaima <epalaima@berklee.edu>:
Hi, I'm trying to do some work with the csound api, running performance threads of csound, but I'm having trouble including the csound.h file referenced in the examples.


Does anyone know where I would get that from or what directory to add it to in order to get the examples to work. Additionally, how does one control which csd file is being run in a performance thread? That is not really clear to me from the article. 

Here is the example I copied and was trying to run, 
I get the error: 'csound/csound.h file not found

 #include <stdio.h> 
#include <csound/csound.h> 

uintptr_t csThread(void *clientData); 

typedef struct { 
  int result; 
  CSOUND *csound; 
  int PERF_STATUS; 
} userData; 

int main(int argc, char *argv[]) 
{
  int finish;
  void *ThreadID; 
  userData *ud; 
  ud = (userData *)malloc(sizeof(userData));  
  MYFLT *pvalue; 
  ud->csound = csoundCreate(NULL);  
  ud->result = csoundCompile(ud->csound, argc, argv); 

  if (!ud->result) {  
    ud->PERF_STATUS = 1; 
    ThreadID = csoundCreateThread(csThread, (void *)ud); 
  } 
  else { 
    return 1; 
  }  

  /* keep performing until user types a number and presses enter */
  scanf("%d", &finish);
  ud->PERF_STATUS = 0; 
  csoundDestroy(ud->csound); 
  free(ud);  
  return 0; 
} 

/* 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; 
}  
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

Date2016-03-23 09:25
FromPeter Burgess
SubjectRe: csound.h and API Questions
aswell as which platform, it depends how you acquired csound.

If you happen to be on ubuntu (and probably other linux distros too),
and it's in the default system location (like it will be if you've
installed it via the package manager), you should find it at
/usr/local/include/csound/csound.h  .Otherwise, you'll have to find
where you have put the csound folder, and it'll be at
../csound/include/csound.h  .in the later case, you'll have to change
to:

#include 

like Francois has suggested. Also in either case, if you set the
include path to the folder containing csound.h, you can use the
#include line above instead.

If you're on windows, I don't know if there is a default location it
can end up like on linux, but if you know where the csound6 folder is,
it's at ../csound6/include/csound/csound.h (although my windows
version isn't very up to date, so this might have changed maybe).

I can't speak for any other platform.....

Now for the .csd:

I'm guessing you're coding in c, in which case if you use the function:

   csoundCompileCsd (CSOUND *csound, char *str);

The arguement char *str is the filepath to the .csd file you want to
compile. You then need to pass the pointer to csound to your
performance thread as an argument. I can't remember how best to do
that now, I haven't been using performance threads for ages. I also
use c++ rather than c, so it may work a little differently.

Hope some of this helps!

Pete

On Wed, Mar 23, 2016 at 7:52 AM, Francois PINOT  wrote:
> Have you tried #include ? The path to the include files might vary
> on different platforms.
>
> 2016-03-23 1:09 GMT+01:00 Emmett Palaima :
>>
>> Hi, I'm trying to do some work with the csound api, running performance
>> threads of csound, but I'm having trouble including the csound.h file
>> referenced in the examples.
>>
>> Im following this article:
>> http://write.flossmanuals.net/csound/a-the-csound-api/
>>
>> Does anyone know where I would get that from or what directory to add it
>> to in order to get the examples to work. Additionally, how does one control
>> which csd file is being run in a performance thread? That is not really
>> clear to me from the article.
>>
>> Here is the example I copied and was trying to run,
>> I get the error: 'csound/csound.h file not found
>>
>>  #include 
>> #include 
>>
>> uintptr_t csThread(void *clientData);
>>
>> typedef struct {
>>   int result;
>>   CSOUND *csound;
>>   int PERF_STATUS;
>> } userData;
>>
>> int main(int argc, char *argv[])
>> {
>>   int finish;
>>   void *ThreadID;
>>   userData *ud;
>>   ud = (userData *)malloc(sizeof(userData));
>>   MYFLT *pvalue;
>>   ud->csound = csoundCreate(NULL);
>>   ud->result = csoundCompile(ud->csound, argc, argv);
>>
>>   if (!ud->result) {
>>     ud->PERF_STATUS = 1;
>>     ThreadID = csoundCreateThread(csThread, (void *)ud);
>>   }
>>   else {
>>     return 1;
>>   }
>>
>>   /* keep performing until user types a number and presses enter */
>>   scanf("%d", &finish);
>>   ud->PERF_STATUS = 0;
>>   csoundDestroy(ud->csound);
>>   free(ud);
>>   return 0;
>> }
>>
>> /* 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;
>> }
>>
>> 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