Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save bspaulding/f9e1313880efb6fc406f347425d2a1e8 to your computer and use it in GitHub Desktop.

Select an option

Save bspaulding/f9e1313880efb6fc406f347425d2a1e8 to your computer and use it in GitHub Desktop.
var events = [];
function HandleMIDI(event) {
event.trace();
events.push(event);
if (events.length === 4) {
schedulePattern(events);
events = [];
}
}
var bpm = 90;
var sixteenthMs = 60000 / (bpm * 4);
function schedulePattern(events) {
var one = events[0];
var two = events[1];
var three = events[2];
var seven = events[3];
three.sendAfterMilliseconds(0);
two.sendAfterMilliseconds(sixteenthMs);
one.sendAfterMilliseconds(sixteenthMs * 2);
seven.sendAfterMilliseconds(sixteenthMs * 3);
one.sendAfterMilliseconds(sixteenthMs * 4);
two.sendAfterMilliseconds(sixteenthMs * 5);
three.sendAfterMilliseconds(sixteenthMs * 6);
two.sendAfterMilliseconds(sixteenthMs * 7);
three.sendAfterMilliseconds(sixteenthMs * 8);
two.sendAfterMilliseconds(sixteenthMs * 9);
one.sendAfterMilliseconds(sixteenthMs * 10);
seven.sendAfterMilliseconds(sixteenthMs * 11);
one.sendAfterMilliseconds(sixteenthMs * 12);
two.sendAfterMilliseconds(sixteenthMs * 13);
three.sendAfterMilliseconds(sixteenthMs * 14);
two.sendAfterMilliseconds(sixteenthMs * 15);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment