Tonejs/Midi

Inconsistent handling of tempo changes in Midi rendering

hillct opened this issue · 3 comments

In testing, we've observed inconsistent parsing results when the Tonejs/Midi module is utilized in an environment running Node 10.x vs 12.x and above. The issue is exemplified in the attached files, and appears to relate to parsing of tempo changes in the source midi file.

In particular, in an environment running Node 10.x an erroneous element is introduced in the example v1- file, as follows:

        {
          "duration": 0.3000000000000007,
          "durationTicks": 960,
          "midi": 55,
          "name": "G3",
          "ticks": 34560,
          "time": 10.799999999999999,
          "velocity": 0.5984251968503937
        }

The correct (expected) behavior is seen in the v12 file, generated in an environment running node 12.x, namely, this extraneous element is not present at all. In the correct results, there are two 'G3's, first one is at 9.6, the second is at 11.1.

Certainly, this issue may be resolved with a fix to the upstream midi-file module, bit it may also be resolved with a polyfill, or simply a declaration here, that node versions lower than 12 (or maybe 11) are not supported. If such a declaration already exists, please let me know, but I haven't found it. If the former is the elected solution, it's worth keeping this ticket open (linking to the related issue for the midi-file module) as a tracking ticket.

It's also worth pointing out that this issue does not occur, when running in a browser (chrome was tested), but only when the module is used in a Node environment.

midi_slice-v10.mid.json.txt
midi_slice-v12.mid.json.txt
midi_slice.mid.gz

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Thanks for the issue. Do you have any ideas on why the Node.js version might be handling these things differently? That issue is potentially in the midi parsing library used under the hood midi-file

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.