int main() { //Create an instance of Csound Csound* csound = new Csound(); //compile instance of csound. csound->Compile("test2.csd"); //prepare Csound for performance csound->Start(); char tmp_string[4096] = {0}; //perform entire score while(csound->PerformKsmps()==0) { csound->GetStringChannel ("stringChannel", tmp_string); cout << tmp_string << " "; } //free Csound object delete csound; return 0; }
int main(int argc, char **argv) { if (argc == 1) { cout << "Usage:" << endl; cout << argv[0] << " [filename.csd] [instrument number] [ksmps offset]" << endl; return -1; } int ksmpsOffset = atoi(argv[3]); Csound* csound = new Csound(); csound->Compile(2, (const char **)argv); csound->Start(); csoundDebuggerInit(csound->GetCsound()); csoundSetBreakpointCallback(csound->GetCsound(), brkpt_cb, NULL); cout << "Csound filename: " << argv[1] << '\n'; cout << "Instr number:" << argv[2] << '\n'; double instr = atof(argv[2]); if (instr >= 1.0) { csoundSetInstrumentBreakpoint(csound->GetCsound(), instr, ksmpsOffset); } else { cout << "Invalid instrument breakpoint: " << instr; } csound->Perform(); csoundDebuggerClean(csound->GetCsound()); delete csound; }
int main() { //Create an instance of Csound Csound* csound = new Csound(); string csdText = "<CsoundSynthesizer>\n" "<CsOptions>\n" "csound -+rtaudio=jack -odac -B4096\n" "</CsOptions>\n" "<CsInstruments>\n" "sr = 44100\n" "ksmps = 64\n " "nchnls = 2\n" "0dbfs = 1\n" "instr 1\n" "a1 oscili 1, 300, 1\n" "outs a1, a1\n" "endin\n" "</CsInstruments>\n" "<CsScore>\n" "f1 0 1024 10 1\n" "i1 0 2\n" "</CsScore>\n" "</CsoundSynthesizer>\n"; //compile instance of csound. csound->CompileCsdText(csdText.c_str()); //prepare Csound for performance csound->Start(); //perform entire score csound->Perform(); //free Csound object delete csound; return 0; }
// Processing function void CsoundPlugin::Process(unsigned long cnt){ int pos, i, j, ksmps = csound->GetKsmps(),n = cnt; MYFLT scale = csound->Get0dBFS(); for(i=0;i<ctlports;i++) csound->SetChannel(ctlchn[i].c_str(), *(ctl[i])); if(!result){ for(i=0; i < n; i++, frames++){ if(frames == ksmps){ result = csound->PerformKsmps(); frames = 0; } for(j=0; j < chans; j++) if(!result){ pos = frames*chans; spin[j+pos] = inp[j][i]*scale; outp[j][i] = (LADSPA_Data) (spout[j+pos]/scale); } else outp[j][i] = 0; } } }
void test_server(void) { const char *instrument = "instr 1 \n" "k1 expon p4, p3, p4*0.001 \n" "a1 randi k1, p5 \n" "out a1 \n" "endin \n"; Csound csound; csound.SetOption((char*)"-odac"); csound.SetOption((char*)"--port=44100"); csound.Start(); CsoundPerformanceThread performanceThread(csound.GetCsound()); performanceThread.Play(); udp_send(instrument); udp_send("$i1 0 2 1000 1000"); csoundSleep(3000); udp_send("##close##"); performanceThread.Join(); csound.Cleanup(); csound.Reset(); }
int main(int argc, char *argv[]) { std::string orc = "sr=44100\n\ ksmps=32\n\ nchnls=2\n\ 0dbfs=1\n\ \n\ instr 1\n\ aout vco2 0.5, 440\n\ outs aout, aout\n\ endin"; std::string sco = "i1 0 1"; //create an instance of Csound Csound* csound = new Csound(); //set CsOptions csound->SetOption("-odac"); //compile orc csound->CompileOrc(orc.c_str()); //compile sco csound->ReadScore(sco.c_str()); //prepare Csound for performance csound->Start(); //perform entire score while(csound->PerformKsmps()==0); //free Csound object delete csound; return 0; }