Git Product home page Git Product logo

Comments (4)

orchetect avatar orchetect commented on June 17, 2024

Thanks for the bug report. I've looked into this and the file is being successfully parsed, but there are two trailing bytes at the end of the file: 0x0D 0x0A. Because these bytes are unexpected, the file is technically considered malformed, even though these bytes are of no apparent consequence.

Thus far I cannot find any reason for them being there. There is nothing in the SMF spec that mentions what they would be for. It's possible to ignore them but I'd rather get to the bottom of why they might be there in the first place if possible before resorting to that.

from midikit.

SinanKarasu avatar SinanKarasu commented on June 17, 2024

Appears they are the \r\n characters. Maybe someone edited the file with a hex editor on windows, and when saved it added carriage return line feed?

from midikit.

SinanKarasu avatar SinanKarasu commented on June 17, 2024

I have developed parsers using Antlr, and this was always a problem between Windows and Unix. Here is one from IBM.
https://www.ibm.com/support/pages/additional-carriage-return-and-line-feed-added-during-sterling-connectdirect-file-transfer

from midikit.

orchetect avatar orchetect commented on June 17, 2024

Yeah it's a Windows CRLF byte pair. Really odd. But if someone attempted editing the file in a text editor then maybe that explains it. Some of the MIDI files out in the wild have survived decades and who knows what happened along the way.

On a related note: I sourced a zip file of about 30,000 crowd-sourced MIDI files from the web and ran all of them through a test harness that had MIDIFile parse them to catch any misfits. It returned a number of results so I'm going to go through those soon and see if the parser can be made more resilient to malformed or unexpected files.

from midikit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.