File: 13-using-audio-objects.rst.txt

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (52 lines) | stat: -rw-r--r-- 1,726 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
13-using-audio-objects.py - Using audio objects as generators.
============================================================================================================================================


Because Events computes its events in real time, it is possible to use
the current value of audio streams as generators for parameter (even
as generators for EventGenerator's arguments). So, wherever a float or
an EventGenerator is possible, a PyoObject is too.

Considering the wide range of audio signal possibilities pyo is offering,
it is worthy to explore these combinations!

.. code-block:: python

    from pyo import *
    
    s = Server().boot()
    
    # Attack - decay envelope.
    env = CosTable([(0, 0.0), (64, 1.0), (8191, 0.0)])
    
    # The pool of notes.
    scl = EventScale(root="C", scale="egyptian", first=4, octaves=3)
    
    # LFO on the duration multiplier.
    durmul1 = Sine(freq=0.1).range(0.5, 1.5)
    # Random on the length of each segment.
    segment1 = RandInt(max=6, freq=0.5)
    # Random on the distance between segments starting points.
    step1 = RandInt(max=6, freq=0.75, add=-3)
    
    e1 = Events(
        midinote=EventSlide(scl, segment1, step1), beat=1 / 4.0, db=[-12, -18, -18], envelope=env, durmul=durmul1,
    ).play()
    
    # Out-of-phase LFO on the duration multiplier.
    durmul2 = Sine(freq=0.1, phase=0.5).range(0.5, 1.5)
    segment2 = RandInt(max=6, freq=0.5)
    step2 = RandInt(max=6, freq=0.75, add=-3)
    
    e2 = Events(
        midinote=EventSlide(scl, segment2, step2),
        db=[-9, -15, -15],
        envelope=env,
        durmul=durmul2,
        beat=1 / 4.0,
        bpm=60,
        transpo=-12,
    ).play()
    
    s.gui(locals())