node-midi
node-midi copied to clipboard
Electron usage
Might be obvious but to use this with Electron-forge, you need to: a) insert this in the dependencies of package.json
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
"midi": "^2.0.0"
},
and yarn
to install it.
b) add this on one of the first lines of index.js
:
const midi = require('midi')
c) add this in the main loop of createWindow:
const input = new midi.Input();
for (let i = 0; i < input.getPortCount(); i++) {
console.log(i, input.getPortName(i))
}
input.on('message', (deltaTime, message) => {
console.log(`m: ${message} d: ${deltaTime}`);
});
input.openPort(1);
In my case the Launchpad was on index 1 and I could see the midi messages on the console.