forked from csound/csoundAPI_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample2.py
More file actions
39 lines (31 loc) · 1.1 KB
/
example2.py
File metadata and controls
39 lines (31 loc) · 1.1 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
# Example 2 - Compilation with Csound without CSD
# Author: Steven Yi <stevenyi@gmail.com>
# 2013.10.28
#
# In this example, we move from using an external CSD file to
# embedding our Csound ORC and SCO code within our Python project.
# 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.
import csnd6
# Defining our Csound ORC code within a triple-quoted, multiline String
orc = """
sr=44100
ksmps=32
nchnls=2
0dbfs=1
instr 1
aout vco2 0.5, 440
outs aout, aout
endin"""
# Defining our Csound SCO code
sco = "i1 0 1"
c = csnd6.Csound()
c.SetOption("-odac") # Using SetOption() to configure Csound
# Note: use only one commandline flag at a time
c.CompileOrc(orc) # Compile the Csound Orchestra string
c.ReadScore(sco) # Compile the Csound SCO String
c.Start() # When compiling from strings, this call is necessary before doing any performing
c.Perform() # Run Csound to completion
c.Stop()