Skip to content

Instantly share code, notes, and snippets.

@GavinJoyce
Last active April 24, 2016 22:33
Show Gist options
  • Save GavinJoyce/f5059afa06619bc7341f8fb7275d03bf to your computer and use it in GitHub Desktop.
Save GavinJoyce/f5059afa06619bc7341f8fb7275d03bf to your computer and use it in GitHub Desktop.
Ableton Push
var midi = require('midi');
var input = new midi.input();
for(var i=0; i<input.getPortCount(); i++) {
console.log(`PORT ${i}: ${input.getPortName(i)}`);
}
----
var MidiStream = require('midi-stream');
var push = MidiStream('Ableton Push 2 User Port');
push.on('data', console.log);
push.write([144, 70, 100]);
push.write([144, 71, 101]);
push.write([144, 72, 102]);
push.write([144, 73, 103]);
--
var MidiStream = require('midi-stream');
var push = MidiStream('Ableton Push 2 User Port');
function write(data) {
console.log('WRITE', data);
push.write(data);
};
function play(channel, note, velocity, delay) {
setTimeout(() => write([channel, note, velocity]), delay);
}
for(var i=0; i<128; i++) {
for(var j=36; j<=99; j++) {
play(j, i, (i * 100) + (j*4));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment