Skip to content

Commit

Permalink
Merge pull request #157 from TimPietrusky/2.0
Browse files Browse the repository at this point in the history
feat(midi): Handle noteon and cc events on enable
  • Loading branch information
2xAA committed Jun 1, 2018
2 parents a9901f9 + ad064d6 commit 30b0b29
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/extra/midi-assignment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,31 @@ const midiAssignment = {
// the assignment is an internal control
const type = data[1];

// The "enable" button for the module
if (type === 'enable') {
const value = !!Math.round(Math.map(midiEvent.data[2], 0, 127, 0, 1));
store.commit('modVModules/setActiveModuleEnabled', {
moduleName,
enabled: value,
});
/*
* Only listen for On-events (button pressed)
*
* data[0] defines the specific MIDI "action" that gets triggered based
* on which type the MIDI element has (for example a button might have
* the type "Note"). Based on this we can handle different actions
*
* 1. Controlchange
* - 176 = This is a Controlchange event
* - 63 = Only listen for "button pressed", because this is the velocity
*
* 2. NoteOn
* - 144 = This is a NoteOn event
*/
if ((midiEvent.data[0] === 176 && midiEvent.data[2] > 63) || midiEvent.data[0] === 144) {
const module = store.getters['modVModules/getActiveModule'](moduleName);
const enabled = module.info.enabled;

store.commit('modVModules/setActiveModuleEnabled', {
moduleName,
enabled: !enabled,
});
}
} else if(type === 'alpha') { //eslint-disable-line
const value = Math.map(midiEvent.data[2], 0, 127, 0, 1);
store.commit('modVModules/setActiveModuleAlpha', {
Expand Down

0 comments on commit 30b0b29

Please sign in to comment.