-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrapperTest.py
49 lines (39 loc) · 1.18 KB
/
wrapperTest.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
from midoWrapper import *
from copy import deepcopy
def generate_random_midi_test():
settings = MusicSettings()
settings.key = "G#m"
s = Midi(settings)
track = Track(settings, 0)
track.generate_random_track(4) # 4 bars
s.tracks.append(track)
retrograde_track = deepcopy(track) # MUST use deepcopy
retrograde_track.retrograde()
s.tracks.append(retrograde_track)
s.save_midi("midi/random.mid")
# Expected result:
# random.mid: A random piece with 4 bars in G sharp minor which has 2 tracks,
# one is the original track, the other is the retrograde track.
def read_midi_test():
midi = Midi.from_midi("mid/test.mid")
right_hand, left_hand = midi.tracks
print(right_hand.brief_info())
print("----------------")
print(left_hand.brief_info())
# For more information, use print(track) to see the detailed notes.
# print(left_hand)
# Expected output for 'test.mid':
# Key: D
# Instrument: 0
# Length: 15353
# Bar: 8
# ----------------
# Key: D
# Instrument: 0
# Length: 15347
# Bar: 8
def main():
generate_random_midi_test()
read_midi_test()
if __name__ == "__main__":
main()