Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not parsing correctly #13

Open
steveschow opened this issue Apr 26, 2020 · 5 comments
Open

Not parsing correctly #13

steveschow opened this issue Apr 26, 2020 · 5 comments
Assignees

Comments

@steveschow
Copy link

I have run into bugs with this parser...

I made a simple midi region in LogicPro with notes one tick apart. I export this region as type 0 midi file. When I parse this midi file with midi-parse-js and log the parsed JSON immediately, it is showing incorrect structure in the JSON structure. the notes are being parsed as meta events with -1 deltaTime... I don't know how to attach the midi file to this ticket but if you ask me for it I can send it in email.

{
  "formatType": 0,
  "tracks": 1,
  "track": [
    {
      "event": [
        {
          "deltaTime": 0,
          "type": 255,
          "metaType": 32,
          "data": 0
        },
        {
          "deltaTime": 16259,
          "type": 255,
          "metaType": 6,
          "data": "nst 1\u0000ÿ\u0004\u0006Inst 1\u0000ÿX\u0004\u0004\u0002\u0018\b\u0000ÿY\u0002\u0000\u0000\u0000ÿT\u0005!\u0000\u0000\u0000\u0000\u0000ÿQ\u0003\u0007¡ \u0000�<P\u0000=P\u0000>P\u0000?P\u0000@P\u0000APx�<\u0000\u0000�=\u0000\u0000"
        },
        {
          "deltaTime": 62,
          "type": 255,
          "metaType": 0,
          "data": -1
        },
        {
          "deltaTime": 63,
          "type": 255,
          "metaType": 0,
          "data": -1
        },
        {
          "deltaTime": 64,
          "type": 255,
          "metaType": 0,
          "data": -1
        },
        {
          "deltaTime": 65,
          "type": 255,
          "metaType": 0,
          "data": -1
        },
        {
          "deltaTime": -1
        }
      ]
    }
  ],
  "timeDivision": 480
}
@colxi
Copy link
Owner

colxi commented Apr 27, 2020

Hi @steveschow you can send me the .midi file to contact@colxi.info so i can analyse better what's causing the issue. Thanks for reporting the bug!

@colxi colxi self-assigned this Apr 27, 2020
@alana314
Copy link

Hello! Thanks for making this library. I'm also having issues with a simple MIDI file from logic. I just get one event with infinity as the value:

{
  formatType: 0,
  tracks: 1,
  track: [
    {
      event: [
        { deltaTime: 1440, type: 255, metaType: 32, data: 0 },
        {
          deltaTime: 16259,
          type: 255,
          metaType: 23,
          data: 2.8996905316392495e+160
        },
        { deltaTime: 2123, type: 255, metaType: 98, data: Infinity },
        { deltaTime: -1 }
      ]
    }
  ],
  timeDivision: 480
}

I'll send you the MIDI file.
Thanks!

@Andy671
Copy link

Andy671 commented Feb 11, 2023

confirming the issue

@sdercolin
Copy link

Having the same issue using Logic Pro.

The reason is Logic Pro is writing a 0x20 type meta event which this library is not handling.
So it goes into the default case, which has a bug (fixed in PR #20, but not merged yet).

I wrote a commit to handle the 0x20 case but it's not the actual reason, so just for reference: master...sdercolin:midi-parser-js:master

Currently, as a workaround, we can assign a function to customInterpreter to fix the issue:

MidiParser.customInterpreter = function (metaType, arrayBuffer) {
    if (metaType !== 0x20) {
        return false;
    }
    return [arrayBuffer.readInt(1)];
}

@Bacto
Copy link

Bacto commented Apr 14, 2024

@colxi I can confirm that I have the same bug.
The PR #20 solved the issue.

I got the bug with the "Self Esteem" file:
https://www.midiworld.com/files/901/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants