[Csnd] CSound and C
Date | 2010-01-29 03:49 |
From | Seiya Matsumiya |
Subject | [Csnd] CSound and C |
Hello all, I've actually been a part of the mailing list for a few months,... but have not said anything. I am emailing you all tonight to ask a question, but let me take this time to briefly introduce myself as well. I am one of Dr. Richard Boulanger's students at Berklee, and have been studying CSound for a few months now. I just started to learn C programming, and the question I have tonight is using C and CSound together. I've written the following code to test a certain function (it has a few memos): #include <stdio.h> int i; float amp,note; int main() { // the part directly below is the "parameter input" part: printf("Amplitude?: "); scanf("%f", &); printf("\nPitch?: "); scanf("%f", ¬e); // after a couple of things are typed in, I need <CsoundSynthesizer> and //</CsoundSynthesizer> and everything in between printed out and saved as // a .csd file... and if possible, run, all of this in one process. // come to think of it, it doesn't need to print. How else could I get it to run? printf("<CsoundSynthesizer>\n"); printf("<CsInstruments>\n"); printf("sr = 44100\n"); printf("ksmps = 4410\n"); printf("kr = 10\n"); printf("nchnls = 1\n"); printf("instr 1\n"); printf("a1 oscil %f, cpspch(%f), 1\n", amp,note);//parameters entered go here. printf("out a1\n"); printf("endin\n"); printf("</CsInstruments>\n"); printf("<CsScore>\n"); printf("f1 0 4096 10 1\n"); printf("i1 0 3\n"); printf("</CsScore>\n"); printf("</CsoundSynthesizer>\n"); printf("Enter 1 to start: "); scanf("%d", &i); switch (i) { case 1: system ("./simplec >> simplec.csd & csound -odac simplec.csd"); //I was trying to get this code to make a .csd file // but when it does, the parameters entered are gone. break; } return 0; } The memos within the code describes my problem pretty well. I'm trying to find a way to enter the amplitude, and the pitch, of a 3 second sine wave, and output the data as a .csd file and run it. But when I do this the parameter's that I've just put in go away and 0 is used for both the amplitude and the pitch. What can I do so that everytime I run the program I can put in new parameters, and create a new .csd file with those parameters? I'm only a couple days into C and may be getting too far ahead of myself. I was trying things with fopen () and fwrite() but gave up after a few hours of producing only errors. I would greatly appreciate it if someone could point me in the right direction!! Hope to hear from you soon, and hopefully you'll hear a lot more from me soon, too. Seiya Matsumiya |