| 1 |
""" |
| 2 |
06-random-generators.py - Overview of some random generators of pyo. |
| 3 |
|
| 4 |
The pyo's random category contains many objects that can be used |
| 5 |
for different purposes. This category really deserves to be studied. |
| 6 |
|
| 7 |
In this tutorial, we use three random objects (Choice, Randi, RandInt) |
| 8 |
to control the pitches, the amplitude and the tone of a simple synth. |
| 9 |
|
| 10 |
We will come back to random generators when we will talk about musical |
| 11 |
algorithms. |
| 12 |
|
| 13 |
""" |
| 14 |
from pyo import * |
| 15 |
|
| 16 |
s = Server().boot() |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
mid = Choice(choice=[60, 62, 63, 65, 67, 69, 71, 72], freq=[2, 3]) |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
jit = Randi(min=0.993, max=1.007, freq=[4.3, 3.5]) |
| 26 |
|
| 27 |
|
| 28 |
fr = MToF(mid, mul=jit) |
| 29 |
|
| 30 |
|
| 31 |
fd = Randi(min=0, max=0.15, freq=0.25) |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
sp = RandInt(max=6, freq=1, add=8) |
| 38 |
|
| 39 |
amp = Sine(sp, mul=0.2, add=0.2) |
| 40 |
|
| 41 |
|
| 42 |
a = SineLoop(freq=fr, feedback=fd, mul=amp).out() |
| 43 |
|
| 44 |
s.gui(locals()) |