forked from csound/csoundAPI_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringOrcScoPlayback.cpp
More file actions
56 lines (41 loc) · 1.05 KB
/
StringOrcScoPlayback.cpp
File metadata and controls
56 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* Example 1 - Simple Compilation with Csound
Author: Steven Yi <stevenyi@gmail.com> 2013.10.28
Adapted for C++ by Rory Walsh
In this example, we move from using an external CSD file to
embedding our Csound ORC and SCO code within our source.
Besides allowing encapsulating the code within the same file,
using the CompileOrc() and CompileSco() API calls is useful when
the SCO or ORC are generated, or perhaps coming from another
source, such as from a database or network.
*/
#include <stdio.h>
#include "csound.hpp"
#include <string>
int main()
{
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
csound->Perform();
//free Csound object
delete csound;
return 0;
}