asigalov61 commited on
Commit
57440b4
1 Parent(s): 99fabfd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -47,6 +47,8 @@ def render_midi(input_midi, render_type, soundfont_bank, melody_patch):
47
  print('Input MIDI file name:', fn)
48
  print('Input MIDI md5 hash', input_midi_md5hash)
49
  print('Render type:', render_type)
 
 
50
 
51
  print('=' * 70)
52
  print('Processing MIDI...Please wait...')
@@ -88,7 +90,7 @@ def render_midi(input_midi, render_type, soundfont_bank, melody_patch):
88
 
89
  for e in output_score:
90
  e[3] = 0
91
- e[6] = 40
92
 
93
  if e[4] < 60:
94
  e[4] = (e[4] % 12) + 60
@@ -141,9 +143,15 @@ def render_midi(input_midi, render_type, soundfont_bank, melody_patch):
141
  track_name='Project Los Angeles',
142
  list_of_MIDI_patches=patches
143
  )
 
 
 
 
 
 
144
 
145
  audio = midi_to_colab_audio(new_fn,
146
- soundfont_path=soundfonts[0],
147
  sample_rate=16000, # 44100
148
  volume_scale=10,
149
  output_for_gradio=True
 
47
  print('Input MIDI file name:', fn)
48
  print('Input MIDI md5 hash', input_midi_md5hash)
49
  print('Render type:', render_type)
50
+ print('Soudnfont bank', soundfont_bank)
51
+ print('Melody patch', melody_patch)
52
 
53
  print('=' * 70)
54
  print('Processing MIDI...Please wait...')
 
90
 
91
  for e in output_score:
92
  e[3] = 0
93
+ e[6] = max(0, min(127, melody_patch))
94
 
95
  if e[4] < 60:
96
  e[4] = (e[4] % 12) + 60
 
143
  track_name='Project Los Angeles',
144
  list_of_MIDI_patches=patches
145
  )
146
+
147
+ if soundfont_bank in ["General MIDI", "Nice strings plus orchestra", "Real choir"]:
148
+ sf2bank = ["General MIDI", "Nice strings plus orchestra", "Real choir"].index(soundfont_bank)
149
+
150
+ else:
151
+ sf2bank = 0
152
 
153
  audio = midi_to_colab_audio(new_fn,
154
+ soundfont_path=soundfonts[sf2bank],
155
  sample_rate=16000, # 44100
156
  volume_scale=10,
157
  output_for_gradio=True