sinshu / rustysynth

A SoundFont MIDI synthesizer written in pure Rust
Other
139 stars 22 forks source link

Skip bytes if the track end event ends before the chunk length #8

Closed ArthurCose closed 1 year ago

ArthurCose commented 1 year ago

I have this midi file that ends the track chunk with multiple track end events:

image

Currently, the MidiFile struct will see the track end and immediately attempt to process the next event as an MTrk header giving me an InvalidChunkType for "??/?". Tracking the number of bytes read and skipping excess bytes (the extra event) allows the file to be fully read + play.

I have a fork that wraps the reader to track bytes read for resolving how many bytes to skip, not sure if there's a better solution.

sinshu commented 1 year ago

Thanks for reporting the issue and for the pull request 😄 Your proposed fix looks good. After merging this pull request, would you mind if I changed the naming convention of the part you created to my personal preference?

ArthurCose commented 1 year ago

I wouldn't mind, thank you

sinshu commented 1 year ago

I've released v1.1.1 which fixes this issue. Thanks for the PR 😄