Skip to content

Instantly share code, notes, and snippets.

@TheWispy
Last active April 30, 2020 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheWispy/acf2ebb5ab1b178c387e6d5d49d6857f to your computer and use it in GitHub Desktop.
Save TheWispy/acf2ebb5ab1b178c387e6d5d49d6857f to your computer and use it in GitHub Desktop.
APC20 MIDI controller Hydra script
navigator.requestMIDIAccess()
.then(onMIDISuccess, onMIDIFailure);
function onMIDISuccess(midiAccess) {
console.log(midiAccess);
var inputs = midiAccess.inputs;
var outputs = midiAccess.outputs;
for (var input of midiAccess.inputs.values()){
input.onmidimessage = getMIDIMessage;
}
}
function onMIDIFailure() {
console.log('Could not access your MIDI devices.');
}
var cc=Array(256).fill(0.5).map(x => Array(256).fill(0.5));
getMIDIMessage = function(midiMessage) {
var arr = midiMessage.data;
var index_a = arr[0];
var index_b = arr[1];
var val = (arr[2]+1)/128.0;
console.log('Midi received on cc' + index_a + ' ,' + index_b + ' value:' + val);
cc[index_a][index_b] = val;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment