asigalov61
commited on
Commit
•
8b3de7f
1
Parent(s):
3733fba
Update app.py
Browse files
app.py
CHANGED
@@ -22,11 +22,14 @@ import matplotlib.pyplot as plt
|
|
22 |
|
23 |
#==========================================================================================================
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
30 |
|
31 |
print('*' * 70)
|
32 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
@@ -48,6 +51,8 @@ def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, cus
|
|
48 |
print('Soudnfont bank', soundfont_bank)
|
49 |
print('Audio render sample rate', render_sample_rate)
|
50 |
print('Custom MIDI render patch', custom_render_patch)
|
|
|
|
|
51 |
|
52 |
print('=' * 70)
|
53 |
print('Processing MIDI...Please wait...')
|
@@ -114,6 +119,12 @@ def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, cus
|
|
114 |
|
115 |
if render_type != "Render as-is":
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
SONG, patches, overflow_patches = TMIDIX.patch_enhanced_score_notes(output_score)
|
118 |
|
119 |
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(SONG,
|
@@ -193,6 +204,7 @@ if __name__ == "__main__":
|
|
193 |
soundfonts = ["SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2", "Nice-Strings-PlusOrchestra-v1.6.sf2", "KBH-Real-Choir-V2.5.sf2", "Orpheus_18.06.2020.sf2", "SuperGameBoy.sf2"]
|
194 |
|
195 |
app = gr.Blocks()
|
|
|
196 |
with app:
|
197 |
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Advanced MIDI Renderer</h1>")
|
198 |
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Transform and render any MIDI</h1>")
|
@@ -216,7 +228,10 @@ if __name__ == "__main__":
|
|
216 |
|
217 |
render_sample_rate = gr.Radio(["16000", "32000", "44100"], label="MIDI audio render sample rate", value="16000")
|
218 |
|
219 |
-
custom_render_patch = gr.Slider(-1, 127, value=-1, label="Custom MIDI
|
|
|
|
|
|
|
220 |
|
221 |
submit = gr.Button()
|
222 |
|
@@ -229,7 +244,14 @@ if __name__ == "__main__":
|
|
229 |
output_plot = gr.Plot(label="Output MIDI score plot")
|
230 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
231 |
|
232 |
-
run_event = submit.click(render_midi, [input_midi,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
[output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
234 |
|
235 |
-
app.queue(
|
|
|
22 |
|
23 |
#==========================================================================================================
|
24 |
|
25 |
+
def render_midi(input_midi,
|
26 |
+
render_type,
|
27 |
+
soundfont_bank,
|
28 |
+
render_sample_rate,
|
29 |
+
custom_render_patch,
|
30 |
+
render_transpose_value,
|
31 |
+
render_transpose_to_C4
|
32 |
+
):
|
33 |
|
34 |
print('*' * 70)
|
35 |
print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
|
|
|
51 |
print('Soudnfont bank', soundfont_bank)
|
52 |
print('Audio render sample rate', render_sample_rate)
|
53 |
print('Custom MIDI render patch', custom_render_patch)
|
54 |
+
print('Transpose value:', render_transpose_value)
|
55 |
+
print('Transpose to C4', render_transpose_to_C4)
|
56 |
|
57 |
print('=' * 70)
|
58 |
print('Processing MIDI...Please wait...')
|
|
|
119 |
|
120 |
if render_type != "Render as-is":
|
121 |
|
122 |
+
if render_transpose_value != 0:
|
123 |
+
output_score = TMIDIX.transpose_escore_notes(output_score, input_transpose_value)
|
124 |
+
|
125 |
+
if render_transpose_to_C4:
|
126 |
+
output_score = TMIDIX.transpose_escore_notes_to_pitch(output_score)
|
127 |
+
|
128 |
SONG, patches, overflow_patches = TMIDIX.patch_enhanced_score_notes(output_score)
|
129 |
|
130 |
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(SONG,
|
|
|
204 |
soundfonts = ["SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2", "Nice-Strings-PlusOrchestra-v1.6.sf2", "KBH-Real-Choir-V2.5.sf2", "Orpheus_18.06.2020.sf2", "SuperGameBoy.sf2"]
|
205 |
|
206 |
app = gr.Blocks()
|
207 |
+
|
208 |
with app:
|
209 |
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Advanced MIDI Renderer</h1>")
|
210 |
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>Transform and render any MIDI</h1>")
|
|
|
228 |
|
229 |
render_sample_rate = gr.Radio(["16000", "32000", "44100"], label="MIDI audio render sample rate", value="16000")
|
230 |
|
231 |
+
custom_render_patch = gr.Slider(-1, 127, value=-1, label="Custom render MIDI patch")
|
232 |
+
|
233 |
+
render_transpose_value = gr.Slider(-12, 12, value=0, step=1, label="Transpose value")
|
234 |
+
render_transpose_to_C4 = gr.Checkbox(label="Transpose to C4", value=False)
|
235 |
|
236 |
submit = gr.Button()
|
237 |
|
|
|
244 |
output_plot = gr.Plot(label="Output MIDI score plot")
|
245 |
output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
|
246 |
|
247 |
+
run_event = submit.click(render_midi, [input_midi,
|
248 |
+
render_type,
|
249 |
+
soundfont_bank,
|
250 |
+
render_sample_rate,
|
251 |
+
custom_render_patch,
|
252 |
+
render_transpose_value,
|
253 |
+
render_transpose_to_C4
|
254 |
+
],
|
255 |
[output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
|
256 |
|
257 |
+
app.queue().launch()
|