-
Notifications
You must be signed in to change notification settings - Fork 53
/
01.ex-basics.py
executable file
·66 lines (55 loc) · 2.69 KB
/
01.ex-basics.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
#------------------------------------------------------------------------
# isobar: ex-basics
#
# Example of some basic functionality: Pattern transformations,
# sequences, scales, stochastic functions, scheduling and mapping.
#------------------------------------------------------------------------
from isobar import *
import logging
def main():
#------------------------------------------------------------------------
# Create a geometric series on a minor scale.
# PingPong plays the series forward then backward. PLoop loops forever.
#------------------------------------------------------------------------
arpeggio = PSeries(0, 2, 6)
arpeggio = PDegree(arpeggio, Scale.minor) + 72
arpeggio = PPingPong(arpeggio)
arpeggio = PLoop(arpeggio)
#------------------------------------------------------------------------
# Create a velocity sequence, with emphasis every 4th note,
# plus a random walk to create gradual dynamic changes.
# Amplitudes are in the MIDI velocity range (0..127).
#------------------------------------------------------------------------
amplitude = PSequence([50, 35, 25, 35]) + PBrown(0, 1, -20, 20)
#------------------------------------------------------------------------
# Create a repeating sequence with scalar transposition:
# [ 36, 38, 43, 39, 36, 38, 43, 39, ... ]
#------------------------------------------------------------------------
bassline = PSequence([0, 2, 7, 3]) + 36
#------------------------------------------------------------------------
# Repeat each note 3 times, and transpose each into a different octave
# [ 36, 48, 60, 38, 50, 62, ... ]
#------------------------------------------------------------------------
bassline = PStutter(bassline, 3) + PSequence([0, 12, 24])
#------------------------------------------------------------------------
# A Timeline schedules events at a specified tempo. By default, events
# are send to the system's default MIDI output.
#------------------------------------------------------------------------
timeline = Timeline(120)
#------------------------------------------------------------------------
# Schedule events, with properties generated by the Pattern objects.
#------------------------------------------------------------------------
timeline.schedule({
"note": arpeggio,
"duration": 0.25,
"amplitude": amplitude
})
timeline.schedule({
"note": bassline,
"duration": 1
})
timeline.run()
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s")
main()