Debian Codegraph @

pyo/examples/x05-envelopes/03-exponential-ramp.py

raw symbols SCIP
1 """
2 03-exponential-ramp.py - Exponential portamento with rising and falling times.
3
4 The Port object is designed to lowpass filter an audio signal with
5 different coefficients for rising and falling signals. A lowpass
6 filter is a good and efficient way of creating an exponential ramp
7 from a signal containing abrupt changes. The rising and falling
8 coefficients are controlled in seconds.
9
10 """
11 from pyo import *
12
13 s = Server().boot()
14
15 # 2 seconds linear ramp starting at 0.0 and ending at 0.3.
16 amp = SigTo(value=0.3, time=2.0, init=0.0)
17
18 # Pick a new value four times per second.
19 pick = Choice([200, 250, 300, 350, 400], freq=4)
20
21 # Print the chosen frequency
22 pp = Print(pick, method=1, message="Frequency")
23
24 # Add an exponential portamento on an audio target and detune a second frequency.
25 # Sharp attack for rising notes and long release for falling notes.
26 freq = Port(pick, risetime=0.001, falltime=0.25, mul=[1, 1.005])
27 # Play with portamento times.
28 freq.ctrl()
29
30 # Play a simple wave.
31 sig = RCOsc(freq, sharp=0.7, mul=amp).out()
32
33 s.gui(locals())