| 1 |
""" |
| 2 |
04-granulation.py - Full control granular synthesis. |
| 3 |
|
| 4 |
The output of a Granular Synthesis is composed of many individual |
| 5 |
grains of sound. A grain is a short chunk of sound, typically between |
| 6 |
10 and 100 ms (but can also vary outside this range), with an amplitude |
| 7 |
envelope in the shape of a bell curve. The sonic quality of a granular |
| 8 |
texture is a result of the distribution of grains in time and of the |
| 9 |
parameters selected for the synthesis of each grain. |
| 10 |
|
| 11 |
This example shows the usage of the most featured granulation object |
| 12 |
of the library! |
| 13 |
|
| 14 |
Available granulation objects, in order of complexity, are: |
| 15 |
|
| 16 |
- Granulator |
| 17 |
- Granule |
| 18 |
- Particle |
| 19 |
- Particle2 |
| 20 |
|
| 21 |
""" |
| 22 |
from pyo import * |
| 23 |
|
| 24 |
s = Server().boot() |
| 25 |
|
| 26 |
snd = SndTable("../snds/baseballmajeur_m.aif") |
| 27 |
snd.view() |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
end = snd.getSize() - s.getSamplingRate() * 0.25 |
| 32 |
|
| 33 |
|
| 34 |
env = WinTable(7) |
| 35 |
env.view(title="Grain envelope") |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
pit = Noise(0, add=1) |
| 40 |
pit.ctrl([SLMap(0, 1, "lin", "mul", 0)], title="Pitch Randomness") |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
pososc = Sine(0.05).range(0, end) |
| 46 |
posrnd = Noise(mul=0.01, add=1) |
| 47 |
pos = pososc * posrnd |
| 48 |
|
| 49 |
|
| 50 |
pan = Noise(mul=0.5, add=0.5) |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
cf = Sine(freq=0.07).range(75, 125) |
| 55 |
fcf = Choice(list(range(1, 40)), freq=150, mul=cf) |
| 56 |
|
| 57 |
grn = Particle2( |
| 58 |
table=snd, |
| 59 |
env=env, |
| 60 |
dens=128, |
| 61 |
|
| 62 |
|
| 63 |
pitch=pit, |
| 64 |
pos=pos, |
| 65 |
dur=0.2, |
| 66 |
dev=0.005, |
| 67 |
|
| 68 |
pan=pan, |
| 69 |
filterfreq=fcf, |
| 70 |
filterq=20, |
| 71 |
filtertype=2, |
| 72 |
|
| 73 |
chnls=2, |
| 74 |
mul=0.2, |
| 75 |
) |
| 76 |
grn.ctrl() |
| 77 |
|
| 78 |
|
| 79 |
comp = Compress(grn, thresh=-20, ratio=4, risetime=0.005, falltime=0.10, knee=0.5, mul=2).out() |
| 80 |
|
| 81 |
s.gui(locals()) |