File: 04_granule.py

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (26 lines) | stat: -rw-r--r-- 624 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Hand-written granulation module.

"""
from pyo import *

s = Server(duplex=0).boot()

t1 = SndTable("../snds/baseballmajeur_m.aif")
t2 = WinTable(7)
t3 = LinTable()

snd_dur = t1.getDur()
num_of_grains = 50
grain_dur = 0.25
jitter_amp = 0.2

met = Metro(time=grain_dur / num_of_grains, poly=num_of_grains).play()
mvt = Randi(freq=0.25)
pos = TrigRand(met, min=mvt, max=mvt + 0.05)
jit = TrigRand(met, min=1 - jitter_amp, max=1 + jitter_amp)
env = TrigEnv(met, t2, dur=grain_dur, mul=0.05)
ind = TrigEnv(met, t3, dur=grain_dur, mul=jit * (grain_dur / snd_dur), add=pos)
snd = Pointer(t1, ind, env).out()

s.gui(locals())