skytnt commited on
Commit
23810d5
1 Parent(s): d5353b5

update tokenizer

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. midi_tokenizer.py +2 -0
app.py CHANGED
@@ -311,7 +311,7 @@ if __name__ == "__main__":
311
  step=1,
312
  value=128)
313
  input_reduce_cc_st = gr.Checkbox(label="reduce control_change and set_tempo events", value=True)
314
- input_remap_track_channel = gr.Checkbox(label="remap tracks and channels to have only one channel per track", value=True)
315
  input_add_default_instr = gr.Checkbox(label="add a default instrument to channels that don't have an instrument", value=True)
316
  input_remove_empty_channels = gr.Checkbox(label="remove channels without notes", value=False)
317
  example2 = gr.Examples([[file, 128] for file in glob.glob("example/*.mid")],
 
311
  step=1,
312
  value=128)
313
  input_reduce_cc_st = gr.Checkbox(label="reduce control_change and set_tempo events", value=True)
314
+ input_remap_track_channel = gr.Checkbox(label="remap tracks and channels so each track has only one channel and in order", value=True)
315
  input_add_default_instr = gr.Checkbox(label="add a default instrument to channels that don't have an instrument", value=True)
316
  input_remove_empty_channels = gr.Checkbox(label="remove channels without notes", value=False)
317
  example2 = gr.Examples([[file, 128] for file in glob.glob("example/*.mid")],
midi_tokenizer.py CHANGED
@@ -131,6 +131,8 @@ class MIDITokenizer:
131
  patch_channels = []
132
  channels_count = 0
133
  channels_map = {9: 9} if 9 in channels else {}
 
 
134
  for c in channels:
135
  if c == 9:
136
  continue
 
131
  patch_channels = []
132
  channels_count = 0
133
  channels_map = {9: 9} if 9 in channels else {}
134
+ if remove_empty_channels:
135
+ channels = sorted(channels, key=lambda x: 1 if x in empty_channels else 0)
136
  for c in channels:
137
  if c == 9:
138
  continue