Quick start

// Import MIDI functions as object
import * as MIDI from 'http://stephen.band/midi/midi.js';

// Listen to incoming 'noteon' and 'noteoff' messages on channel 1
MIDI.on({channel: 1, type: 'note'}, (e) => {
    // Time, port and message are properties of the DOM event
    const time    = e.timeStamp;
    const port    = e.target;
    const message = e.data;

    // Get the note name
    const name = MIDI.toNoteName(message[1]);

    // Normalise velocity to the range 0-1
    const velocity = MIDI.int7ToFloat(message[2]);
});

On this page, functions have been imported to the object window.MIDI so that you may play with them in the console.

Functions

// Import Soundstage
import Soundstage from 'http://stephen.band/soundstage/soundstage.js';

Soundstage()

Methods

.get(id)

Return the plugin with id, or undefined.

.timeAtDomTime(domTime)

Returns audio context time at a given DOM time, where domTime is a time in seconds relative to window.performance.now().