| 1 |
""" |
| 2 |
04-ping-pong-delay.py - Stereo ping-pong delay. |
| 3 |
|
| 4 |
A stereo ping-pong delay is when you use two delays, one hard left and the |
| 5 |
other hard right, and the delays alternate. |
| 6 |
|
| 7 |
This exemple illustrates how we can pass the signal of a first object to |
| 8 |
the input of a second even if the first object does not exist yet when the |
| 9 |
second is created. |
| 10 |
|
| 11 |
""" |
| 12 |
from pyo import * |
| 13 |
import random |
| 14 |
|
| 15 |
s = Server(duplex=0).boot() |
| 16 |
|
| 17 |
|
| 18 |
buftime = s.getBufferSize() / s.getSamplingRate() |
| 19 |
|
| 20 |
|
| 21 |
delay_time_l = Sig(0.125) |
| 22 |
delay_time_l.ctrl() |
| 23 |
delay_feed = Sig(0.75) |
| 24 |
delay_feed.ctrl() |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
delay_time_r = Sig(delay_time_l, add=-buftime) |
| 31 |
|
| 32 |
|
| 33 |
sf = SfPlayer("../snds/alum1.wav").stop() |
| 34 |
|
| 35 |
|
| 36 |
sfout = sf.mix(2).out() |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
right = Delay(Sig(0), delay=delay_time_r).out(1) |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
left = Delay(sf + right * delay_feed, delay=delay_time_l).out() |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
original_delayed = Delay(sf, delay_time_l, mul=1 - delay_feed) |
| 51 |
|
| 52 |
|
| 53 |
right.setInput(original_delayed + left * delay_feed) |
| 54 |
|
| 55 |
|
| 56 |
def playit(): |
| 57 |
"Assign a sound to the player and start playback." |
| 58 |
which = random.randint(1, 4) |
| 59 |
path = "../snds/alum%d.wav" % which |
| 60 |
sf.path = path |
| 61 |
sf.play() |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
pat = Pattern(playit, 1).play() |
| 66 |
|
| 67 |
s.gui(locals()) |