newlandsvalley / elm-comidi

MIDI parser in pure elm
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

Not all Type-1 files parse #1

Closed newlandsvalley closed 8 years ago

newlandsvalley commented 8 years ago

There is still a problem with multi-track files. Carolan's Receipt parses OK whereas the Galway Hornpipe does not - it reaches the end of the first track and expects the input to be at an end. Not entirely sure yet why this is - the files are pretty similar and I would have expected either both to pass or both to fail. I suspect the problem might be in midiMessage() - the parser has to consume the delta-time but then has to backtrack if in fact the message is TrackEnd. In which case, why would anything parse at all?

newlandsvalley commented 8 years ago

After a good many false leads, I've perhaps found the root of the problem. The subsequent track was not parsing I suspect because it contained an unexpected meta event type (i.e. within the range 00-7F but not a value defined in the spec). I had ignored these values. The parser error reporting was a trifle misleading - the error position appeared to be the start of the track which contained the error.

newlandsvalley commented 8 years ago

This was indeed the problem - a meta type of 0x21 which is inside the range but not defined in the spec. Added a parser for unspecified meta types and added proper recognition of TrackEnd as a terminating condition for a list of MIDI events.