Debian Codegraph @

docs/_sources/examples/22-events/13-using-audio-objects.rst.txt

raw
1 13-using-audio-objects.py - Using audio objects as generators.
2 ============================================================================================================================================
3
4
5 Because Events computes its events in real time, it is possible to use
6 the current value of audio streams as generators for parameter (even
7 as generators for EventGenerator's arguments). So, wherever a float or
8 an EventGenerator is possible, a PyoObject is too.
9
10 Considering the wide range of audio signal possibilities pyo is offering,
11 it is worthy to explore these combinations!
12
13 .. code-block:: python
14
15 from pyo import *
16
17 s = Server().boot()
18
19 # Attack - decay envelope.
20 env = CosTable([(0, 0.0), (64, 1.0), (8191, 0.0)])
21
22 # The pool of notes.
23 scl = EventScale(root="C", scale="egyptian", first=4, octaves=3)
24
25 # LFO on the duration multiplier.
26 durmul1 = Sine(freq=0.1).range(0.5, 1.5)
27 # Random on the length of each segment.
28 segment1 = RandInt(max=6, freq=0.5)
29 # Random on the distance between segments starting points.
30 step1 = RandInt(max=6, freq=0.75, add=-3)
31
32 e1 = Events(
33 midinote=EventSlide(scl, segment1, step1), beat=1 / 4.0, db=[-12, -18, -18], envelope=env, durmul=durmul1,
34 ).play()
35
36 # Out-of-phase LFO on the duration multiplier.
37 durmul2 = Sine(freq=0.1, phase=0.5).range(0.5, 1.5)
38 segment2 = RandInt(max=6, freq=0.5)
39 step2 = RandInt(max=6, freq=0.75, add=-3)
40
41 e2 = Events(
42 midinote=EventSlide(scl, segment2, step2),
43 db=[-9, -15, -15],
44 envelope=env,
45 durmul=durmul2,
46 beat=1 / 4.0,
47 bpm=60,
48 transpo=-12,
49 ).play()
50
51 s.gui(locals())
52