hackmidi
v0.0.4
Published
MIDI playback for web browsers.
Downloads
7
Readme
Hackmidi
A JavaScript library to play MIDI files in Edge, Firefox, Safari, and Chrome.
A fork of midihackery. Powered by libtimidity. Used in Hacklily.
Installation
npm install hackmidi --save
Usage
import {playerFromMIDIBuffer} from "hackmidi";
fetch("Chop-28-4.mid")
.then(response => response.arrayBuffer())
.then(buffer => playerFromMIDIBuffer(buffer, "samples/"))
.then(player => {
player.addChangeListener((timeInSeconds, isPlaying) => {
console.log(timeInSeconds, isPlaying); // (0, false)
});
player.play();
// ...
player.pause();
// ...
player.seek(20.5 /* seconds */);
});