Created
June 20, 2020 04:36
-
-
Save lannonbr/884287173d5967438757a9ce1f687881 to your computer and use it in GitHub Desktop.
easymidi example w/ Launchpad Mini MK3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const easyMidi = require("easymidi"); | |
const launchpadInput = new easyMidi.Input( | |
"Launchpad Mini MK3 LPMiniMK3 MIDI Out" | |
); | |
const launchpadOutput = new easyMidi.Output( | |
"Launchpad Mini MK3 LPMiniMK3 MIDI In" | |
); | |
launchpadInput.on("noteon", function (msg) { | |
console.log(msg); | |
if (msg.velocity === 127) { // key is pressed down | |
const color = Math.floor(Math.random() * 128); | |
for (let i = 36; i < 100; i++) { // bottom left is note 36, top right is note 99 | |
setTimeout(() => { | |
launchpadOutput.send("noteon", { | |
note: i, | |
velocity: color, // velocity for a MIDI out on the launchpad turns the key a specific color between 0 and 127. Color chart for newer Launchpads here: http://www.launchpadfun.com/downloads/Velocity-Colors_MASTER_PICTURE_hires.png | |
channel: 0, | |
}); | |
}, i * 10); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment