| 1 |
""" |
| 2 |
02-scrubbing.py - Navigate through a sound table. |
| 3 |
|
| 4 |
The SndTable object allows to transfer the data from a soundfile |
| 5 |
into a function table for a fast access to every sample. |
| 6 |
|
| 7 |
This example illustrates how to do scrubbing with the mouse in |
| 8 |
a sound window. The mouse position is then used to control the |
| 9 |
position and the balance of a simple stereo granulator. |
| 10 |
|
| 11 |
Give the focus to the Scrubbing window then click and move the mouse... |
| 12 |
|
| 13 |
""" |
| 14 |
|
| 15 |
from pyo import * |
| 16 |
|
| 17 |
s = Server().boot() |
| 18 |
|
| 19 |
|
| 20 |
def mouse(mpos): |
| 21 |
print("X = %.2f, Y = %.2f" % tuple(mpos)) |
| 22 |
|
| 23 |
position.value = mpos[0] |
| 24 |
|
| 25 |
l, r = 1.0 - mpos[1], mpos[1] |
| 26 |
leftRightAmp.value = [l, r] |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
snd = SndTable("../snds/ounkmaster.aif").normalize() |
| 31 |
|
| 32 |
snd.view(title="Scrubbing window", mouse_callback=mouse) |
| 33 |
|
| 34 |
|
| 35 |
leftRightAmp = SigTo([1, 1], time=0.1, init=[1, 1], mul=0.1) |
| 36 |
|
| 37 |
position = SigTo(0.5, time=0.1, init=0.5, mul=snd.getSize(), add=Noise(5)) |
| 38 |
|
| 39 |
|
| 40 |
gran = Granulator( |
| 41 |
table=snd, |
| 42 |
env=HannTable(), |
| 43 |
pitch=[0.999, 1.0011], |
| 44 |
pos=position, |
| 45 |
dur=Noise(0.002, 0.1), |
| 46 |
grains=64, |
| 47 |
basedur=0.1, |
| 48 |
mul=leftRightAmp, |
| 49 |
).out() |
| 50 |
|
| 51 |
s.gui(locals()) |