Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -113,7 +113,7 @@ def load_model():
|
|
113 |
|
114 |
#==================================================================================
|
115 |
|
116 |
-
def load_midi(input_midi,
|
117 |
|
118 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi.name)
|
119 |
|
@@ -121,27 +121,38 @@ def load_midi(input_midi, model_selector=''):
|
|
121 |
escore_notes = TMIDIX.augment_enhanced_score_notes(escore_notes, timings_divider=32)
|
122 |
|
123 |
sp_escore_notes = TMIDIX.solo_piano_escore_notes(escore_notes, keep_drums=False)
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
cscore = TMIDIX.chordify_score([1000, zscore])
|
127 |
|
128 |
score = []
|
129 |
|
|
|
|
|
130 |
pc = cscore[0]
|
131 |
|
132 |
for c in cscore:
|
133 |
score.append(max(0, min(127, c[0][1]-pc[0][1])))
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
|
|
|
|
141 |
|
142 |
pc = c
|
|
|
|
|
143 |
|
144 |
-
return score
|
145 |
|
146 |
#==================================================================================
|
147 |
|
|
|
113 |
|
114 |
#==================================================================================
|
115 |
|
116 |
+
def load_midi(input_midi, melody_patch=-1):
|
117 |
|
118 |
raw_score = TMIDIX.midi2single_track_ms_score(input_midi.name)
|
119 |
|
|
|
121 |
escore_notes = TMIDIX.augment_enhanced_score_notes(escore_notes, timings_divider=32)
|
122 |
|
123 |
sp_escore_notes = TMIDIX.solo_piano_escore_notes(escore_notes, keep_drums=False)
|
124 |
+
|
125 |
+
if melody_patch == -1:
|
126 |
+
zscore = TMIDIX.recalculate_score_timings(sp_escore_notes)
|
127 |
+
|
128 |
+
else:
|
129 |
+
zscore = TMIDIX.recalculate_score_timings([e for e in sp_escore_notes if e[6] == melody_patch])
|
130 |
|
131 |
cscore = TMIDIX.chordify_score([1000, zscore])
|
132 |
|
133 |
score = []
|
134 |
|
135 |
+
score_list = []
|
136 |
+
|
137 |
pc = cscore[0]
|
138 |
|
139 |
for c in cscore:
|
140 |
score.append(max(0, min(127, c[0][1]-pc[0][1])))
|
141 |
|
142 |
+
scl = [[max(0, min(127, c[0][1]-pc[0][1]))]]
|
143 |
+
|
144 |
+
n = c[0]
|
145 |
+
|
146 |
+
score.extend([max(1, min(127, n[2]))+128, max(1, min(127, n[4]))+256])
|
147 |
+
scl.append([max(1, min(127, n[2]))+128, max(1, min(127, n[4]))+256])
|
148 |
+
|
149 |
+
score_list.append(scl)
|
150 |
|
151 |
pc = c
|
152 |
+
|
153 |
+
score_list.append(scl)
|
154 |
|
155 |
+
return score, score_list
|
156 |
|
157 |
#==================================================================================
|
158 |
|