Created
March 18, 2018 05:09
-
-
Save Lokua/327ad141e69d9710293f855b88ce6399 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function listNodeMidiPorts(portType) { | |
const io = new require('midi')[portType]() | |
return Array(io.getPortCount()) | |
.fill(null) | |
.map((_, index) => io.getPortName(index)) | |
} | |
export function getNodeMidiPortNumberByName(portType, name) { | |
const io = new require('midi')[portType]() | |
const matches = str => | |
name instanceof RegExp ? name.test(str) : str === name | |
for (let i = 0; i < io.getPortCount(); i++) { | |
if (matches(io.getPortName(i))) { | |
return i | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment