-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorc_rollup.py
executable file
·65 lines (57 loc) · 1.33 KB
/
orc_rollup.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'''
Roll up all .inc files into one .orc file.
If the "instrnames" list is not empty, it is a flat list of .inc files that
will be rolled up in the order specified; otherwise, all the .inc files will
simply be concatenated.
'''
print(__doc__)
import os
import sys
instrnames = '''FMWaterBell.inc
Harpsichord.inc
HeavyMetal.inc
Internals.inc
MasterOutput.inc
Melody.inc
Sweeper.inc
Tambourine.inc
WGPluck.inc
ZakianFlute.inc
ReverbSC.inc
MasterOutput.inc'''
template_top = '''<CsoundSynthesizer>
<CsLicense>
This piece tests combinations of instr definitions.
</CsLicense>
<CsOptions>
--m-amps=1 --m-range=1 --m-dB=1 --m-benchmarks=1 --m-warnings=0 -+msg_color=0 -d -odac -Fmisty.mid
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 128
nchnls = 2
0dbfs = 4
'''
template_bottom = '''
</CsInstruments>
<CsScore>
f 0 360
</CsScore>
<CsoundSynthesizer>
'''
from pathlib import Path
orc = {}
print("Reading all .inc files...")
for p in Path('.').glob('patches/*.inc'):
print(f"Found: {p.name}")
orc[p.name] = p.read_text()
print("Creating output csd...")
if len(instrnames) > 0:
with open("rollup.csd", 'w') as output:
output.write(template_top)
for instrname in instrnames.split('\n'):
print("Using: ", instrname)
instr = orc[instrname]
output.write(instr)
output.write(template_bottom)
print("Finished.")