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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
import random
hard = [('', '', '\\accent', '', 10), ('', '', '\\staccatissimo', '', 3)]
soft = [('', '', '\\tenuto', '', 10), ('', '', '\\portato', '', 10)]
slur = ('', '(', '', ')', 7)
normale = '^\\markup { \\italic norm }'
rvnh = "\n\\revert Voice.NoteHead #'style\n"
tremolo = ('', '^\\markup { \\italic trem }', '', normale, 5)
lv = ('', '', '\\laissezVibrer', '', 9)
pedal = ('', '\\sustainOn', '', '\\sustainOff', 5)
null = ('', '', '', '', 5)
class Instrument:
""" define a basic instrument """
def __init__(self, name):
self.name = name
self.timbre = {
'hard sound': hard + [],
'soft sound': soft + [],
'hard noise': hard + [],
'soft noise': soft + [],
'hard sound-noise': hard + [],
'soft sound-noise': soft + []
}
self.transposition = 0
self.staff = 0
self.pitched = True
self.quality = {
'muted': [null],
'accent': [null, ('', '', '\\marcato', '', 10)],
'accent reverb': [null],
'periodic': [null],
'aperiodic': [null]
}
self.sticks = False
self.tone = False
self.maxgrace = 3
self.clefs = None
class Clarinet(Instrument):
""" common attributes of clarinet """
def __init__(self, name, transposition):
Instrument.__init__(self, name)
self.transposition = transposition
self.timbre['hard sound'] += []
self.timbre['soft sound'] += [slur]
self.timbre['hard noise'] += [('', '', '-\\slaptongue', '', 5)]
self.timbre['soft noise'] += [('% multiphonics\n', '', '\\flageolet', '', 2)]
self.timbre['hard sound-noise'] += [('', '-\\markup { \\italic vox }', '', normale, 2)]
self.timbre['soft sound-noise'] += [('', '-\\markup { \\italic vox }', '', normale, 2), slur]
self.quality['periodic'] += [( \
"\\override TextSpanner #'bound-details #'left #'text = \"flz\"\n", \
'\\startTextSpan', '', '\\stopTextSpan', 4)]
#self.quality['aperiodic'] += [( \
# "\\override TextSpanner #'bound-details #'left #'text = \"bisbig\"\n", \
# '\\startTextSpan', '\\trill', '\\stopTextSpan', 3)]
self.quality['aperiodic'] += [('', '', '\\trill', '', 3)]
class Percussion(Instrument):
""" common attributes of percussion """
def __init__(self, name, staff):
Instrument.__init__(self, name)
self.sticks = True
self.staff = staff
self.quality['accent reverb'] += [lv]
class Guitar(Instrument):
""" common attributes of guitars """
def __init__(self, name):
Instrument.__init__(self, name)
handmute = ("\\override Voice.NoteHead #'style = #'harmonic-black % handmute\n", '', '', rvnh, 4)
self.timbre['hard sound'] += [
('', '^\\markup { \\italic sp }', '', normale, 6)]
self.timbre['soft sound'] += [slur]
self.timbre['hard noise'] += [
('', '^\\markup { \\italic msp }', '', normale, 6),
('', '', '^\\bartok', '', 3)]
self.timbre['soft noise'] += [handmute, slur]
self.timbre['hard sound-noise'] += []
self.timbre['soft sound-noise'] += [slur]
self.quality['muted'] += [handmute]
self.quality['periodic'] += [tremolo]
self.quality['accent reverb'] += [lv]
class Piano(Instrument):
def __init__(self, name, staff):
Instrument.__init__(self, name)
self.timbre['hard sound'] += []
self.timbre['soft sound'] += [slur]
self.timbre['hard noise'] += [
("\\override Voice.NoteHead #'style = #'xcircle % dampen\n", '', '', rvnh, 3)]
self.timbre['soft noise'] += [('% harmonics\n', '', '\\flageolet', '', 1), slur]
self.timbre['hard sound-noise'] += [
("\\override Voice.NoteHead #'style = #'triangle % pluck\n", '', '', rvnh, 2)]
self.timbre['soft sound-noise'] += [
("\\override Voice.NoteHead #'style = #'slash % hit\n", '', '', rvnh, 2), slur]
self.staff = staff
class Celeste(Instrument):
def __init__(self, name, staff):
Instrument.__init__(self, name)
self.staff = staff
self.timbre['soft sound'] += [slur]
self.timbre['soft noise'] += [slur]
self.timbre['soft sound-noise'] += [slur]
self.quality['accent reverb'] += [pedal]
class Cello(Instrument):
def __init__(self, name, staff):
Instrument.__init__(self, name)
sp = ('', '^\\markup { \\italic sp }', '', normale, 6)
msp = ('', '^\\markup { \\italic msp }', '', normale, 4)
st = ('', '^\\markup { \\italic st }', '', normale, 6)
mst = ('', '^\\markup { \\italic mst }', '', normale, 4)
pizz = ('', '^\\markup { \\italic pizz }', '', '^\\markup { \\italic arco }', 7)
bpizz = ('', '^\\markup { \\italic pizz }', '^\\bartok', '^\\markup { \\italic arco }', 3)
sord = ('', '^\\markup { \\italic "con sord" }', '', '^\\markup { \\italic "senza sord" }', 2)
ricochet = ('', '', '^\\ricochet', '', 3)
lowstring = ('', '^\\markup { \\italic "sul basso poss" }', '', normale, 5)
self.timbre['hard sound'] += [sp]
self.timbre['soft sound'] += [st, ('', '', '\\flageolet', '', 4), slur]
self.timbre['hard noise'] += [msp]
self.timbre['soft noise'] += [mst, slur]
self.timbre['hard sound-noise'] += [bpizz]
self.timbre['soft sound-noise'] += [pizz, slur]
self.quality['muted'] += [sord, lowstring]
self.quality['accent'] += []
self.quality['accent reverb'] += []
self.quality['periodic'] += [tremolo]
self.quality['aperiodic'] += [ricochet]
self.staff = staff
self.maxgrace = 2
class Speaker():
def __init__(self):
self.name = 'speaker'
self.staff = 0
self.sticks = False
self.tone = False
self.maxgrace = 0
self.clefs = None
class Player():
def __init__(self, number):
self.number = number
self.staves = []
self.staves = []
class Staff():
def __init__(self, name, attackconstant, poschange, negchange):
self.name = name
self.attackconstant = attackconstant
self.poschange = poschange
self.negchange = negchange
self.pos = []
self.neg = []
class Instrumentation():
def __init__(self, numberofplayers):
self.players = []
for p in range(numberofplayers):
self.players.append(Player(p))
instrumentation = Instrumentation(7)
p = instrumentation.players[0]
p.name = 'soprano'
p.staves.append(Staff('soprano', 0.6, ('\\tosing', ''), ('\\tospeak', '')))
p.staves[0].lyrics = []
p.staves[0].pos.append(Instrument('soprano'))
p.staves[0].pos[0].range = (('a', 0), ('c', 3))
p.staves[0].pos[0].stretch = (1, 1)
p.staves[0].pos[0].maxgrace = 0
p.staves[0].neg.append(Speaker())
p = instrumentation.players[1]
p.name = 'clarinet'
p.staves.append(Staff('clarinet', 1.4, \
('\\toAcl', '^\\markup { to Clarinet in A }'), \
('\\toEflcl', '^\\markup { to Clarinet in E\\flat }')))
p.staves[0].pos.append(Clarinet('clarinet A', 3))
p.staves[0].pos[0].range = (('cis', 0), ('a', 3))
p.staves[0].pos[0].stretch = (1, 1)
p.staves[0].neg.append(Clarinet('clarinet Es', -4))
p.staves[0].neg[0].range = (('g', 0), ('c', 3))
p.staves[0].neg[0].stretch = (1, 1)
p.staves[0].neg.append(Speaker())
p = instrumentation.players[2]
p.name = 'percussion'
p.staves.append(Staff('marimbavibraphone', 1.0, \
('\\topercAtwo', '^\\markup { to Marimba }'), \
('\\topercBtwo', '^\\markup { to Vibraphone }')))
p.staves.append(Staff('timpano', 0.08, \
('\\topercAthree', ''), ('\\topercBthree', '')))
p.staves.append(Staff('perccrotales', 1.0, \
('\\topercAone', '^\\markup { to Percussion }'), \
('\\topercBone', '^\\markup { to Crotales }')))
arco = ('', '^\\markup { \\italic arco }', '', normale, 2)
deadstick = ('', '', '^\\deadstick', '', 6)
p.staves[0].pos.append(Percussion('marimba', 1))
p.staves[0].pos[0].range = (('a', -1), ('c', 4))
p.staves[0].pos[0].clefs = [('bass', 25, 47), ('treble', 33, 76)]
p.staves[0].pos[0].stretch = (2, 8)
p.staves[0].pos[0].timbre['hard sound'] += []
p.staves[0].pos[0].timbre['soft sound'] += [arco, slur]
p.staves[0].pos[0].timbre['hard noise'] += [deadstick]
p.staves[0].pos[0].timbre['soft noise'] += [arco, slur]
p.staves[0].pos[0].timbre['hard sound-noise'] += []
p.staves[0].pos[0].timbre['soft sound-noise'] += [arco, slur]
p.staves[1].pos.append(Percussion('timpano', 2))
p.staves[1].pos[0].maxgrace = 0
p.staves[1].pos[0].range = (('g', -1), ('d', 0))
p.staves[1].pos[0].stretch = (1, 1)
p.staves[1].pos[0].timbre['hard sound'] += []
p.staves[1].pos[0].timbre['soft sound'] += []
p.staves[1].pos[0].timbre['hard noise'] += [deadstick]
p.staves[1].pos[0].timbre['soft noise'] += []
p.staves[1].pos[0].timbre['hard sound-noise'] += []
p.staves[1].pos[0].timbre['soft sound-noise'] += []
p.staves[1].pos[0].quality['accent reverb'] += [lv]
logdrum = [32, 33]
templeblocks = [39, 40, 42]
cymbals = [45, 47, 49]
p.staves[2].instrumenttimbre = {
'hard sound': logdrum + templeblocks,
'soft sound': logdrum,
'hard noise': templeblocks + cymbals,
'soft noise': cymbals,
'hard sound-noise': logdrum + templeblocks + cymbals,
'soft sound-noise': logdrum + cymbals,
'free': logdrum + templeblocks + cymbals
}
p.staves[2].pos.append(Percussion('cymbals', 0))
p.staves[2].pos[0].range = cymbals
p.staves[2].pos[0].stretch = (1, 1)
p.staves[2].pos[0].pitched = False
p.staves[2].pos[0].timbre['hard noise'] += [('', '', '\\stopped', '', 12)]
p.staves[2].pos[0].timbre['soft noise'] += [('', '', '\\open', '', 12)]
p.staves[2].pos[0].timbre['hard sound-noise'] += [('', '', '\\stopped', '', 12)]
p.staves[2].pos[0].timbre['soft sound-noise'] += [('', '', '\\open', '', 12)]
p.staves[2].pos[0].quality['accent reverb'] += [lv]
p.staves[2].pos.append(Percussion('templeblocks', 0))
p.staves[2].pos[1].range = templeblocks
p.staves[2].pos[1].stretch = (1, 1)
p.staves[2].pos[1].pitched = False
p.staves[2].pos.append(Percussion('logdrum', 0))
p.staves[2].pos[2].range = logdrum
p.staves[2].pos[2].stretch = (1, 1)
p.staves[2].pos[2].pitched = False
p.staves[2].pos[2].timbre['hard noise'] += [deadstick]
p.staves[0].neg.append(Percussion('vibraphone', 1))
p.staves[0].neg[0].range = (('f', 0), ('f', 3))
p.staves[0].neg[0].stretch = (2, 8)
p.staves[0].neg[0].timbre['hard sound'] += []
p.staves[0].neg[0].timbre['soft sound'] += [arco, slur]
p.staves[0].neg[0].timbre['hard noise'] += [deadstick]
p.staves[0].neg[0].timbre['soft noise'] += [arco, slur]
p.staves[0].neg[0].timbre['hard sound-noise'] += []
p.staves[0].neg[0].timbre['soft sound-noise'] += [arco, slur]
p.staves[0].neg[0].quality['accent reverb'] += [lv]
p.staves[1].neg.append(Speaker())
p.staves[2].neg.append(Percussion('crotales', 0))
p.staves[2].neg[0].range = (('c', 4), ('c', 5))
p.staves[2].neg[0].stretch = (1, 1)
p.staves[2].neg[0].timbre['soft sound'] += [arco]
p.staves[2].neg[0].timbre['soft noise'] += [arco]
p.staves[2].neg[0].timbre['soft sound-noise'] += [arco]
p.staves[2].neg[0].quality['accent reverb'] += [lv]
p = instrumentation.players[3]
p.name = 'guitar'
p.staves.append(Staff('guitar', 1.3, \
('\\toeguitar', '^\\markup { to E-Guitar }'), \
('\\tomand', '^\\markup { to Mandolin }')))
p.staves[0].pos.append(Guitar('eguitar'))
p.staves[0].pos[0].range = (('e', -1), ('c', 4))
p.staves[0].pos[0].stretch = (3, 12)
p.staves[0].pos[0].tone = True
p.staves[0].neg.append(Guitar('mandolin'))
p.staves[0].neg[0].range = (('g', 0), ('e', 3))
p.staves[0].neg[0].stretch = (2, 8)
p.staves[0].neg.append(Speaker())
p = instrumentation.players[4]
p.name = 'piano'
p.staves.append(Staff('kbtreble', 1.7, \
('\\topianotreble', '^\\markup { to Piano }'), \
('\\tocelestetreble', '^\\markup { to Celeste }')))
p.staves[0].pos.append(Piano('pianorh', 0))
p.staves[0].pos[0].range = (('a', 0), ('c', 5))
p.staves[0].pos[0].clefs = [('bass', 0, 47), ('treble', 33, 88)]
p.staves[0].pos[0].stretch = (3, 12)
p.staves[0].neg.append(Celeste('celesterh', 0))
p.staves[0].neg[0].range = (('c', 1), ('c', 5))
p.staves[0].neg[0].clefs = [('F^8', 0, 59), ('G^8', 45, 88)]
p.staves[0].neg[0].stretch = (3, 12)
p.staves[0].neg.append(Speaker())
p.staves.append(Staff('kbbass', 1.3, \
('\\topianobass', ''), ('\\tocelestebass', '')))
p.staves[1].pos.append(Piano('pianolh', 1))
p.staves[1].pos[0].range = (('a', -3), ('c', 2))
p.staves[1].pos[0].clefs = [('bass', 0, 47), ('treble', 33, 88)]
p.staves[1].pos[0].stretch = (3, 12)
p.staves[1].pos[0].quality['accent reverb'] += [pedal]
p.staves[1].neg.append(Celeste('celestelh', 1))
p.staves[1].neg[0].range = (('c', 0), ('c', 4))
p.staves[1].neg[0].clefs = [('F^8', 0, 59), ('G^8', 45, 88)]
p.staves[1].neg[0].stretch = (3, 12)
p.staves[1].neg[0].quality['accent reverb'] += [pedal]
p = instrumentation.players[5]
p.name = 'cello'
p.staves.append(Staff('cello', 1.4, ('', ''), ('', '')))
p.staves[0].pos.append(Cello('cello', 0))
p.staves[0].pos[0].range = (('c', -1), ('c', 3))
p.staves[0].pos[0].clefs = [('bass', 16, 47), ('tenor', 30, 52), ('treble', 44, 64)]
p.staves[0].pos[0].stretch = (2, 16)
p.staves[0].neg.append(Cello('cello', 0))
p.staves[0].neg[0].range = (('a', 0), ('c', 3))
p.staves[0].neg[0].stretch = (2, 8)
p = instrumentation.players[6]
p.name = 'electronics'
p.staves.append(Staff('electronics', 0.2, ('', ''), ('', '')))
p.staves[0].pos.append(Instrument('electronics'))
p.staves[0].pos[0].range = (('a', -3), ('c', 5))
p.staves[0].pos[0].stretch = (3, 88)
p.staves[0].neg.append(Instrument('electronics'))
p.staves[0].neg[0].range = (('c', 1), ('c', 5))
p.staves[0].neg[0].stretch = (1, 88)
p.staves[0].neg.append(Speaker())
# multiply and order timbre, quality in each instrument
for p in instrumentation.players:
for st in p.staves:
for coll in [st.pos, st.neg]:
for inst in coll:
if inst.name == 'speaker': continue
for tk in inst.timbre.keys():
tklist = []
for tt in inst.timbre[tk]:
tklist.extend([tt] * tt[4])
random.shuffle(tklist)
inst.timbre[tk] = tklist
for qk in inst.quality.keys():
qklist = []
for qq in inst.quality[qk]:
qklist.extend([qq] * qq[4])
random.shuffle(qklist)
inst.quality[qk] = qklist
# multiply stretch for per-event-type choice
if inst.stretch[0] == 1:
inst.stretch = [inst.stretch] * 7
elif inst.stretch[0] == 2:
inst.stretch = [(1, inst.stretch[1])] * 4 + [(2, inst.stretch[1])] * 3
random.shuffle(inst.stretch)
elif inst.stretch[0] == 3:
inst.stretch = [(1, inst.stretch[1])] * 3 + \
[(2, inst.stretch[1])] * 2 + [(3, inst.stretch[1])] * 2
random.shuffle(inst.stretch)
|