|
7 | 7 | # sequences, scales, stochastic functions, scheduling and mapping. |
8 | 8 | #------------------------------------------------------------------------ |
9 | 9 |
|
10 | | -import isobar as iso |
11 | | - |
12 | | -#------------------------------------------------------------------------ |
13 | | -# Turn on some basic logging output. |
14 | | -#------------------------------------------------------------------------ |
| 10 | +from isobar import * |
15 | 11 | import logging |
16 | | -logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s") |
17 | | - |
18 | | -#------------------------------------------------------------------------ |
19 | | -# Create a geometric series on a minor scale. |
20 | | -# PingPong plays the series forward then backward. PLoop loops forever. |
21 | | -#------------------------------------------------------------------------ |
22 | | -arpeggio = iso.PSeries(0, 2, 6) |
23 | | -arpeggio = iso.PDegree(arpeggio, iso.Scale.minor) + 72 |
24 | | -arpeggio = iso.PPingPong(arpeggio) |
25 | | -arpeggio = iso.PLoop(arpeggio) |
26 | | - |
27 | | -#------------------------------------------------------------------------ |
28 | | -# Create a velocity sequence, with emphasis every 4th note, |
29 | | -# plus a random walk to create gradual dynamic changes. |
30 | | -# Amplitudes are in the MIDI velocity range (0..127). |
31 | | -#------------------------------------------------------------------------ |
32 | | -amplitude = iso.PSequence([50, 35, 25, 35]) + iso.PBrown(0, 1, -20, 20) |
33 | | - |
34 | | -#------------------------------------------------------------------------ |
35 | | -# Create a repeating sequence with scalar transposition: |
36 | | -# [ 36, 38, 43, 39, 36, 38, 43, 39, ... ] |
37 | | -#------------------------------------------------------------------------ |
38 | | -bassline = iso.PSequence([0, 2, 7, 3]) + 36 |
39 | | - |
40 | | -#------------------------------------------------------------------------ |
41 | | -# Repeat each note 3 times, and transpose each into a different octave |
42 | | -# [ 36, 48, 60, 38, 50, 62, ... ] |
43 | | -#------------------------------------------------------------------------ |
44 | | -bassline = iso.PStutter(bassline, 3) + iso.PSequence([0, 12, 24]) |
45 | 12 |
|
46 | | -#------------------------------------------------------------------------ |
47 | | -# A Timeline schedules events at a specified tempo. By default, events |
48 | | -# are send to the system's default MIDI output. |
49 | | -#------------------------------------------------------------------------ |
50 | | -output = iso.MidiOutputDevice() |
51 | | - |
52 | | -timeline = iso.Timeline(120, output) |
| 13 | +def main(): |
| 14 | + #------------------------------------------------------------------------ |
| 15 | + # Create a geometric series on a minor scale. |
| 16 | + # PingPong plays the series forward then backward. PLoop loops forever. |
| 17 | + #------------------------------------------------------------------------ |
| 18 | + arpeggio = PSeries(0, 2, 6) |
| 19 | + arpeggio = PDegree(arpeggio, Scale.minor) + 72 |
| 20 | + arpeggio = PPingPong(arpeggio) |
| 21 | + arpeggio = PLoop(arpeggio) |
| 22 | + |
| 23 | + #------------------------------------------------------------------------ |
| 24 | + # Create a velocity sequence, with emphasis every 4th note, |
| 25 | + # plus a random walk to create gradual dynamic changes. |
| 26 | + # Amplitudes are in the MIDI velocity range (0..127). |
| 27 | + #------------------------------------------------------------------------ |
| 28 | + amplitude = PSequence([50, 35, 25, 35]) + PBrown(0, 1, -20, 20) |
| 29 | + |
| 30 | + #------------------------------------------------------------------------ |
| 31 | + # Create a repeating sequence with scalar transposition: |
| 32 | + # [ 36, 38, 43, 39, 36, 38, 43, 39, ... ] |
| 33 | + #------------------------------------------------------------------------ |
| 34 | + bassline = PSequence([0, 2, 7, 3]) + 36 |
| 35 | + |
| 36 | + #------------------------------------------------------------------------ |
| 37 | + # Repeat each note 3 times, and transpose each into a different octave |
| 38 | + # [ 36, 48, 60, 38, 50, 62, ... ] |
| 39 | + #------------------------------------------------------------------------ |
| 40 | + bassline = PStutter(bassline, 3) + PSequence([0, 12, 24]) |
| 41 | + |
| 42 | + #------------------------------------------------------------------------ |
| 43 | + # A Timeline schedules events at a specified tempo. By default, events |
| 44 | + # are send to the system's default MIDI output. |
| 45 | + #------------------------------------------------------------------------ |
| 46 | + timeline = Timeline(120) |
| 47 | + |
| 48 | + #------------------------------------------------------------------------ |
| 49 | + # Schedule events, with properties generated by the Pattern objects. |
| 50 | + #------------------------------------------------------------------------ |
| 51 | + timeline.schedule({ |
| 52 | + "note": arpeggio, |
| 53 | + "duration": 0.25, |
| 54 | + "amplitude": amplitude |
| 55 | + }) |
| 56 | + timeline.schedule({ |
| 57 | + "note": bassline, |
| 58 | + "duration": 1 |
| 59 | + }) |
| 60 | + |
| 61 | + timeline.run() |
53 | 62 |
|
54 | | -#------------------------------------------------------------------------ |
55 | | -# Schedule events, with properties generated by the Pattern objects. |
56 | | -#------------------------------------------------------------------------ |
57 | | -timeline.schedule({ |
58 | | - "note": arpeggio, |
59 | | - "duration": 0.25, |
60 | | - "amplitude": amplitude |
61 | | -}) |
62 | | -timeline.schedule({ |
63 | | - "note": bassline, |
64 | | - "duration": 1 |
65 | | -}) |
66 | 63 |
|
67 | | -timeline.run() |
| 64 | +if __name__ == "__main__": |
| 65 | + logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s") |
| 66 | + main() |
0 commit comments