forked from BryanDavis999/Ambient-Music-Gen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge_high_low.py
More file actions
executable file
·33 lines (27 loc) · 934 Bytes
/
Copy pathmerge_high_low.py
File metadata and controls
executable file
·33 lines (27 loc) · 934 Bytes
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
#! /usr/bin/python3
from mido import MidiFile
import os
import math
low_midi = MidiFile('Low/hierdec-mel_16bar_interpolate_2019-04-17_234652-001-of-005.mid')
high_midi = MidiFile('High/hierdec-mel_16bar_interpolate_2019-04-17_234652-000-of-005.mid')
def getPitch(mid,pos) :
# mid = MidiFile(file)
j = mid.tracks[1]
notes = []
for i in range(0,len(j)):
msg = j[i]
if i != 0 and i != len(j)-1:
notes.append(msg.note)
# print(notes)
pitch = math.floor(notes[pos]/12)
return pitch
def high_to_low():
high_pitch = getPitch(high_midi,-1)
low_pitch = getPitch(low_midi,0)
print("High to Low : high_pitch: {} \t low_pitch: {}".format(high_pitch,low_pitch))
def low_to_high():
low_pitch = getPitch(low_midi,-1)
high_pitch = getPitch(high_midi,0)
print("Low to High : high_pitch: {} \t low_pitch: {}".format(high_pitch,low_pitch))
high_to_low()
low_to_high()