asigalov61 commited on
Commit
8069a96
·
verified ·
1 Parent(s): 4f6146b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -14
app.py CHANGED
@@ -20,7 +20,14 @@ import matplotlib.pyplot as plt
20
 
21
  # =================================================================================================
22
 
23
- def AddMelody(input_midi, input_mel_type, input_channel, input_patch, input_start_chord):
 
 
 
 
 
 
 
24
  print('=' * 70)
25
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
26
  start_time = reqtime.time()
@@ -36,6 +43,7 @@ def AddMelody(input_midi, input_mel_type, input_channel, input_patch, input_star
36
  print('Req channel:', input_channel)
37
  print('Req patch:', input_patch)
38
  print('Req start chord:', input_start_chord)
 
39
  print('-' * 70)
40
 
41
  #===============================================================================
@@ -44,7 +52,10 @@ def AddMelody(input_midi, input_mel_type, input_channel, input_patch, input_star
44
  #===============================================================================
45
  # Enhanced score notes
46
 
47
- escore_notes = TMIDIX.advanced_score_processor(raw_score, return_enhanced_score_notes=True)[0]
 
 
 
48
 
49
  if len(escore_notes) > 0:
50
 
@@ -169,6 +180,7 @@ if __name__ == "__main__":
169
  input_channel = gr.Slider(0, 15, value=3, step=1, label="Melody MIDI channel")
170
  input_patch = gr.Slider(0, 127, value=40, step=1, label="Melody MIDI patch")
171
  input_start_chord = gr.Slider(0, 128, value=0, step=1, label="Melody start chord")
 
172
 
173
  run_btn = gr.Button("add melody", variant="primary")
174
 
@@ -181,17 +193,38 @@ if __name__ == "__main__":
181
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
182
 
183
 
184
- run_event = run_btn.click(AddMelody, [input_midi, input_mel_type, input_channel, input_patch, input_start_chord],
185
- [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
186
-
187
- gr.Examples(
188
- [["Sharing The Night Together.kar", "Expressive", 3, 40, 0],
189
- ["Deep Relaxation Melody #6.mid", "Expressive", 3, 40, 0],
190
- ],
191
- [input_midi, input_mel_type, input_channel, input_patch, input_start_chord],
192
- [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot],
193
- AddMelody,
194
- cache_examples=True,
195
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
  app.queue().launch()
 
20
 
21
  # =================================================================================================
22
 
23
+ def AddMelody(input_midi,
24
+ input_mel_type,
25
+ input_channel,
26
+ input_patch,
27
+ input_start_chord,
28
+ input_apply_sustains
29
+ ):
30
+
31
  print('=' * 70)
32
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
33
  start_time = reqtime.time()
 
43
  print('Req channel:', input_channel)
44
  print('Req patch:', input_patch)
45
  print('Req start chord:', input_start_chord)
46
+ print('Req apply sustains:', input_apply_sustains)
47
  print('-' * 70)
48
 
49
  #===============================================================================
 
52
  #===============================================================================
53
  # Enhanced score notes
54
 
55
+ escore_notes = TMIDIX.advanced_score_processor(raw_score,
56
+ return_enhanced_score_notes=True,
57
+ apply_sustain=input_apply_sustains
58
+ )[0]
59
 
60
  if len(escore_notes) > 0:
61
 
 
180
  input_channel = gr.Slider(0, 15, value=3, step=1, label="Melody MIDI channel")
181
  input_patch = gr.Slider(0, 127, value=40, step=1, label="Melody MIDI patch")
182
  input_start_chord = gr.Slider(0, 128, value=0, step=1, label="Melody start chord")
183
+ input_apply_sustains = gr.Checkbox(value=False, label="Apply sustains (if present)")
184
 
185
  run_btn = gr.Button("add melody", variant="primary")
186
 
 
193
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
194
 
195
 
196
+ run_event = run_btn.click(AddMelody, [input_midi,
197
+ input_mel_type,
198
+ input_channel,
199
+ input_patch,
200
+ input_start_chord,
201
+ input_apply_sustains
202
+ ],
203
+ [output_midi_title,
204
+ output_midi_summary,
205
+ output_midi,
206
+ output_audio,
207
+ output_plot
208
+ ])
209
+
210
+ gr.Examples([["Sharing The Night Together.kar", "Expressive", 3, 40, 0],
211
+ ["Deep Relaxation Melody #6.mid", "Expressive", 3, 40, 0],
212
+ ],
213
+ [input_midi,
214
+ input_mel_type,
215
+ input_channel,
216
+ input_patch,
217
+ input_start_chord,
218
+ input_apply_sustains
219
+ ],
220
+ [output_midi_title,
221
+ output_midi_summary,
222
+ output_midi,
223
+ output_audio,
224
+ output_plot
225
+ ],
226
+ AddMelody,
227
+ cache_examples=True,
228
+ )
229
 
230
  app.queue().launch()