Closed TimHanewich closed 1 year ago
Hi Tim, no, there is currently no track attribute. Many MIDI files have one track per instrument, but in many, many files there are several instruments per track or one instrument is present in several tracks. In order to identify which instrument has to be played, I use the event.channel attribute, since the track attribute would not be reliable to identify the instrument. All channel events, such as note on, note off, control change, program change already have the channel atribute. When MIDI is sent over USB or BLE, no track number is present, the channel number identifies what where notes belong. In other MIDI file parsers, such as MIDO (for CPython), the track information is also not returned, for the same reasons. You also can get the events in each track with umididparser. This is intended for midi type 2 files, which are not very common, but also works for type 0 and 1 files.
Is this useful for you use case?
Thank you for the quick response! Yes this is very helpful. Thanks again and great work on this.
Hi @bixb922 , thank you for creating and providing this useful module. I have a quick question for you: how are we to determine which track a particular note_on or note_off event belongs to? For example, consider the following events that were listed using the
.play()
method of the MidiFile class:How would one be able to determine which track each note_on and note_off event belongs to? Thank you for the help!