Csound Csound-dev Csound-tekno Search About

[Csnd] Csound with C

Date2010-02-04 05:20
Frommichael geiler
Subject[Csnd] Csound with C
Hello everyone,
Just a quick introduction as this is my first time posing a question
to the Csound list...
My name is Michael Geiler and I am studying C programming with Dr.
Boulanger at Berklee College of Music.
I hope some of you can help me with a little problem I'm dealing with.

I am trying to run a command that will compile a file, run it, then
make it into a .csd file and finally launch Csound and the newly
created file all in one swoop.

--This is the code I am using

#include 

int main()
{
	printf("\n");
	printf("\n");
	printf("instr hellosine\n");
	printf(" a1 oscil 10000, 440, 1\n");
	printf(" out a1\n");
	printf("endin\n");
	printf("\n");
	printf("\n");
	printf("f 1  0 4096 10   1 ; GEN10 to compute a sine wave\n");
	printf("i \"hellosine\" 0 3\n");
	printf("\n");
	printf("\n");
	
	return 0;	
}

-- This is the command
gcc -o hellosine hellosine.c & ./hellosine > hellosine.csd & csound
-odac hellosine.csd

when I run the command I get the following message
-bash: csound: command not found

I had a similar problem when I first started writing code. the message was
-bash: cc: command not found

This was because I did not have a compiler installed on my computer
and once I did this I could use the cc and gcc commands.
Csound is installed on my computer (an Intel MacBook Pro) so I am not
sure what the problem is.

Thanks for all and any help.

Michael


Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-02-04 05:29
FromMike Moser-Booth
Subject[Csnd] Re: Csound with C
Can you run Csound from the terminal on its own? If not, you may need to 
add it to your .profile file (I had to do it at least). Check out this 
article from the Csound Journal. It spells it out pretty well:

http://www.csounds.com/journal/issue9/terminalOSX.html

.mmb

michael geiler wrote:
> Hello everyone,
> Just a quick introduction as this is my first time posing a question
> to the Csound list...
> My name is Michael Geiler and I am studying C programming with Dr.
> Boulanger at Berklee College of Music.
> I hope some of you can help me with a little problem I'm dealing with.
>
> I am trying to run a command that will compile a file, run it, then
> make it into a .csd file and finally launch Csound and the newly
> created file all in one swoop.
>
> --This is the code I am using
>
> #include 
>
> int main()
> {
> 	printf("\n");
> 	printf("\n");
> 	printf("instr hellosine\n");
> 	printf(" a1 oscil 10000, 440, 1\n");
> 	printf(" out a1\n");
> 	printf("endin\n");
> 	printf("\n");
> 	printf("\n");
> 	printf("f 1  0 4096 10   1 ; GEN10 to compute a sine wave\n");
> 	printf("i \"hellosine\" 0 3\n");
> 	printf("\n");
> 	printf("\n");
> 	
> 	return 0;	
> }
>
> -- This is the command
> gcc -o hellosine hellosine.c & ./hellosine > hellosine.csd & csound
> -odac hellosine.csd
>
> when I run the command I get the following message
> -bash: csound: command not found
>
> I had a similar problem when I first started writing code. the message was
> -bash: cc: command not found
>
> This was because I did not have a compiler installed on my computer
> and once I did this I could use the cc and gcc commands.
> Csound is installed on my computer (an Intel MacBook Pro) so I am not
> sure what the problem is.
>
> Thanks for all and any help.
>
> Michael
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>   



Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-02-04 06:44
FromMatsumiya Seiya
Subject[Csnd] Re: Re: Csound with C
Hello,

Thanks for so many responses. With a help from a friend & Dr.  
Boulanger I've figured it out.

Something like this works (replace the csound part with your own  
csound code):

#include 
#include 
int	i;
float	amp,note;
char csdFile[256];


int main()
{
	FILE *csdPointer;
	
	printf("Amplitude?: ");
	scanf("%f", &);
	printf("\nPitch (i.e. 8.00, 8.07)?: ");
	scanf("%f", ¬e);
	
	printf("\nEnter New File Name: ");
	scanf("%s", &csdFile);

	strcat(csdFile, ".csd");

	csdPointer = fopen(csdFile, "w");
	if(csdPointer !=NULL)
	{
		fprintf(csdPointer,"\n");
		fprintf(csdPointer,"\n");
		fprintf(csdPointer,"sr = 44100\n");
		fprintf(csdPointer,"ksmps = 4410\n");
		fprintf(csdPointer,"kr = 10\n");
		fprintf(csdPointer,"nchnls = 1\n");
		fprintf(csdPointer,"instr 1\n");
		fprintf(csdPointer,"a1	oscil %f, cpspch(%f), 1\n", amp,note);
		fprintf(csdPointer,"out a1\n");
		fprintf(csdPointer,"endin\n");
		fprintf(csdPointer,"\n");
		fprintf(csdPointer,"\n");
		fprintf(csdPointer,"f1 0 4096 10 	1\n");
		fprintf(csdPointer,"i1 0 3\n");
		fprintf(csdPointer,"\n");
		fprintf(csdPointer,"\n");

	}
	
	fclose(csdPointer);
	
	char commandline[1000] = "csound -odac ";
	strcat(commandline, csdFile);
	system(commandline);
	
	
	return 0;
}


Seiya


On Feb 4, 2010, at 12:29 AM, Mike Moser-Booth wrote:

> Can you run Csound from the terminal on its own? If not, you may  
> need to add it to your .profile file (I had to do it at least).  
> Check out this article from the Csound Journal. It spells it out  
> pretty well:
>
> http://www.csounds.com/journal/issue9/terminalOSX.html
>
> .mmb
>
> michael geiler wrote:
>> Hello everyone,
>> Just a quick introduction as this is my first time posing a question
>> to the Csound list...
>> My name is Michael Geiler and I am studying C programming with Dr.
>> Boulanger at Berklee College of Music.
>> I hope some of you can help me with a little problem I'm dealing  
>> with.
>>
>> I am trying to run a command that will compile a file, run it, then
>> make it into a .csd file and finally launch Csound and the newly
>> created file all in one swoop.
>>
>> --This is the code I am using
>>
>> #include 
>>
>> int main()
>> {
>> 	printf("\n");
>> 	printf("\n");
>> 	printf("instr hellosine\n");
>> 	printf(" a1 oscil 10000, 440, 1\n");
>> 	printf(" out a1\n");
>> 	printf("endin\n");
>> 	printf("\n");
>> 	printf("\n");
>> 	printf("f 1  0 4096 10   1 ; GEN10 to compute a sine wave\n");
>> 	printf("i \"hellosine\" 0 3\n");
>> 	printf("\n");
>> 	printf("\n");
>> 	
>> 	return 0;	
>> }
>>
>> -- This is the command
>> gcc -o hellosine hellosine.c & ./hellosine > hellosine.csd & csound
>> -odac hellosine.csd
>>
>> when I run the command I get the following message
>> -bash: csound: command not found
>>
>> I had a similar problem when I first started writing code. the  
>> message was
>> -bash: cc: command not found
>>
>> This was because I did not have a compiler installed on my computer
>> and once I did this I could use the cc and gcc commands.
>> Csound is installed on my computer (an Intel MacBook Pro) so I am not
>> sure what the problem is.
>>
>> Thanks for all and any help.
>>
>> Michael
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"



Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"