asigalov61 commited on
Commit
b3cb334
·
verified ·
1 Parent(s): 2c8f67f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -93,7 +93,7 @@ def generate_MIDI_images(num_images):
93
 
94
  # =================================================================================================
95
 
96
- def Generate_POP_Medley(input_num_medley_comps):
97
 
98
  print('=' * 70)
99
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
@@ -101,8 +101,11 @@ def Generate_POP_Medley(input_num_medley_comps):
101
  print('=' * 70)
102
 
103
  print('Req number of medley compositions:', input_num_medley_comps)
 
104
  print('=' * 70)
105
 
 
 
106
  #===============================================================================
107
 
108
  imgs_array = generate_MIDI_images(input_num_medley_comps)
@@ -120,6 +123,9 @@ def Generate_POP_Medley(input_num_medley_comps):
120
 
121
  score = TMIDIX.binary_matrix_to_original_escore_notes(bmatrix)
122
 
 
 
 
123
  medley_compositions_escores.append(score)
124
 
125
  print('Done!')
@@ -212,6 +218,7 @@ if __name__ == "__main__":
212
  gr.Markdown("Choose medley settings")
213
 
214
  input_num_medley_comps = gr.Slider(1, 12, value=8, step=1, label="Number of medley compositions")
 
215
 
216
  run_btn = gr.Button("Generate POP Medley", variant="primary")
217
 
@@ -223,7 +230,7 @@ if __name__ == "__main__":
223
  output_plot = gr.Plot(label="Output MIDI score plot")
224
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
225
 
226
- run_event = run_btn.click(Generate_POP_Medley, [input_num_medley_comps],
227
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
228
 
229
  app.queue().launch()
 
93
 
94
  # =================================================================================================
95
 
96
+ def Generate_POP_Medley(input_num_medley_comps, input_melody_patch):
97
 
98
  print('=' * 70)
99
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
 
101
  print('=' * 70)
102
 
103
  print('Req number of medley compositions:', input_num_medley_comps)
104
+ print('Req melody MIDI patch number:', input_melody_patch)
105
  print('=' * 70)
106
 
107
+ #===============================================================================
108
+ # MIDI Images generation function
109
  #===============================================================================
110
 
111
  imgs_array = generate_MIDI_images(input_num_medley_comps)
 
123
 
124
  score = TMIDIX.binary_matrix_to_original_escore_notes(bmatrix)
125
 
126
+ if input_melody_patch > -1:
127
+ score = TMIDIX.add_melody_to_enhanced_score_notes(score, melody_patch=input_melody_patch)
128
+
129
  medley_compositions_escores.append(score)
130
 
131
  print('Done!')
 
218
  gr.Markdown("Choose medley settings")
219
 
220
  input_num_medley_comps = gr.Slider(1, 12, value=8, step=1, label="Number of medley compositions")
221
+ input_melody_patch = gr.Slider(-1, 127, value=40, step=1, label="Medley melody MIDI patch number")
222
 
223
  run_btn = gr.Button("Generate POP Medley", variant="primary")
224
 
 
230
  output_plot = gr.Plot(label="Output MIDI score plot")
231
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
232
 
233
+ run_event = run_btn.click(Generate_POP_Medley, [input_num_medley_comps, input_melody_patch],
234
  [output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
235
 
236
  app.queue().launch()