Skip to content

Commit fb4a774

Browse files
author
joachimheintz
committed
better example for scripts
1 parent 9612332 commit fb4a774

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

book/14-b-methods-of-writing-csound-scores.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ written:
184184

185185
To test this, first save this file as _print.py_ in the same folder
186186
where your .csd examples are:
187-
188187
```python
188+
189189
from sys import argv
190190
print("Script = '%s'" % argv[0])
191191
print("File to read = '%s'" % argv[1])
@@ -217,6 +217,31 @@ And again a complaint about the invalid score file:
217217

218218
cannot open scorefile /tmp/csound-NbMTfJ.sco
219219

220+
To get rid of the complaints we must write the score file. This is a simple example, saved as _test.py_:
221+
222+
``` python
223+
from sys import argv
224+
print("Script = '%s'" % argv[0])
225+
print("File to read = '%s'" % argv[1])
226+
print("File to write = '%s'" % argv[2])
227+
with open(argv[2], 'w') as out:
228+
out.write('i 1 0 1')
229+
```
230+
231+
Which is called in this Csound file:
232+
233+
``` csound-csd
234+
<CsoundSynthesizer>
235+
<CsInstruments>
236+
instr 1
237+
outall(poscil(.2,expon(1500,p3,400)))
238+
endin
239+
</CsInstruments>
240+
<CsScore bin="python3 test.py">
241+
</CsScore>
242+
</CsoundSynthesizer>
243+
```
244+
220245
### CsBeats
221246

222247
As an alternative to the classical Csound score,
@@ -267,7 +292,7 @@ e
267292
```perl
268293
# cs_sco_rand.pl
269294
my ($in, $out) = @ARGV;
270-
open(EXT, "<", $in);
295+
open(EXT, "<", $in);When you execute this .csd file in the terminal, your
271296
open(SCO, ">", $out);
272297

273298
while (<EXT>) {

0 commit comments

Comments
 (0)