New
Apps 6,353Makers 6,332This week 13
Promote your app−30%
4views in
the last 30 days

MidiPlayerJS

MIDI parser & player engine for browser or Node

Built with Claude Code

by grimmdude · Unclaimed · from USUnited States · added Nov 3, 2026
no ratings0 comments

♬ 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

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

http://grimmdude.com/MidiPlayerJS/docs/

Description taken from the repository README.

Ratings

–
0 ratings
5 0
4 0
3 0
2 0
1 0

Rate this app

Sign in to rate

Comments 0

Sign in to comment

No comments yet.

Related apps

#music · #javascript