Skip to content

Instantly share code, notes, and snippets.

@tnayuki
Created December 8, 2016 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnayuki/07580463ddd4e0cb6706e60fbd1166f1 to your computer and use it in GitHub Desktop.
Save tnayuki/07580463ddd4e0cb6706e60fbd1166f1 to your computer and use it in GitHub Desktop.
var midi = require('midi');
var getwild = [63, 61, 59, 63, 61, 59, 59, 59, 61, 63, 63, 64, 63, 59, 63, 63, 61, 59];
var output = new midi.output();
output.openPort(0);
var input = new midi.input();
input.openPort(0);
var count = 0;
output.sendMessage([0x90, getwild[0], 127]);
input.on('message', function(deltaTime, message) {
if (((message[0] & 0xf0) == 0x90 && message[2] == 0) || (message[0] & 0xf0 == 0x80) ) {
if (message[1] == getwild[count]) {
count = (count + 1) % getwild.length;
output.sendMessage([0x90, getwild[count], 127]);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment