asigalov61
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -239,7 +239,7 @@ def Harmonize_Melody(input_src_midi,
|
|
239 |
|
240 |
final_song.extend(all_chords_ptcs_chunks[sidx])
|
241 |
|
242 |
-
for i in tqdm
|
243 |
|
244 |
trg_chunk = np.array(harm_toks[i:i+chunk_length])
|
245 |
|
@@ -263,44 +263,80 @@ def Harmonize_Melody(input_src_midi,
|
|
263 |
print('=' * 70)
|
264 |
print('Done!')
|
265 |
print('=' * 70)
|
266 |
-
|
267 |
-
print('Rendering results...')
|
268 |
-
print('=' * 70)
|
269 |
|
270 |
-
|
271 |
-
|
272 |
-
time = 0
|
273 |
-
|
274 |
-
patches = [0] * 16
|
275 |
-
patches[0] = harmonized_accompaniment_MIDI_patch_number
|
276 |
-
|
277 |
-
if base_MIDI_patch_number > -1:
|
278 |
-
patches[2] = base_MIDI_patch_number
|
279 |
-
|
280 |
-
patches[3] = melody_MIDI_patch_number
|
281 |
|
282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
|
288 |
time = mel_score[i][1] * 16
|
289 |
dur = mel_score[i][2] * 16
|
290 |
|
291 |
output_score.append(['note', time, dur, 3, mel_score[i][4], 115+(mel_score[i][4] % 12), 40])
|
292 |
-
|
293 |
-
chord = TMIDIX.ALL_CHORDS_FILTERED[s-12]
|
294 |
|
295 |
-
for c in
|
296 |
|
297 |
-
pitch =
|
298 |
output_score.append(['note', time, dur, 0, pitch, max(40, pitch), harmonized_accompaniment_MIDI_patch_number])
|
299 |
|
300 |
if base_MIDI_patch_number > -1:
|
301 |
-
output_score.append(['note', time, dur, 2,
|
|
|
|
|
302 |
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
fn1 = "Melody-Harmonizer-Transformer-Composition"
|
306 |
|
|
|
239 |
|
240 |
final_song.extend(all_chords_ptcs_chunks[sidx])
|
241 |
|
242 |
+
for i in tqdm(range(chunk_length, len(harm_toks), chunk_length)):
|
243 |
|
244 |
trg_chunk = np.array(harm_toks[i:i+chunk_length])
|
245 |
|
|
|
263 |
print('=' * 70)
|
264 |
print('Done!')
|
265 |
print('=' * 70)
|
|
|
|
|
|
|
266 |
|
267 |
+
print('Rendering textured results...')
|
268 |
+
print('=' * 70)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
+
output_score = []
|
271 |
+
|
272 |
+
time = 0
|
273 |
+
|
274 |
+
patches = [0] * 16
|
275 |
+
patches[0] = harmonized_accompaniment_MIDI_patch_number
|
276 |
+
|
277 |
+
if base_MIDI_patch_number > -1:
|
278 |
+
patches[2] = base_MIDI_patch_number
|
279 |
+
|
280 |
+
patches[3] = melody_MIDI_patch_number
|
281 |
|
282 |
+
i = 0
|
283 |
+
|
284 |
+
for s in final_song:
|
285 |
|
286 |
time = mel_score[i][1] * 16
|
287 |
dur = mel_score[i][2] * 16
|
288 |
|
289 |
output_score.append(['note', time, dur, 3, mel_score[i][4], 115+(mel_score[i][4] % 12), 40])
|
|
|
|
|
290 |
|
291 |
+
for c in s:
|
292 |
|
293 |
+
pitch = c
|
294 |
output_score.append(['note', time, dur, 0, pitch, max(40, pitch), harmonized_accompaniment_MIDI_patch_number])
|
295 |
|
296 |
if base_MIDI_patch_number > -1:
|
297 |
+
output_score.append(['note', time, dur, 2, (s[-1] % 12) + 24, 120-(s[-1] % 12), base_MIDI_patch_number])
|
298 |
+
|
299 |
+
i += 1
|
300 |
|
301 |
+
else:
|
302 |
+
|
303 |
+
print('Rendering results...')
|
304 |
+
print('=' * 70)
|
305 |
+
|
306 |
+
output_score = []
|
307 |
+
|
308 |
+
time = 0
|
309 |
+
|
310 |
+
patches = [0] * 16
|
311 |
+
patches[0] = harmonized_accompaniment_MIDI_patch_number
|
312 |
+
|
313 |
+
if base_MIDI_patch_number > -1:
|
314 |
+
patches[2] = base_MIDI_patch_number
|
315 |
+
|
316 |
+
patches[3] = melody_MIDI_patch_number
|
317 |
+
|
318 |
+
i = 0
|
319 |
+
|
320 |
+
for s in song:
|
321 |
+
|
322 |
+
if 11 < s < 141:
|
323 |
+
|
324 |
+
time = mel_score[i][1] * 16
|
325 |
+
dur = mel_score[i][2] * 16
|
326 |
+
|
327 |
+
output_score.append(['note', time, dur, 3, mel_score[i][4], 115+(mel_score[i][4] % 12), 40])
|
328 |
+
|
329 |
+
chord = TMIDIX.ALL_CHORDS_FILTERED[s-12]
|
330 |
+
|
331 |
+
for c in chord:
|
332 |
+
|
333 |
+
pitch = 48+c
|
334 |
+
output_score.append(['note', time, dur, 0, pitch, max(40, pitch), harmonized_accompaniment_MIDI_patch_number])
|
335 |
+
|
336 |
+
if base_MIDI_patch_number > -1:
|
337 |
+
output_score.append(['note', time, dur, 2, chord[-1]+24, 120-chord[-1], base_MIDI_patch_number])
|
338 |
+
|
339 |
+
i += 1
|
340 |
|
341 |
fn1 = "Melody-Harmonizer-Transformer-Composition"
|
342 |
|