grimmdude/MidiPlayerJS
grimmdude/MidiPlayerJS has 399 GitHub stars and 57 forks. GitHot measured +2 stars in 24 hours, +2 in 7 days, and +2 in 15 days. Last checked 2026-11-09 23:18 UTC. Last push 2026-06-22.
♬ MIDI parser & player engine for browser or Node. As a parser converts MIDI events into JSON. Works well with single or multitrack MIDI files.
Measured star growth
- in 24h
- +2
- in 7 days
- +2
- in 15 days
- +2
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Original♬ MidiPlayerJS
MidiPlayerJS is a JavaScript library which reads standard MIDI files and emits JSON events in real time. This player does not generate any audio, but by attaching a handler to the event emitter you can trigger any code you like which could play audio, control visualizations, feed into a MIDI interface, etc.
Demos
- Neopixel Music by robertvorthman @robertvorthman
- Autocomposer by RJ Salvador @rjsalvadorr
- Simple Browser Player by Garrett Grimm @grimmdude
- Orchestra by Daniel Alejandro Cast @lexcast
Getting Started
Using MidiPlayerJS is pretty simple. Create a new player by instantiating MidiPlayer.Player with an event handler to be called for every MIDI event. Then you can load and play a MIDI file.
import MidiPlayer from 'midi-player-js';
// Initialize player and register event handler
const Player = new MidiPlayer.Player(function(event) {
console.log(event);
});
// Load a MIDI file
Player.loadFile('./test.mid');
Player.play();
Player Events
There are a handful of events on the Player object which you can subscribe to using the Player.on() method. Some events pass data as the first argument of the callback as described below:
Player.on('fileLoaded', function() {
// Do something when file is loaded
});
Player.on('playing', function(currentTick) {
// Do something while player is playing
// (this is repeatedly triggered within the play loop)
});
Player.on('midiEvent', function(event) {
// Do something when a MIDI event is fired.
// (this is the same as passing a function to MidiPlayer.Player() when instantiating.
});
Player.on('endOfFile', function() {
// Do something when end of the file has been reached.
});
Note that because of a common practice called "running status" many MIDI files may use Note on events with 0 velocity in place of Note off events.
See Also
Need to generate MIDI files programmatically? Check out MidiWriterJS — a JavaScript library for creating expressive multi-track MIDI files. Together they form a complete MIDI toolkit:
- MidiPlayerJS — parse and play MIDI files with real-time event callbacks
- MidiWriterJS — generate MIDI files programmatically
Full API Documentation
Explore related projects
ytdl-org/youtube-dl
Command-line program to download videos from YouTube.com and other video sites
141,527 starsexcalidraw/excalidraw
Virtual whiteboard for sketching hand-drawn like diagrams
135,396 starsgodotengine/godot
Godot Engine – Multi-platform 2D and 3D game engine
119,942 starsmrdoob/three.js
JavaScript 3D Library.
117,983 stars