1; By Jacob Joachim (and Bach...)
2; Requires Python and PythonScore
3; https://github.com/jacobjoaquin/csd/tree/master/demo/pysco
4
5<CsoundSynthesizer>
6<CsInstruments>
7sr = 44100
8kr = 44100
9ksmps = 1
10nchnls = 2
110dbfs = 1.0
12
13instr 1
14    itail = 0.01
15    p3 = p3 + itail
16    idur = p3
17    iamp = p4
18    ifreq = p5
19
20    kenv linseg 0, 0.001, 1, 0.25, 0.4, 2, 0.1, 0, 0.1
21    kenvgate linseg, 1, idur - itail, 1, itail, 0, 0, 0
22    kenv = kenv * kenvgate
23
24    a1 vco2 1, ifreq * 2, 0
25    a2 vco2 1, ifreq, 2, 0.6 + birnd(0.1)
26
27    ival1 = 7000 + rnd(3000)
28    ival2 = 7000 + rnd(3000)
29    kenv2 expseg 16000 + rnd(2000), 2, ival1, 4, 2000, 0, 2000
30    kenv3 expseg 16000 + rnd(2000), 2, ival2, 4, 2000, 0, 2000
31
32    amix = a1 * 0.4 + a2 + 0.6
33    amix = amix * kenv * iamp
34
35    afilter1 moogladder amix, kenv2, 0.4 + rnd(0.1)
36    afilter2 moogladder amix, kenv3, 0.4 + rnd(0.1)
37    ;afilter1 moogvcf2 amix, kenv2, 0.5 + rnd(0.1)
38    ;afilter2 moogvcf2 amix, kenv3, 0.5 + rnd(0.1)
39
40    outs afilter1, afilter2
41
42    chnmix afilter1, "left"
43    chnmix afilter2, "right"
44endin
45
46instr 2
47    iamp = p4
48    idelay_left = p5
49    idelay_right = p6
50    iroom_size = p7
51    iHFDamp = p8
52
53    a1 chnget "left"
54    a2 chnget "right"
55
56    a1 delay a1, idelay_left
57    a2 delay a2, idelay_right
58
59    a1, a2 freeverb a2, a1, iroom_size, iHFDamp
60    outs a1 * iamp, a2 * iamp
61
62    chnclear "left"
63    chnclear "right"
64endin
65
66instr 3
67    prints "\nMeasure %d\n", p4
68endin
69
70</CsInstruments>
71<CsScore bin="python">
72"""Invention No. 1 by Johann Sebastian Bach (1685-1750) BWV 772
73
74Source:
75http://www.mutopiaproject.org/cgibin/piece-info.cgi?id=40
76
77Sheet music from www.MutopiaProject.org * Free to download, with
78the freedom to distribute, modify and perform.  Typeset using
79www.LilyPond.org by Jeff Covey. Copyright (C) 2008.  Reference:
80Mutopia-2008/06/15-40.
81
82Licensed under the Creative Commons Attribution-ShareAlike 3.0
83(Unported) License, for details see:
84http://creativecommons.org/licenses/by-sa/3.0/
85
86Ported to Csound PythonScore by Jacob Joaquin 2013.
87
88"""
89
90from csd.pysco import PythonScore
91from random import random
92
93def info():
94    print "\033[0;31m" + ('=' * 72) + "\033[1;33m"
95    print __doc__
96    print "\033[0;31m" + ('=' * 72) + "\033[0m"
97
98def pch_split(pch):
99    '''Splits a pitch-class value into an octave and pitch.'''
100
101    octave, note = "{0:.2f}".format(pch).split('.')
102    return int(octave), int(note.zfill(2))
103
104def transpose_pch(pch, halfstep):
105    '''Transposes a pitch-class value by halfsteps.'''
106
107    octave, note = pch_split(pch)
108    note += halfstep
109
110    if note < 0:
111        octave = octave - abs(int(note + 1)) / 12 - 1
112    else:
113        octave += int(note / 12.0)
114
115    note = int(note) % 12
116    return octave + note * 0.01
117
118def mordent(halfstep, instr, start, dur, pch):
119    '''Ornaments a note with a mordent.
120
121    Generates multiple score instrument events using a baroque
122    style mordent.
123
124    Args:
125        halfstep: Half steps away from root note.
126        instr: Score instrument to play
127        start: Start time.
128        dur: Duration.
129        pch: Pitch of root note in pitch-class notation.
130
131    '''
132
133    d = dur * 0.125
134    instr(start, d, pch)
135    instr(start + d, d, transpose_pch(pch, halfstep))
136    instr(start + d * 2, dur * 0.75, pch)
137
138def trill(halfstep, div, instr, start, dur, pch):
139    '''Ornaments a note with a trill.
140
141    Generates multiple score instrument events using a trill.
142
143    Args:
144        halfstep: Half steps away from root note.
145        div: Number of divisions of the written note duration.
146        instr: Score instrument to play
147        start: Start time.
148        dur: Duration.
149        pch: Pitch of root note in pitch-class notation.
150
151    '''
152
153    d = dur / float(div)
154    for i in xrange(0, div, 2):
155        with score.cue(start):
156            instr(d * i, d, transpose_pch(pch, halfstep))
157            instr(d * (i + 1), d, pch)
158
159def measure(t):
160    '''Allows PythonScore to use 4/4 time in measures.'''
161
162    beats = (t - 1) * 4.0
163    score.i(3, beats, 1, t)
164    return score.cue(beats)
165
166def varied_tempo_map(minimum, maximum):
167    '''Generates a varied tempo map.
168
169    This creates a tempo "t" score event with randomly changing tempos
170    specified by minimum and maximum.
171
172    Args:
173        minimum: Minimum tempo BPM.
174        maximum: Maximum tempo in BPM.
175
176    '''
177
178    L = ["t"]
179    counter = 0
180    while counter < 88:
181        L.append(str(counter))
182        L.append(str(minimum + random() * (maximum - minimum)))
183        counter += random() * 3.0 + 1.0
184    score.write(" ".join(L))
185
186def increment(inc=0.06):
187    '''Floating point increment generator.'''
188
189    offset = 0;
190    while True:
191        yield offset
192        offset += inc
193
194def wellpch(pch):
195    '''Well-tempered pitch-class to frequency converter.'
196
197    The source of the ratios:
198        http://www.larips.com/
199
200    '''
201
202    ratios = [5.9, 3.9, 2, 3.9, -2, 7.8, 2, 3.9, 3.9, 0, 3.9, 0]
203    octave, note = pch_split(pch)
204    pitch = 415 * 2 ** (((octave - 8) * 12 + (note - 9)) / 12.0)
205    return pitch * 2 ** (ratios[int(note)] / 1200.0)
206
207def harpsichord(start, dur, pitch):
208    '''Interface for Csound orchestra harpsichord instrument.'''
209
210    score.i(1, start, dur, 0.5, wellpch(pitch))
211
212def reverb(dur, amp, delay_left, delay_right, room_size, damp):
213    '''Interface for Csound orchesta reverb instrument.'''
214
215    score.i(2, 0, dur, amp, delay_left, delay_right, room_size, damp)
216
217info()
218score = PythonScore()
219top = harpsichord
220bottom = harpsichord
221reverb(90, 2.333, 0.0223, 0.0213, 0.4, 0.3)
222varied_tempo_map(80, 85)
223
224with measure(1):
225    top(0.25, 0.25, 8.00)
226    top(0.50, 0.25, 8.02)
227    top(0.75, 0.25, 8.04)
228    top(1.00, 0.25, 8.05)
229    top(1.25, 0.25, 8.02)
230    top(1.50, 0.25, 8.04)
231    top(1.75, 0.25, 8.00)
232    top(2.00, 0.5, 8.07)
233    top(2.50, 0.5, 9.00)
234    mordent(-2, top, 3.00, 0.5, 8.11)
235    top(3.50, 0.5, 9.00)
236
237    bottom(2.25, 0.25, 7.00)
238    bottom(2.50, 0.25, 7.02)
239    bottom(2.75, 0.25, 7.04)
240    bottom(3.00, 0.25, 7.05)
241    bottom(3.25, 0.25, 7.02)
242    bottom(3.50, 0.25, 7.04)
243    bottom(3.75, 0.25, 7.00)
244
245with measure(2):
246    top(0.00, 0.25, 9.02)
247    top(0.25, 0.25, 8.07)
248    top(0.50, 0.25, 8.09)
249    top(0.75, 0.25, 8.11)
250    top(1.00, 0.25, 9.00)
251    top(1.25, 0.25, 8.09)
252    top(1.50, 0.25, 8.11)
253    top(1.75, 0.25, 8.07)
254    top(2.00, 0.5, 9.02)
255    top(2.50, 0.5, 9.07)
256    mordent(-1, top, 3.00, 0.5, 9.05)
257    top(3.50, 0.5, 9.07)
258
259    bottom(0.00, 0.5, 7.07)
260    bottom(0.50, 0.5, 6.07)
261    bottom(2.25, 0.25, 7.07)
262    bottom(2.50, 0.25, 7.09)
263    bottom(2.75, 0.25, 7.11)
264    bottom(3.00, 0.25, 8.00)
265    bottom(3.25, 0.25, 7.09)
266    bottom(3.50, 0.25, 7.11)
267    bottom(3.75, 0.25, 7.07)
268
269with measure(3):
270    top(0.00, 0.25, 9.04)
271    top(0.25, 0.25, 9.09)
272    top(0.50, 0.25, 9.07)
273    top(0.75, 0.25, 9.05)
274    top(1.00, 0.25, 9.04)
275    top(1.25, 0.25, 9.07)
276    top(1.50, 0.25, 9.05)
277    top(1.75, 0.25, 9.09)
278    top(2.00, 0.25, 9.07)
279    top(2.25, 0.25, 9.05)
280    top(2.50, 0.25, 9.04)
281    top(2.75, 0.25, 9.02)
282    top(3.00, 0.25, 9.00)
283    top(3.25, 0.25, 9.04)
284    top(3.50, 0.25, 9.02)
285    top(3.75, 0.25, 9.05)
286
287    bottom(0.00, 0.5, 8.00)
288    bottom(0.50, 0.5, 7.11)
289    bottom(1.00, 0.5, 8.00)
290    bottom(1.50, 0.5, 8.02)
291    bottom(2.00, 0.5, 8.04)
292    bottom(2.50, 0.5, 7.07)
293    bottom(3.00, 0.5, 7.09)
294    bottom(3.50, 0.5, 7.11)
295
296with measure(4):
297    top(0.00, 0.25, 9.04)
298    top(0.25, 0.25, 9.02)
299    top(0.50, 0.25, 9.00)
300    top(0.75, 0.25, 8.11)
301    top(1.00, 0.25, 8.09)
302    top(1.25, 0.25, 9.00)
303    top(1.50, 0.25, 8.11)
304    top(1.75, 0.25, 9.02)
305    top(2.00, 0.25, 9.00)
306    top(2.25, 0.25, 8.11)
307    top(2.50, 0.25, 8.09)
308    top(2.75, 0.25, 8.07)
309    top(3.00, 0.25, 8.06)
310    top(3.25, 0.25, 8.09)
311    top(3.50, 0.25, 8.07)
312    top(3.75, 0.25, 8.11)
313
314    bottom(0.00, 0.5, 8.00)
315    bottom(0.50, 0.5, 7.04)
316    bottom(1.00, 0.5, 7.06)
317    bottom(1.50, 0.5, 7.07)
318    bottom(2.00, 0.5, 7.09)
319    bottom(2.50, 0.5, 7.11)
320    bottom(3.00, 1.25, 8.00)
321
322with measure(5):
323    top(0.00, 0.5, 8.09)
324    top(0.50, 0.5, 8.02)
325    trill(2, 10, top, 1.00, 0.75, 9.00)
326    top(1.75, 0.25, 9.02)
327    top(2.00, 0.25, 8.11)
328    top(2.25, 0.25, 8.09)
329    top(2.50, 0.25, 8.07)
330    top(2.75, 0.25, 8.06)
331    top(3.00, 0.25, 8.04)
332    top(3.25, 0.25, 8.07)
333    top(3.50, 0.25, 8.06)
334    top(3.75, 0.25, 8.09)
335
336    bottom(0.25, 0.25, 7.02)
337    bottom(0.50, 0.25, 7.04)
338    bottom(0.75, 0.25, 7.06)
339    bottom(1.00, 0.25, 7.07)
340    bottom(1.25, 0.25, 7.04)
341    bottom(1.50, 0.25, 7.06)
342    bottom(1.75, 0.25, 7.02)
343    bottom(2.00, 0.5, 7.07)
344    bottom(2.50, 0.5, 6.11)
345    bottom(3.00, 0.5, 7.00)
346    bottom(3.50, 0.5, 7.02)
347
348with measure(6):
349    top(0.00, 0.25, 8.07)
350    top(0.25, 0.25, 8.11)
351    top(0.50, 0.25, 8.09)
352    top(0.75, 0.25, 9.00)
353    top(1.00, 0.25, 8.11)
354    top(1.25, 0.25, 9.02)
355    top(1.50, 0.25, 9.00)
356    top(1.75, 0.25, 9.04)
357    top(2.00, 0.25, 9.02)
358    top(2.25, 0.125, 8.11)
359    top(2.375, 0.125, 9.00)
360    top(2.50, 0.25, 9.02)
361    top(2.75, 0.25, 9.07)
362    mordent(-2, top, 3.00, 0.5, 8.11)
363    top(3.50, 0.25, 8.09)
364    top(3.75, 0.25, 8.07)
365
366    bottom(0.00, 0.5, 7.04)
367    bottom(0.50, 0.5, 7.06)
368    bottom(1.00, 0.5, 7.07)
369    bottom(1.50, 0.5, 7.04)
370    bottom(2.00, 0.75, 6.11)
371    bottom(2.75, 0.25, 7.00)
372    bottom(3.00, 0.5, 7.02)
373    bottom(3.50, 0.5, 6.02)
374
375with measure(7):
376    top(0.00, 0.5, 8.07)
377    top(2.25, 0.25, 8.07)
378    top(2.50, 0.25, 8.09)
379    top(2.75, 0.25, 8.11)
380    top(3.00, 0.25, 9.00)
381    top(3.25, 0.25, 8.09)
382    top(3.50, 0.25, 8.11)
383    top(3.75, 0.25, 8.07)
384
385    bottom(0.25, 0.25, 6.07)
386    bottom(0.50, 0.25, 6.09)
387    bottom(0.75, 0.25, 6.11)
388    bottom(1.00, 0.25, 7.00)
389    bottom(1.25, 0.25, 6.09)
390    bottom(1.50, 0.25, 6.11)
391    bottom(1.75, 0.25, 6.07)
392    bottom(2.00, 0.5, 7.02)
393    bottom(2.50, 0.5, 7.07)
394    bottom(3.00, 0.5, 7.06)
395    bottom(3.50, 0.5, 7.07)
396
397with measure(8):
398    mordent(-2, top, 0.00, 0.5, 8.06)
399    top(2.25, 0.25, 8.09)
400    top(2.50, 0.25, 8.11)
401    top(2.75, 0.25, 9.00)
402    top(3.00, 0.25, 9.02)
403    top(3.25, 0.25, 8.11)
404    top(3.50, 0.25, 9.00)
405    top(3.75, 0.25, 8.09)
406
407    bottom(0.00, 0.25, 7.09)
408    bottom(0.25, 0.25, 7.02)
409    bottom(0.50, 0.25, 7.04)
410    bottom(0.75, 0.25, 7.06)
411    bottom(1.00, 0.25, 7.07)
412    bottom(1.25, 0.25, 7.04)
413    bottom(1.50, 0.25, 7.06)
414    bottom(1.75, 0.25, 7.02)
415    bottom(2.00, 0.5, 7.09)
416    bottom(2.50, 0.5, 8.02)
417    bottom(3.00, 0.5, 8.00)
418    bottom(3.50, 0.5, 8.02)
419
420with measure(9):
421    top(0.00, 0.5, 8.11)
422    top(2.25, 0.25, 9.02)
423    top(2.50, 0.25, 9.00)
424    top(2.75, 0.25, 8.11)
425    top(3.00, 0.25, 8.09)
426    top(3.25, 0.25, 9.00)
427    top(3.50, 0.25, 8.11)
428    top(3.75, 0.25, 9.02)
429
430    bottom(0.00, 0.25, 7.07)
431    bottom(0.25, 0.25, 8.07)
432    bottom(0.50, 0.25, 8.05)
433    bottom(0.75, 0.25, 8.04)
434    bottom(1.00, 0.25, 8.02)
435    bottom(1.25, 0.25, 8.05)
436    bottom(1.50, 0.25, 8.04)
437    bottom(1.75, 0.25, 8.07)
438    bottom(2.00, 0.5, 8.05)
439    bottom(2.50, 0.5, 8.04)
440    bottom(3.00, 0.5, 8.05)
441    bottom(3.50, 0.5, 8.02)
442
443with measure(10):
444    top(0.00, 0.5, 9.00)
445    top(2.25, 0.25, 9.04)
446    top(2.50, 0.25, 9.02)
447    top(2.75, 0.25, 9.00)
448    top(3.00, 0.25, 8.11)
449    top(3.25, 0.25, 9.02)
450    top(3.50, 0.25, 9.01)
451    top(3.75, 0.25, 9.04)
452
453    bottom(0.00, 0.25, 8.04)
454    bottom(0.25, 0.25, 8.09)
455    bottom(0.50, 0.25, 8.07)
456    bottom(0.75, 0.25, 8.05)
457    bottom(1.00, 0.25, 8.04)
458    bottom(1.25, 0.25, 8.07)
459    bottom(1.50, 0.25, 8.05)
460    bottom(1.75, 0.25, 8.09)
461    bottom(2.00, 0.5, 8.07)
462    bottom(2.50, 0.5, 8.05)
463    bottom(3.00, 0.5, 8.07)
464    bottom(3.50, 0.5, 8.04)
465
466with measure(11):
467    top(0.00, 0.5, 9.02)
468    top(0.50, 0.5, 9.01)
469    top(1.00, 0.5, 9.02)
470    top(1.50, 0.5, 9.04)
471    top(2.00, 0.5, 9.05)
472    top(2.50, 0.5, 8.09)
473    top(3.00, 0.5, 8.11)
474    top(3.50, 0.5, 9.01)
475
476    bottom(0.00, 0.25, 8.05)
477    bottom(0.25, 0.25, 8.10)
478    bottom(0.50, 0.25, 8.09)
479    bottom(0.75, 0.25, 8.07)
480    bottom(1.00, 0.25, 8.05)
481    bottom(1.25, 0.25, 8.09)
482    bottom(1.50, 0.25, 8.07)
483    bottom(1.75, 0.25, 8.10)
484    bottom(2.00, 0.25, 8.09)
485    bottom(2.25, 0.25, 8.07)
486    bottom(2.50, 0.25, 8.05)
487    bottom(2.75, 0.25, 8.04)
488    bottom(3.00, 0.25, 8.02)
489    bottom(3.25, 0.25, 8.05)
490    bottom(3.50, 0.25, 8.04)
491    bottom(3.75, 0.25, 8.07)
492
493with measure(12):
494    top(0.00, 0.5, 9.02)
495    top(0.50, 0.5, 8.06)
496    top(1.00, 0.5, 8.08)
497    top(1.50, 0.5, 8.09)
498    top(2.00, 0.5, 8.11)
499    top(2.50, 0.5, 9.00)
500    top(3.00, 1.25, 9.02)
501
502    bottom(0.00, 0.25, 8.05)
503    bottom(0.25, 0.25, 8.04)
504    bottom(0.50, 0.25, 8.02)
505    bottom(0.75, 0.25, 8.00)
506    bottom(1.00, 0.25, 7.11)
507    bottom(1.25, 0.25, 8.02)
508    bottom(1.50, 0.25, 8.00)
509    bottom(1.75, 0.25, 8.04)
510    bottom(2.00, 0.25, 8.02)
511    bottom(2.25, 0.25, 8.00)
512    bottom(2.50, 0.25, 7.11)
513    bottom(2.75, 0.25, 7.09)
514    bottom(3.00, 0.25, 7.08)
515    bottom(3.25, 0.25, 7.11)
516    bottom(3.50, 0.25, 7.09)
517    bottom(3.75, 0.25, 8.00)
518
519with measure(13):
520    top(0.25, 0.25, 8.04)
521    top(0.50, 0.25, 8.06)
522    top(0.75, 0.25, 8.08)
523    top(1.00, 0.25, 8.09)
524    top(1.25, 0.25, 8.06)
525    top(1.50, 0.25, 8.08)
526    top(1.75, 0.25, 8.04)
527    top(2.00, 0.25, 9.04)
528    top(2.25, 0.25, 9.02)
529    top(2.50, 0.25, 9.00)
530    top(2.75, 0.25, 9.04)
531    top(3.00, 0.25, 9.02)
532    top(3.25, 0.25, 9.00)
533    top(3.50, 0.25, 8.11)
534    top(3.75, 0.25, 9.02)
535
536    bottom(0.00, 0.5, 7.11)
537    bottom(0.50, 0.5, 7.04)
538    trill(2, 8, bottom, 1.00, 0.75, 8.02)
539    bottom(1.75, 0.25, 8.04)
540    bottom(2.00, 0.25, 8.00)
541    bottom(2.25, 0.25, 7.11)
542    bottom(2.50, 0.25, 7.09)
543    bottom(2.75, 0.25, 7.07)
544    bottom(3.00, 0.25, 7.06)
545    bottom(3.25, 0.25, 7.09)
546    bottom(3.50, 0.25, 7.08)
547    bottom(3.75, 0.25, 7.11)
548
549with measure(14):
550    top(0.00, 0.25, 9.00)
551    top(0.25, 0.25, 9.09)
552    top(0.50, 0.25, 9.08)
553    top(0.75, 0.25, 9.11)
554    top(1.00, 0.25, 9.09)
555    top(1.25, 0.25, 9.04)
556    top(1.50, 0.25, 9.05)
557    top(1.75, 0.25, 9.02)
558    top(2.00, 0.25, 8.08)
559    top(2.25, 0.25, 9.05)
560    top(2.50, 0.25, 9.04)
561    top(2.75, 0.25, 9.02)
562    top(3.00, 0.5, 9.00)
563    top(3.50, 0.25, 8.11)
564    top(3.75, 0.25, 8.09)
565
566    bottom(0.00, 0.25, 7.09)
567    bottom(0.25, 0.25, 8.00)
568    bottom(0.50, 0.25, 7.11)
569    bottom(0.75, 0.25, 8.02)
570    bottom(1.00, 0.25, 8.00)
571    bottom(1.25, 0.25, 8.04)
572    bottom(1.50, 0.25, 8.02)
573    bottom(1.75, 0.25, 8.05)
574    bottom(2.00, 0.5, 8.04)
575    bottom(2.50, 0.5, 7.09)
576    bottom(3.00, 0.5, 8.04)
577    bottom(3.50, 0.5, 7.04)
578
579with measure(15):
580    top(0.00, 0.25, 8.09)
581    top(0.25, 0.25, 9.09)
582    top(0.50, 0.25, 9.07)
583    top(0.75, 0.25, 9.05)
584    top(1.00, 0.25, 9.04)
585    top(1.25, 0.25, 9.07)
586    top(1.50, 0.25, 9.05)
587    top(1.75, 0.25, 9.09)
588    top(2.00, 2.25, 9.07)
589
590    bottom(0.00, 0.5, 7.09)
591    bottom(0.50, 0.5, 6.09)
592    bottom(2.25, 0.25, 8.04)
593    bottom(2.50, 0.25, 8.02)
594    bottom(2.75, 0.25, 8.00)
595    bottom(3.00, 0.25, 7.11)
596    bottom(3.25, 0.25, 8.02)
597    bottom(3.50, 0.25, 8.01)
598    bottom(3.75, 0.25, 8.04)
599
600with measure(16):
601    top(0.25, 0.25, 9.04)
602    top(0.50, 0.25, 9.05)
603    top(0.75, 0.25, 9.07)
604    top(1.00, 0.25, 9.09)
605    top(1.25, 0.25, 9.05)
606    top(1.50, 0.25, 9.07)
607    top(1.75, 0.25, 9.04)
608    top(2.00, 2.25, 9.05)
609
610    bottom(0.00, 2.25, 8.02)
611    bottom(2.25, 0.25, 7.09)
612    bottom(2.50, 0.25, 7.11)
613    bottom(2.75, 0.25, 8.00)
614    bottom(3.00, 0.25, 8.02)
615    bottom(3.25, 0.25, 7.11)
616    bottom(3.50, 0.25, 8.00)
617    bottom(3.75, 0.25, 7.09)
618
619with measure(17):
620    top(0.25, 0.25, 9.07)
621    top(0.50, 0.25, 9.05)
622    top(0.75, 0.25, 9.04)
623    top(1.00, 0.25, 9.02)
624    top(1.25, 0.25, 9.05)
625    top(1.50, 0.25, 9.04)
626    top(1.75, 0.25, 9.07)
627    top(2.00, 2.25, 9.05)
628
629    bottom(0.00, 2.25, 7.11)
630    bottom(2.25, 0.25, 8.02)
631    bottom(2.50, 0.25, 8.00)
632    bottom(2.75, 0.25, 7.11)
633    bottom(3.00, 0.25, 7.09)
634    bottom(3.25, 0.25, 8.00)
635    bottom(3.50, 0.25, 7.11)
636    bottom(3.75, 0.25, 8.02)
637
638with measure(18):
639    top(0.25, 0.25, 9.02)
640    top(0.50, 0.25, 9.04)
641    top(0.75, 0.25, 9.05)
642    top(1.00, 0.25, 9.07)
643    top(1.25, 0.25, 9.04)
644    top(1.50, 0.25, 9.05)
645    top(1.75, 0.25, 9.02)
646    top(2.00, 2.25, 9.04)
647
648    bottom(0.00, 2.25, 8.00)
649    bottom(2.25, 0.25, 7.07)
650    bottom(2.50, 0.25, 7.09)
651    bottom(2.75, 0.25, 7.10)
652    bottom(3.00, 0.25, 8.00)
653    bottom(3.25, 0.25, 7.09)
654    bottom(3.50, 0.25, 7.10)
655    bottom(3.75, 0.25, 7.07)
656
657with measure(19):
658    top(0.25, 0.25, 9.00)
659    top(0.50, 0.25, 9.02)
660    top(0.75, 0.25, 9.04)
661    top(1.00, 0.25, 9.05)
662    top(1.25, 0.25, 9.02)
663    top(1.50, 0.25, 9.04)
664    top(1.75, 0.25, 9.00)
665    top(2.00, 0.25, 9.02)
666    top(2.25, 0.25, 9.04)
667    top(2.50, 0.25, 9.05)
668    top(2.75, 0.25, 9.07)
669    top(3.00, 0.25, 9.09)
670    top(3.25, 0.25, 9.05)
671    top(3.50, 0.25, 9.07)
672    top(3.75, 0.25, 9.04)
673
674    bottom(0.00, 0.5, 7.09)
675    bottom(0.50, 0.5, 7.10)
676    bottom(1.00, 0.5, 7.09)
677    bottom(1.50, 0.5, 7.07)
678    bottom(2.00, 0.5, 7.05)
679    bottom(2.50, 0.5, 8.02)
680    bottom(3.00, 0.5, 8.00)
681    bottom(3.50, 0.5, 7.10)
682
683with measure(20):
684    top(0.00, 0.25, 9.05)
685    top(0.25, 0.25, 9.07)
686    top(0.50, 0.25, 9.09)
687    top(0.75, 0.25, 9.11)
688    top(1.00, 0.25, 10.00)
689    top(1.25, 0.25, 9.09)
690    top(1.50, 0.25, 9.11)
691    top(1.75, 0.25, 9.07)
692    top(2.00, 0.5, 10.00)
693    top(2.50, 0.5, 9.07)
694    top(3.00, 0.5, 9.04)
695    top(3.50, 0.25, 9.02)
696    top(3.75, 0.25, 9.00)
697
698    bottom(0.00, 0.5, 7.09)
699    bottom(0.50, 0.5, 8.05)
700    bottom(1.00, 0.5, 8.04)
701    bottom(1.50, 0.5, 8.02)
702    bottom(2.00, 0.25, 8.04)
703    bottom(2.25, 0.25, 8.02)
704    bottom(2.50, 0.25, 8.04)
705    bottom(2.75, 0.25, 8.05)
706    bottom(3.00, 0.25, 8.07)
707    bottom(3.25, 0.25, 8.04)
708    bottom(3.50, 0.25, 8.05)
709    bottom(3.75, 0.25, 8.02)
710
711with measure(21):
712    top(0.00, 0.25, 9.00)
713    top(0.25, 0.25, 8.10)
714    top(0.50, 0.25, 8.09)
715    top(0.75, 0.25, 8.07)
716    top(1.00, 0.25, 8.05)
717    top(1.25, 0.25, 8.09)
718    top(1.50, 0.25, 8.07)
719    top(1.75, 0.25, 8.10)
720    top(2.00, 0.25, 8.09)
721    top(2.25, 0.25, 8.11)
722    top(2.50, 0.25, 9.00)
723    top(2.75, 0.25, 8.04)
724    top(3.00, 0.25, 8.02)
725    top(3.25, 0.25, 9.00)
726    top(3.50, 0.25, 8.05)
727    top(3.75, 0.25, 8.11)
728
729    bottom(0.00, 0.5, 7.04)
730    bottom(0.50, 0.5, 7.00)
731    bottom(1.00, 0.5, 7.02)
732    bottom(1.50, 0.5, 7.04)
733    bottom(2.00, 0.25, 7.05)
734    bottom(2.25, 0.25, 7.02)
735    bottom(2.50, 0.25, 7.04)
736    bottom(2.75, 0.25, 7.05)
737    bottom(3.00, 0.5, 7.07)
738    bottom(3.50, 0.5, 6.07)
739
740with measure(22):
741    arp = increment()
742    score.p_callback('i', 1, 2, lambda x: arp.next())
743    bottom(0, 0.5, 6.00)
744    bottom(0, 0.5, 7.00)
745    top(0, 0.5, 8.04)
746    top(0, 0.5, 8.07)
747    top(0, 0.5, 9.00)
748
749score.pmap('i', 1, 2, lambda x: x + random() * 0.05)  # Randomize start time
750score.pmap('i', 1, 3, lambda x: x + random() * 0.05)  # Randomize duration
751score.pmap('i', 1, 4, lambda x: x * 0.4)              # Lower amplitude
752score.end()
753
754</CsScore>
755</CsoundSynthesizer>
756<bsbPanel>
757 <label>Widgets</label>
758 <objectName/>
759 <x>669</x>
760 <y>214</y>
761 <width>320</width>
762 <height>240</height>
763 <visible>true</visible>
764 <uuid/>
765 <bgcolor mode="nobackground">
766  <r>255</r>
767  <g>255</g>
768  <b>255</b>
769 </bgcolor>
770</bsbPanel>
771<bsbPresets>
772</bsbPresets>
773