Debian Codegraph @

pyo/examples/x22-events/05-complex-sequences.py

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