Update app.py
Browse files
app.py
CHANGED
@@ -75,7 +75,7 @@ def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, cus
|
|
75 |
print('=' * 70)
|
76 |
print('Processing...Please wait...')
|
77 |
|
78 |
-
if render_type == "
|
79 |
output_score = copy.deepcopy(escore)
|
80 |
|
81 |
elif render_type == "Extract melody":
|
@@ -119,29 +119,38 @@ def render_midi(input_midi, render_type, soundfont_bank, render_sample_rate, cus
|
|
119 |
|
120 |
new_fn = fn1+'.mid'
|
121 |
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
else:
|
134 |
-
patches[-1] = e[6]
|
135 |
-
|
136 |
-
patches = [p if p != -1 else 0 for p in patches]
|
137 |
-
|
138 |
-
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
|
139 |
-
output_signature = 'Advanced MIDI Renderer',
|
140 |
-
output_file_name = fn1,
|
141 |
-
track_name='Project Los Angeles',
|
142 |
-
list_of_MIDI_patches=patches
|
143 |
-
)
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
if soundfont_bank in ["General MIDI", "Nice strings plus orchestra", "Real choir"]:
|
146 |
sf2bank = ["General MIDI", "Nice strings plus orchestra", "Real choir"].index(soundfont_bank)
|
147 |
|
@@ -227,7 +236,7 @@ if __name__ == "__main__":
|
|
227 |
|
228 |
gr.Markdown("## Select desired render type")
|
229 |
|
230 |
-
render_type = gr.Radio(["Render as-is", "Extract melody", "Transform", "Repair"], label="Render type", value="Render as-is")
|
231 |
|
232 |
gr.Markdown("## Select desired render options")
|
233 |
|
|
|
75 |
print('=' * 70)
|
76 |
print('Processing...Please wait...')
|
77 |
|
78 |
+
if render_type == "Custom render" or not render_type:
|
79 |
output_score = copy.deepcopy(escore)
|
80 |
|
81 |
elif render_type == "Extract melody":
|
|
|
119 |
|
120 |
new_fn = fn1+'.mid'
|
121 |
|
122 |
+
if render_type != "Render as-is":
|
123 |
+
|
124 |
+
patches = [-1] * 16
|
125 |
+
patches[9] = 9
|
126 |
+
|
127 |
+
for e in output_score:
|
128 |
+
if e[3] != 9:
|
129 |
+
if patches[e[3]] == -1:
|
130 |
+
patches[e[3]] = e[6]
|
131 |
+
else:
|
132 |
+
if patches[e[3]] != e[6]:
|
133 |
+
if -1 in patches:
|
134 |
+
patches[patches.index(-1)] = e[6]
|
135 |
+
else:
|
136 |
+
patches[-1] = e[6]
|
137 |
|
138 |
+
patches = [p if p != -1 else 0 for p in patches]
|
139 |
+
|
140 |
+
detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
|
141 |
+
output_signature = 'Advanced MIDI Renderer',
|
142 |
+
output_file_name = fn1,
|
143 |
+
track_name='Project Los Angeles',
|
144 |
+
list_of_MIDI_patches=patches
|
145 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
+
else:
|
148 |
+
midi_data = TMIDIX.score2midi(raw_score)
|
149 |
+
|
150 |
+
with open(new_fn, 'wb') as f:
|
151 |
+
f.write(midi_data)
|
152 |
+
f.close()
|
153 |
+
|
154 |
if soundfont_bank in ["General MIDI", "Nice strings plus orchestra", "Real choir"]:
|
155 |
sf2bank = ["General MIDI", "Nice strings plus orchestra", "Real choir"].index(soundfont_bank)
|
156 |
|
|
|
236 |
|
237 |
gr.Markdown("## Select desired render type")
|
238 |
|
239 |
+
render_type = gr.Radio(["Render as-is", "Custom render", "Extract melody", "Transform", "Repair"], label="Render type", value="Render as-is")
|
240 |
|
241 |
gr.Markdown("## Select desired render options")
|
242 |
|