asigalov61 commited on
Commit
37f1de7
·
verified ·
1 Parent(s): 183a2a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -102,16 +102,19 @@ def render_midi(input_midi, render_options):
102
 
103
  new_fn = fn1+'.mid'
104
 
105
- patches = [0] * 16
106
  patches[9] = 9
107
 
108
- channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15]
109
-
110
- score_patches = sorted(set([e[6] for e in output_score if e[3] != 9]))
111
-
112
- for channel, patch in enumerate(channels[:len(score_patches)]):
113
- patches[patch] = score_patches[channel]
114
-
 
 
 
115
  detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
116
  output_signature = 'Advanced MIDI Renderer',
117
  output_file_name = fn1,
 
102
 
103
  new_fn = fn1+'.mid'
104
 
105
+ patches = [-1] * 16
106
  patches[9] = 9
107
 
108
+ for e in output_score:
109
+ if e[3] != 9:
110
+ if patches[e[3]] == -1:
111
+ patches[e[3]] = e[6]
112
+ else:
113
+ if -1 in patches:
114
+ patches[patches.index(-1)] = e[6]
115
+ else:
116
+ patches[-1] = e[6]
117
+
118
  detailed_stats = TMIDIX.Tegridy_ms_SONG_to_MIDI_Converter(output_score,
119
  output_signature = 'Advanced MIDI Renderer',
120
  output_file_name = fn1,