User Tools

Site Tools


new_control_mapping_format

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
new_control_mapping_format [2015/08/04 14:18]
egasimus [Approach 3]
new_control_mapping_format [2015/08/04 14:34] (current)
egasimus [Approach 3]
Line 83: Line 83:
   MIDI.button([1,​ 2], '​mixer.kill.mid',​ 1, '​toggle'​),​   MIDI.button([1,​ 2], '​mixer.kill.mid',​ 1, '​toggle'​),​
   MIDI.button([1,​ 3], '​mixer.kill.lo', ​ 1, '​toggle'​),​   MIDI.button([1,​ 3], '​mixer.kill.lo', ​ 1, '​toggle'​),​
 +  ​
 +  MIDI.linear([1,​ 16], '​mixer.eq.hi'​),​
 +  MIDI.linear([1,​ 17], '​mixer.eq.mid'​),​
 +  MIDI.linear([1,​ 18], '​mixer.eq.lo'​),​
   ​   ​
   MIDI.encoder( ... ),   MIDI.encoder( ... ),
Line 108: Line 112:
 MIDI = { MIDI = {
   button: function (mask, event /* + optional arg1, arg2 ... argN */) {   button: function (mask, event /* + optional arg1, arg2 ... argN */) {
-    var args = [].slice.call(arguments, ​3); // gets list of optional arguments +    var args = [].slice.call(arguments, ​2); // gets list of optional arguments 
-    ​Events.on('​midi', ​function (midiMessage) {+    ​return ​function ​buttonPressed ​(midiMessage) {
       if (midiMessage.matches(mask)) {       if (midiMessage.matches(mask)) {
         Events.emit.apply(Events,​ [event].concat(args))         Events.emit.apply(Events,​ [event].concat(args))
         // that was a fancy way of saying `Events.emit(event,​ arg1, arg2 ... argN)`+         // that was a fancy way of saying `Events.emit(event,​ arg1, arg2 ... argN)`+
       }       }
-    });+    } 
 +  }, 
 +  linear: function (mask, event) { 
 +    var args = [].slice.call(arguments,​ 2); // gets list of optional arguments 
 +    return function potRotated (midiMessage) { 
 +      if (midiMessage.matches(mask)) { 
 +        Events.emit.apply(Events,​ [event].concat(args).concat([midiMessage.data2])); 
 +      } 
 +    }
   }   }
 } }
 +
 +// at the top of the chain sits a function which
 +// simply runs every received MIDI message through
 +// every registered MIDI handler.
 +Events.on('​midi.input',​ function (midiMessage) {
 +  Channel1.controls.map(function (control) { control(midiMessage);​ });
 +});
 </​code>​ </​code>​
  
-The event name can be parameterized too (have one event handler for `mixer.kill.*` and dispatch on event name), see https://​github.com/​asyncly/​EventEmitter2 for one nice implementation.+Event names can be parameterized too (have one event handler for `mixer.kill.*` and dispatch on event name), see https://​github.com/​asyncly/​EventEmitter2 for one nice implementation.
new_control_mapping_format.txt · Last modified: 2015/08/04 14:34 by egasimus