-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (29 loc) · 979 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*'use strict';
const Launchpad = require( 'launchpad-mini' ),
pad = new Launchpad();
pad.connect().then( () => { // Auto-detect Launchpad
pad.reset( 2 ); // Make Launchpad glow yellow
pad.on( 'key', k => {
pad.col( pad.red, k ); // Turn on buttons on press
} );
} );*/
var midi = require('midi');
// Set up a new input.
var input = new midi.input();
var launch = new midi.output();
// Count the available input ports.
var i = input.getPortCount()
for(a=0;a<i;a++){
console.log(input.getPortName(a));
}
launch.openPort(1);
input.openPort(6);
// Configure a callback.
input.on('message', function(deltaTime, message) {
// The message is an array of numbers corresponding to the MIDI bytes:
// [status, data1, data2]
// https://www.cs.cf.ac.uk/Dave/Multimedia/node158.html has some helpful
// information interpreting the messages.
console.log('m:' + message + ' d:' + deltaTime);
launch.sendMessage(message);
});