-
Notifications
You must be signed in to change notification settings - Fork 59
Play MIDI files #107
Comments
Thank you for summarizing! |
To sum up several discussions: The only approach that works well so far (correct instruments, perfect rhythm, can play in the background) is the latest official branch of MIDI.js (named "abcjs"), except for the first seconds of the first time a song is played. That problem is described at mudcube/MIDI.js#268 (comment). Solving that seems like the most promising plan. Feel free to have a look into that. |
Thanks for your help! |
But when i click the 'play' button on my Kalimba-sheet-music-writer project the sound is fine (there is a little sound jitter but i don't mind that). |
@urobot2011 Hm, I'd like to play MIDI files without jitter. And regarding note durations, I suspect that some JavaScript MIDI players don't care about matching "Note On" MIDI messages with the respective "Note Off" messages. If you don't want to "reinvent" that matching, then apps that visualize that matching (for example as piano rolls) might serve as inspiration. Tag me at https://github.com/urobot2011/Kalimba-sheet-music-writer/discussions or so if you want me to list them and some of their properties. I don't know whether MidiPlayerJS performs that matching. https://musiclab.chromeexperiments.com/Piano-Roll/ (https://github.com/googlecreativelab/chrome-music-lab/tree/master/pianoroll) uses an interval tree to rewind the song efficiently. |
@page200 I looked at Color Piano and thought this might be possible with MIDI.JS. |
@urobot2011 Color Piano uses MIDI.js, but probably an old branch of MIDI.js that doesn't play all instruments correctly. (Color Piano only plays the piano.) As discussed at mudcube/MIDI.js#268, it seems more promosing to fix the first seconds of the new "abcjs" branch than the entire instrument support in the old "master" branch. |
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:time
argument ofplay()
orschedule()
insoundfont-player
to program a melody where many instruments play fast in the beginning (for example playing fast scales), does the melody play with the correct rhythm?soundfont-player
is the loading of MIDI files. We could borrow that functionality from other projects than MIDI.js. For example:timidity
(which has problems playing MIDI files after reading them, but we would usesoundfont-player
to play them instead).webaudio-tinysynth
(which plays synthesizers but not SoundFonts, and currently is partially out of tune, but that's no problem because we would usesoundfont-player
instead).Another thing: When I tried the official demo of
MidiPlayerJS
months ago, which usessoundfont-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 toMidiPlayerJS
orsoundfont-player
. It might be due tosoundfont-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.
The text was updated successfully, but these errors were encountered: