-
Notifications
You must be signed in to change notification settings - Fork 0
/
pa.py
45 lines (38 loc) · 1.18 KB
/
pa.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
import sys
import manager
import patter_policy as PATPOL
from musical_structures.song import *
# For interactive debugging
import code
try:
import readline
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
#code.interact(local=locals())
file = "Do-Do.xml"
pa_manager = manager.Manager(file)
#pa_manager.setup()
#print("Title: {}").format(pa_manager.pattern[])
notes = {}
melody = pa_manager.pattern.tracks[1]
# Try to build song
#song_obj = Song()
#TODO: Recognize all tracks and being able to print a single track
current_time = 0
for note in melody:
if note.type == PATPOL.NOTE_ON:
if note.velocity is 0:
print ("Note: {}, Beggining: {} End: {}".format(note.note % 12, notes[note.note], note.time))
notes.pop(note.note)
continue
notes[note.note] = current_time
elif note.type == PATPOL.NOTE_OFF:
current_time += note.time
print ("Note: {}, Beggining: {} End: {}".format(note.note % 12, notes[note.note], current_time))
notes.pop(note.note)
print (melody)
if "--interactive" in sys.argv:
code.interact(local=locals())