Debian Codegraph @

examples/makecsd.py

raw symbols SCIP
1 import glob
2 import os, re
3 files = glob.glob('*.orc')
4 files.sort()
5 files.remove('ambisonic.orc')
6 files.remove('fluid.orc')
7 files.remove('fluidAllOut.orc')
8
9 for file in files:
10 #print file
11 handleorc = open(file, 'r')
12 handlesco = open(file[:file.index('.orc')]+'.sco')
13 #print file[:file.index('.sco')]+'.csd'
14 newtext = '''<CsoundSynthesizer>
15 <CsOptions>
16 ; Select audio/midi flags here according to platform
17 ; Audio out Audio in Silent MIDI in
18 -odac -iadc -d -M0 ;;;realtime output
19 ; For Non-realtime ouput leave only the line below:
20 ; -o ''' + file[:file.index('.orc')] + '''.wav -W ;;; for file output any platform
21 </CsOptions>
22 <CsInstruments>
23 '''
24 commentorc = re.compile('/.*[0-9a-z]*\.orc.*/[\N\R]*')
25 commentsco = re.compile('/.*[0-9a-z]*\.sco.*/[\N\R]*')
26 orc = handleorc.read()
27 orc = commentorc.sub('',orc)
28 sco = handlesco.read()
29 sco = commentsco.sub('',sco)
30
31 newtext += orc + '\n</CsInstruments>\n<CsScore>\n' + sco + '\n</CsScore>\n</CsoundSynthesizer>\n'
32 #print newtext
33 dest = open(file[:file.index('.orc')]+'.csd','w')
34 dest.write(newtext)
35 dest.close()
36 handleorc.close()
37 handlesco.close()
38