Static
requestRequest access to MIDI devices from the browser. This must be called before using any other MIDI functionality.
Static
getGet the current MIDI access status
The current access status
Static
hasCheck 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
Static
setStatic
isCheck if MIDI processing is currently enabled
True if MIDI processing is enabled, false otherwise
Static
getGet all available MIDI input devices
Array of MIDIInput objects representing connected input devices
Static
resetReset 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.
Static
onRegister 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}`);
});
Static
offRemove an event handler
The MIDI event type
The handler function to remove
MIDI channel the handler was registered for (-1 for all channels)
Static
unsubscribe
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