Skip to content

Instantly share code, notes, and snippets.

@iccir
Created August 30, 2015 03:44
Show Gist options
  • Save iccir/f47e439fd3dc4536baa3 to your computer and use it in GitHub Desktop.
Save iccir/f47e439fd3dc4536baa3 to your computer and use it in GitHub Desktop.
MIDI Messages
// See chart at http://www.midi.org/techspecs/midimessages.php
function handleMIDIMessage(message)
{
var status = message.data[0];
var note = message.data[1];
var velocity = message.data[2];
var type = status >> 4;
var channel = status & 0xf;
if (type == 0x8) {
handleNoteOff(channel, note);
} else if (type == 0x9) {
handleNoteOn(channel, note, velocity);
} else if (type == 0xa) {
handleAftertouch(channel, note, velocity);
} else {
// ... handle other types here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment