Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron usage #235

Open
dirkk0 opened this issue May 28, 2023 · 0 comments
Open

Electron usage #235

dirkk0 opened this issue May 28, 2023 · 0 comments

Comments

@dirkk0
Copy link

dirkk0 commented May 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant