| 1 |
""" |
| 2 |
Receiving Open Sound Control messages as audio streams |
| 3 |
|
| 4 |
**02-receive-streams.py** |
| 5 |
|
| 6 |
This script shows a granulation process controlled by OSC messages |
| 7 |
coming from another program (run the next example, *03-send-streams.py*, |
| 8 |
to get values coming in). |
| 9 |
|
| 10 |
""" |
| 11 |
from pyo import * |
| 12 |
|
| 13 |
s = Server().boot() |
| 14 |
|
| 15 |
|
| 16 |
table = SndTable("../snds/flute.aif") |
| 17 |
|
| 18 |
|
| 19 |
rec = OscReceive(port=9000, address=["/density", "/position", "/pitch_rand", "/duration"]) |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
rec.setValue("/density", 0.5) |
| 24 |
rec.setValue("/position", 0.5) |
| 25 |
rec.setValue("/pitch_rand", 0.0) |
| 26 |
rec.setValue("/duration", 0.5) |
| 27 |
|
| 28 |
|
| 29 |
dens = SigTo(rec["/density"], time=0.05, mul=249, add=1) |
| 30 |
|
| 31 |
|
| 32 |
pos = SigTo(rec["/position"], time=0.05, mul=table.getSize(), add=Noise(100)) |
| 33 |
|
| 34 |
|
| 35 |
rpit = SigTo(rec["/pitch_rand"], time=0.05, mul=0.2, add=0.001) |
| 36 |
pit = Noise(mul=rpit, add=1) |
| 37 |
|
| 38 |
|
| 39 |
dur = SigTo(rec["/duration"], time=0.05, mul=0.475, add=0.025) |
| 40 |
|
| 41 |
grain = Particle( |
| 42 |
table=table, |
| 43 |
env=HannTable(), |
| 44 |
dens=dens, |
| 45 |
pitch=pit, |
| 46 |
pos=pos, |
| 47 |
dur=dur, |
| 48 |
dev=0.01, |
| 49 |
pan=Noise(0.5, 0.5), |
| 50 |
chnls=2, |
| 51 |
mul=0.15, |
| 52 |
).out() |
| 53 |
|
| 54 |
s.gui(locals()) |