forked from csound/csoundAPI_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample2.cs
More file actions
37 lines (31 loc) · 1.57 KB
/
Example2.cs
File metadata and controls
37 lines (31 loc) · 1.57 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
using System;
using System.Text;
using csound6netlib; //Exposes DotNet to Csound 6 Bridge's classes from csound6netlib.dll
namespace csoundAPI_examples
{
public partial class CsoundAPI_Examples
{
/* Example 2 - Compilation with Csound without CSD
*
* In this example, we move from using an external CSD file to
* embedding our Csound ORC and SCO code directly in our C# project.
* Besides allowing encapsulation of 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.
*/
public void Example2()
{
using (var c = new Csound6Net())
{
// Using SetOption() to configure Csound: here to output in realtime
c.SetOption("-odac"); // Note: SetOption uses only one commandline flag per call
c.CompileOrc(orc); // Compile the Csound Orchestra string
c.ReadScore("i1 0 1\n"); // Compile the Csound score as a string constant
c.Start(); // When compiling from strings, Start() is needed before performing
c.Perform();// Run Csound to completion
c.Stop(); // At this point, Csound is already stopped, but this call is here
} // as it is something that you would generally call in real-world
} // contexts.
}
}