forked from csound/csoundAPI_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample2.vb
More file actions
43 lines (31 loc) · 1.71 KB
/
Example2.vb
File metadata and controls
43 lines (31 loc) · 1.71 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
Imports csound6netlib 'Exposes DotNet to Csound 6 Bridge's classes from csound6netlib.dll
Partial Public Class 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 VB 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 Sub Example2()
Using c As 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.
End Using
End Sub
'Used in examples 2, 3 and 4
Public Const orc = "sr=44100" & vbCrLf & _
"ksmps=32" & vbCrLf & _
"nchnls=2" & vbCrLf & _
"0dbfs=1" & vbCrLf & _
"instr 1 " & vbCrLf & _
"aout vco2 0.5, 440" & vbCrLf & _
"outs aout, aout" & vbCrLf & _
"endin"
End Class