-
Notifications
You must be signed in to change notification settings - Fork 53
/
05.ex-piano-phase.py
executable file
·47 lines (40 loc) · 1.82 KB
/
05.ex-piano-phase.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
#!/usr/bin/env python3
#------------------------------------------------------------------------
# isobar: ex-piano-phase
#
# Implementation of Steve Reich's "Piano Phase" (1967):
# Two identical piano lines, one with a slightly longer duration,
# moving in and out of phase with one another.
#------------------------------------------------------------------------
from isobar import *
import logging
def main():
#------------------------------------------------------------------------
# Melody line
#------------------------------------------------------------------------
sequence = PSequence([-7, -5, 0, 2, 3, -5, -7, 2, 0, -5, 3, 2])
#------------------------------------------------------------------------
# Create a timeline at 160BPM
#------------------------------------------------------------------------
timeline = Timeline(160)
#------------------------------------------------------------------------
# Schedule two identical melodies.
# We must copy the note sequence or else the position will be stepped
# by two every note... try removing the .copy() and see what happens!
#------------------------------------------------------------------------
timeline.schedule({
"note": sequence.copy() + 60,
"duration": 0.5
})
timeline.schedule({
"note": sequence.copy() + 72,
"duration": 0.5 * 1.01
})
#------------------------------------------------------------------------
# Start playing via default MIDI out, and block forever.
# Alternatively, use timeline.background() to retain foreground control.
#------------------------------------------------------------------------
timeline.run()
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s")
main()