-
Notifications
You must be signed in to change notification settings - Fork 62
Play MIDI files #107
Description
Since there's no "Discussions" tab in this repo (and this discussion affects potential add-ons and bugfixes), I'm opening this issue to discuss how to play MIDI files. This discussion started at mudcube/MIDI.js#268 (comment) and mudcube/MIDI.js#268 (comment) with @urobot2011 in the repo of MIDI.js, whose SoundFont loader soundfont-player replaces.
The readme of soundfont-player says "It is a much simpler and lightweight replacement for MIDI.js soundfont loader (MIDI.js is much bigger, capable of play midi files, for example, but it weights an order of magnitude more).". Therefore:
- By implementing the capability of playing MIDI files, we might partially revert to what MIDI.js does and thus again run into the problem that the first notes play too late. As a quick test, if you use the
timeargument ofplay()orschedule()insoundfont-playerto program a melody where many instruments play fast in the beginning (for example playing fast scales), does the melody play with the correct rhythm? - What's lacking in
soundfont-playeris the loading of MIDI files. We could borrow that functionality from other projects than MIDI.js. For example:- from
timidity(which has problems playing MIDI files after reading them, but we would usesoundfont-playerto play them instead). - from
webaudio-tinysynth(which plays synthesizers but not SoundFonts, and currently is partially out of tune, but that's no problem because we would usesoundfont-playerinstead).
- from
Another thing: When I tried the official demo of MidiPlayerJS months ago, which uses soundfont-player, it had unstable playback, for example when switching quickly between windows. When I tried today, it seemed to use wrong instruments and the rhythm didn't seem perfect. I wonder whether that problem is due to MidiPlayerJS or soundfont-player. It might be due to soundfont-player because that webpage says "This MIDI player was built using MidiPlayerJS to read the file, and soundfont-player to load and play the sounds". I also wonder whether those are the fatal flaws that @urobot2011 mentioned at mudcube/MIDI.js#268 (comment) and grimmdude/MidiPlayerJS#94, or whether @urobot2011 meant another one.
I wonder what the change was compared to MIDI.js that affected the timing.