Incorrect loading of files with multiple instruments per track
cifkao opened this issue · 2 comments
A MIDI track might contain multiple channels and program numbers, but Tone.js/Midi assigns channel numbers and instruments to entire MIDI tracks. This is especially painful in Type 0 MIDI files, where all instruments, including drums, are in a single track.
Moreover, different channels in the same MIDI track may have overlapping notes (again, this will happen often in Type 0 files), which will break the pairing of note-ons and note-offs.
Tone.js could adopt the behavior of pretty_midi
, which creates a separate track for every (program, channel, track)
triplet. This would solve both problems.
A workaround for users is to run MIDI files through pretty_midi
before loading them with Tone.js.
Probably related to #9 and #75.
Might be of interest to Magenta.js people (@notwaldorf?) – but you probably already know about this.
I've looked into this and it turns out Type 0 files are fine (these seem to be handled well by midi-file). The problem is when a Type 1 file contains multiple instruments per track.