StaticrequestRequest access to MIDI devices from the browser. This must be called before using any other MIDI functionality.
StaticgetGet the current MIDI access status
The current access status
StatichasCheck if MIDI permissions have been granted without requesting access. This uses the Permissions API to query the current permission state.
Promise that resolves to true if MIDI permissions are granted, false otherwise
StaticsetStaticisCheck if MIDI processing is currently enabled
True if MIDI processing is enabled, false otherwise
StaticgetGet all available MIDI input devices
Array of MIDIInput objects representing connected input devices
StaticresetReset the HuMIDI library to its initial state. This clears all event handlers, resets access status, and clears device tracking. Useful for testing or when you need to reinitialize the library.
StaticonRegister an event handler for MIDI events
The MIDI event type to listen for
Function to call when the event occurs
MIDI channel to listen on (-1 for all channels, 0-15 for specific channels)
// Listen for note events on all channels
HuMIDI.on('noteon', (event) => {
console.log(`Note ${event.note} pressed with velocity ${event.velocity}`);
});
// Listen for note events on channel 1 only
HuMIDI.on('noteon', (event) => {
console.log(`Channel 1 note: ${event.note}`);
}, 1);
// Listen for input device connections
HuMIDI.on('inputconnected', (event) => {
console.log(`New device: ${event.input.name}`);
});
StaticoffRemove an event handler
The MIDI event type
The handler function to remove
MIDI channel the handler was registered for (-1 for all channels)
Staticunsubscribe
HuMIDI - A human-friendly MIDI library for the Web MIDI API
Provides a simple event-driven interface for working with MIDI input devices, including automatic device management, note tracking for stuck note prevention, and per-device enable/disable functionality.
Example: Basic Usage
Example: Device Management
Example: Channel-Specific Events