Spaces:
Running
Running
asigalov61
commited on
Commit
•
e4d1c33
1
Parent(s):
ac062f7
Update app.py
Browse files
app.py
CHANGED
@@ -125,6 +125,8 @@ def Mix_Melody(input_midi,
|
|
125 |
input_output_as_solo_piano,
|
126 |
input_remove_drums,
|
127 |
input_output_tempo,
|
|
|
|
|
128 |
input_transpose_value
|
129 |
):
|
130 |
|
@@ -137,6 +139,8 @@ def Mix_Melody(input_midi,
|
|
137 |
fn = os.path.basename(input_midi.name)
|
138 |
fn1 = fn.split('.')[0]
|
139 |
|
|
|
|
|
140 |
print('-' * 70)
|
141 |
print('Input file name:', fn)
|
142 |
print('Find best matches', input_find_best_match)
|
@@ -145,6 +149,8 @@ def Mix_Melody(input_midi,
|
|
145 |
print('Output as Solo Piano:', input_output_as_solo_piano)
|
146 |
print('Remove drums:', input_remove_drums)
|
147 |
print('Output tempo:', input_output_tempo)
|
|
|
|
|
148 |
print('Transpose value:', input_transpose_value)
|
149 |
print('-' * 70)
|
150 |
|
@@ -167,6 +173,12 @@ def Mix_Melody(input_midi,
|
|
167 |
|
168 |
src_melody = [c[0] for c in src_cscore][:256]
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
mel_avg_time = TMIDIX.escore_notes_averages(src_melody)[0]
|
171 |
|
172 |
src_melody_pitches = [p[4] for p in src_melody]
|
@@ -302,9 +314,18 @@ def Mix_Melody(input_midi,
|
|
302 |
|
303 |
mixed_song = TMIDIX.adjust_escore_notes_timings(mixed_song, time_k)
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
if input_transpose_value != 0:
|
306 |
mixed_song = TMIDIX.transpose_escore_notes(mixed_song, input_transpose_value)
|
307 |
-
|
|
|
|
|
|
|
308 |
#===============================================================================
|
309 |
print('Rendering results...')
|
310 |
|
@@ -397,7 +418,10 @@ if __name__ == "__main__":
|
|
397 |
input_output_as_solo_piano = gr.Checkbox(label="Output as Solo Piano", value=False)
|
398 |
input_remove_drums = gr.Checkbox(label="Remove drums from output", value=False)
|
399 |
input_output_tempo = gr.Radio(["Mix Melody", "Source Melody", "Mix"], value="Mix Melody", label="Output tempo")
|
|
|
|
|
400 |
input_transpose_value = gr.Slider(-12, 12, value=0, step=1, label="Transpose value")
|
|
|
401 |
|
402 |
run_btn = gr.Button("mix melody", variant="primary")
|
403 |
|
@@ -417,13 +441,15 @@ if __name__ == "__main__":
|
|
417 |
input_output_as_solo_piano,
|
418 |
input_remove_drums,
|
419 |
input_output_tempo,
|
|
|
|
|
420 |
input_transpose_value
|
421 |
],
|
422 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
423 |
|
424 |
gr.Examples(
|
425 |
-
[["Abracadabra-Sample-Melody.mid", True, True, True, False, False, "Mix Melody", 0],
|
426 |
-
["Sparks-Fly-Sample-Melody.mid", True, True, True, False, False, "Mix Melody", 0],
|
427 |
],
|
428 |
[input_midi,
|
429 |
input_find_best_match,
|
@@ -432,6 +458,8 @@ if __name__ == "__main__":
|
|
432 |
input_output_as_solo_piano,
|
433 |
input_remove_drums,
|
434 |
input_output_tempo,
|
|
|
|
|
435 |
input_transpose_value
|
436 |
],
|
437 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
|
|
|
125 |
input_output_as_solo_piano,
|
126 |
input_remove_drums,
|
127 |
input_output_tempo,
|
128 |
+
input_transform,
|
129 |
+
input_transpose_to_C4,
|
130 |
input_transpose_value
|
131 |
):
|
132 |
|
|
|
139 |
fn = os.path.basename(input_midi.name)
|
140 |
fn1 = fn.split('.')[0]
|
141 |
|
142 |
+
print('-' * 70)
|
143 |
+
print('Requested settings:')
|
144 |
print('-' * 70)
|
145 |
print('Input file name:', fn)
|
146 |
print('Find best matches', input_find_best_match)
|
|
|
149 |
print('Output as Solo Piano:', input_output_as_solo_piano)
|
150 |
print('Remove drums:', input_remove_drums)
|
151 |
print('Output tempo:', input_output_tempo)
|
152 |
+
print('Transform:', input_transform)
|
153 |
+
print('Transpose to C4:', input_transpose_to_C4)
|
154 |
print('Transpose value:', input_transpose_value)
|
155 |
print('-' * 70)
|
156 |
|
|
|
173 |
|
174 |
src_melody = [c[0] for c in src_cscore][:256]
|
175 |
|
176 |
+
if input_transform == 'Flip Melody':
|
177 |
+
src_melody = TMIDIX.flip_enhanced_score_notes(src_melody)
|
178 |
+
|
179 |
+
elif input_transform == 'Reverse Melody':
|
180 |
+
src_melody = TMIDIX.reverse_enhanced_score_notes(src_melody)
|
181 |
+
|
182 |
mel_avg_time = TMIDIX.escore_notes_averages(src_melody)[0]
|
183 |
|
184 |
src_melody_pitches = [p[4] for p in src_melody]
|
|
|
314 |
|
315 |
mixed_song = TMIDIX.adjust_escore_notes_timings(mixed_song, time_k)
|
316 |
|
317 |
+
if input_transform == 'Flip Mix':
|
318 |
+
mixed_song = TMIDIX.flip_enhanced_score_notes(mixed_song)
|
319 |
+
|
320 |
+
elif input_transform == 'Reverse Mix':
|
321 |
+
mixed_song = TMIDIX.reverse_enhanced_score_notes(mixed_song)
|
322 |
+
|
323 |
if input_transpose_value != 0:
|
324 |
mixed_song = TMIDIX.transpose_escore_notes(mixed_song, input_transpose_value)
|
325 |
+
|
326 |
+
if input_transpose_to_C4:
|
327 |
+
mixed_song = TMIDIX.transpose_escore_notes_to_pitch(mixed_song)
|
328 |
+
|
329 |
#===============================================================================
|
330 |
print('Rendering results...')
|
331 |
|
|
|
418 |
input_output_as_solo_piano = gr.Checkbox(label="Output as Solo Piano", value=False)
|
419 |
input_remove_drums = gr.Checkbox(label="Remove drums from output", value=False)
|
420 |
input_output_tempo = gr.Radio(["Mix Melody", "Source Melody", "Mix"], value="Mix Melody", label="Output tempo")
|
421 |
+
input_transform = gr.Radio(["As-is", "Flip Melody", "Reverse Melody", "Flip Mix", "Reverse Mix"], value="As-is", label="Transform")
|
422 |
+
input_transpose_to_C4 = gr.Checkbox(label="Transpose to C4", value=False)
|
423 |
input_transpose_value = gr.Slider(-12, 12, value=0, step=1, label="Transpose value")
|
424 |
+
|
425 |
|
426 |
run_btn = gr.Button("mix melody", variant="primary")
|
427 |
|
|
|
441 |
input_output_as_solo_piano,
|
442 |
input_remove_drums,
|
443 |
input_output_tempo,
|
444 |
+
input_transform,
|
445 |
+
input_transpose_to_C4,
|
446 |
input_transpose_value
|
447 |
],
|
448 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
449 |
|
450 |
gr.Examples(
|
451 |
+
[["Abracadabra-Sample-Melody.mid", True, True, True, False, False, "Mix Melody", "As-is", False, 0],
|
452 |
+
["Sparks-Fly-Sample-Melody.mid", True, True, True, False, False, "Mix Melody", "As-is", False, 0],
|
453 |
],
|
454 |
[input_midi,
|
455 |
input_find_best_match,
|
|
|
458 |
input_output_as_solo_piano,
|
459 |
input_remove_drums,
|
460 |
input_output_tempo,
|
461 |
+
input_transform,
|
462 |
+
input_transpose_to_C4,
|
463 |
input_transpose_value
|
464 |
],
|
465 |
[output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
|