Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ in_space = os.getenv("SYSTEM") == "spaces"
|
|
| 28 |
|
| 29 |
#==========================================================================================================
|
| 30 |
|
| 31 |
-
def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, custom_render_patch
|
| 32 |
|
| 33 |
print('*' * 70)
|
| 34 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
|
@@ -92,7 +92,6 @@ def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, cus
|
|
| 92 |
|
| 93 |
for e in output_score:
|
| 94 |
e[3] = 0
|
| 95 |
-
e[6] = max(0, min(127, melody_patch))
|
| 96 |
|
| 97 |
if e[4] < 60:
|
| 98 |
e[4] = (e[4] % 12) + 60
|
|
@@ -146,6 +145,8 @@ def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, cus
|
|
| 146 |
else:
|
| 147 |
output_score.extend(c)
|
| 148 |
|
|
|
|
|
|
|
| 149 |
print('Done processing!')
|
| 150 |
print('=' * 70)
|
| 151 |
|
|
@@ -286,8 +287,6 @@ if __name__ == "__main__":
|
|
| 286 |
|
| 287 |
custom_render_patch = gr.Slider(-1, 127, value=-1, label="Custom MIDI render patch")
|
| 288 |
|
| 289 |
-
melody_patch = gr.Slider(0, 127, value=40, label="Melody MIDI patch")
|
| 290 |
-
|
| 291 |
submit = gr.Button()
|
| 292 |
|
| 293 |
gr.Markdown("## Render results")
|
|
@@ -299,7 +298,7 @@ if __name__ == "__main__":
|
|
| 299 |
output_plot = gr.Plot(label="Output MIDI score plot")
|
| 300 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
| 301 |
|
| 302 |
-
run_event = submit.click(render_midi, [input_midi, render_type, soundfont_bank, render_sample_rate, custom_render_patch
|
| 303 |
[output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
| 304 |
|
| 305 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|
|
|
|
| 28 |
|
| 29 |
#==========================================================================================================
|
| 30 |
|
| 31 |
+
def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, custom_render_patch):
|
| 32 |
|
| 33 |
print('*' * 70)
|
| 34 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
|
|
|
| 92 |
|
| 93 |
for e in output_score:
|
| 94 |
e[3] = 0
|
|
|
|
| 95 |
|
| 96 |
if e[4] < 60:
|
| 97 |
e[4] = (e[4] % 12) + 60
|
|
|
|
| 145 |
else:
|
| 146 |
output_score.extend(c)
|
| 147 |
|
| 148 |
+
output_score.sort(key= lambda x: x[1])
|
| 149 |
+
|
| 150 |
print('Done processing!')
|
| 151 |
print('=' * 70)
|
| 152 |
|
|
|
|
| 287 |
|
| 288 |
custom_render_patch = gr.Slider(-1, 127, value=-1, label="Custom MIDI render patch")
|
| 289 |
|
|
|
|
|
|
|
| 290 |
submit = gr.Button()
|
| 291 |
|
| 292 |
gr.Markdown("## Render results")
|
|
|
|
| 298 |
output_plot = gr.Plot(label="Output MIDI score plot")
|
| 299 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
| 300 |
|
| 301 |
+
run_event = submit.click(render_midi, [input_midi, render_type, soundfont_bank, render_sample_rate, custom_render_patch],
|
| 302 |
[output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
| 303 |
|
| 304 |
app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
|