Debian Codegraph @

docs/_sources/examples/22-events/05-complex-sequences.rst.txt

raw
1 05-complex-sequences.py - Exploring generators that sequence values.
2 ============================================================================================================================================
3
4
5 This example explores two more generators that sequence values.
6
7 **EventSlide** ::
8
9 EventSlide(values, segment, step, startpos=0, wraparound=True,
10 occurrences=inf, stopEventsWhenDone=True)
11
12 EventSlide plays sub-melodies of length 'segment' and then moves by 'step'
13 positions from the beginning of the last segment to start another one, and
14 so on. The argument 'step' can be negative to move backward and the 'startpos'
15 can also be negative to start from the end of the list. If 'wraparound' is True,
16 indexing wraps around if goes past beginning or end. If False, the playback
17 stops if it goes outside the list bounds.
18
19 **EventIndex** ::
20
21 EventIndex(values, index, occurrences=inf, stopEventsWhenDone=True)
22
23 EventIndex uses an 'index' parameter to read specific positions into the
24 list 'values'. This is useful, for instance, to read a scale using degree
25 values.
26
27 .. code-block:: python
28
29 from pyo import *
30
31 s = Server().boot()
32
33 scl = [5.00, 5.02, 5.03, 5.05, 5.07, 5.08, 5.10, 6.00, 6.02, 6.03, 6.05, 6.07]
34
35 # 3 notes segments, moving forward 1 index each iteration.
36 e = Events(
37 degree=EventSlide(scl, segment=3, step=1, startpos=0),
38 beat=1 / 2.0,
39 db=-6,
40 attack=0.001,
41 decay=0.05,
42 sustain=0.5,
43 release=0.005,
44 ).play()
45
46 # 4 notes segments, moving backward (from the end) 2 indexes each iteration.
47 e2 = Events(
48 degree=EventSlide(scl, segment=4, step=-2, startpos=-1),
49 beat=1,
50 db=-12,
51 transpo=12,
52 attack=0.001,
53 decay=0.05,
54 sustain=0.5,
55 release=0.005,
56 ).play()
57
58 # Arpeggio on the root chord.
59 e3 = Events(
60 degree=EventIndex(scl, EventSeq([0, 4, 2, 0, 4, 2, 0, 2, 4, 7, 4, 2])),
61 db=EventSeq([-6, -12, -12]),
62 beat=1 / 4.0,
63 transpo=-12,
64 attack=0.001,
65 decay=0.05,
66 sustain=0.5,
67 release=0.005,
68 ).play()
69
70 s.gui(locals())
71