Debian Codegraph @

pyo/examples/x05-envelopes/02-linear-ramp.py

raw symbols SCIP
1 """
2 02-linear-ramp.py - Portamento, glissando, ramping.
3
4 The SigTo object allows to create audio glissando between the
5 current value and the target value, within a user-defined time.
6 The target value can be a float or another PyoObject. A new ramp
7 is created everytime the target value changes.
8
9 Also:
10
11 The VarPort object acts similarly but works only with float and
12 can call a user-defined callback when the ramp reaches the target
13 value.
14
15 The PyoObject.set() method is another way create a ramp for any
16 given parameter that accept audio signal but is not already
17 controlled with a PyoObject.
18
19 """
20 from pyo import *
21
22 s = Server().boot()
23
24 # 2 seconds linear ramp starting at 0.0 and ending at 0.3.
25 amp = SigTo(value=0.3, time=2.0, init=0.0)
26
27 # Pick a new value four times per second.
28 pick = Choice([200, 250, 300, 350, 400], freq=4)
29
30 # Print the chosen frequency
31 pp = Print(pick, method=1, message="Frequency")
32
33 # Add a little portamento on an audio target and detune a second frequency.
34 freq = SigTo(pick, time=0.01, mul=[1, 1.005])
35 # Play with portamento time.
36 freq.ctrl([SLMap(0, 0.25, "lin", "time", 0.01, dataOnly=True)])
37
38 # Play a simple wave.
39 sig = RCOsc(freq, sharp=0.7, mul=amp).out()
40
41 s.gui(locals())