| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
if (q.getDocument("live_coding.py") == -1): |
| 8 |
q.loadDocument("live_coding.py") |
| 9 |
|
| 10 |
d = q.loadDocument("live_coding.csd") |
| 11 |
q.play(d) |
| 12 |
q.setDocument(q.getDocument("live_coding.py")) |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
q.sendEvent(d, "i 1 0 1 1000 0.1") |
| 17 |
|
| 18 |
|
| 19 |
import random |
| 20 |
|
| 21 |
def randomLadder(remaining, dur, next = 0): |
| 22 |
freq = random.uniform(220, 880) |
| 23 |
amp = 0.2*(remaining/20.0) |
| 24 |
text = "i 1 %f %f %f %f\n"%(next + dur/2, dur, freq, amp) |
| 25 |
|
| 26 |
if remaining > 0: |
| 27 |
text = text + randomLadder(remaining - 1.0, dur*0.9,next + dur) |
| 28 |
return text |
| 29 |
|
| 30 |
q.sendEvent(d,randomLadder(10, 1)) |
| 31 |
q.sendEvent(d,randomLadder(15, 0.8)) |
| 32 |
q.sendEvent(d,randomLadder(40, 0.5)) |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
q.sendEvent(d,randomLadder(30, 0.9)) |
| 38 |
q.sendEvent(d,randomLadder(30, 0.899)) |
| 39 |
q.sendEvent(d,randomLadder(30, 0.898)) |
| 40 |
q.sendEvent(d,randomLadder(30, 0.897)) |
| 41 |
|
| 42 |
|
| 43 |
|