node-midi icon indicating copy to clipboard operation
node-midi copied to clipboard

Electron usage

Open dirkk0 opened this issue 1 year ago • 0 comments

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.

dirkk0 avatar May 28 '23 08:05 dirkk0