Add bank and program callbacks
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Fri, 3 Jun 2022 12:58:50 +0000 (15:58 +0300)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Fri, 3 Jun 2022 12:58:50 +0000 (15:58 +0300)
extensions/classes/midiremotesl.sc

index 9e21a5e..db00b15 100644 (file)
@@ -19,6 +19,8 @@ MidiRemote25SL : MidiHandler {
   var <>mod;
   var <>touch;
   var <>tempo, bpm=127;
+  var <>bank;
+  var <>program;
 
   *new {|name='Novation SL25 ReMOTE MKII', midiNames=#["ReMOTE SL", "ReMOTE SL MIDI 1", "ReMOTE SL MIDI 1"], reveal=true|
     ^super.newCopyArgs(name, midiNames, reveal).midiInit.controlInit;
@@ -63,9 +65,19 @@ MidiRemote25SL : MidiHandler {
       );
     }, [94, 95], srcID: idin2);
 
+    // bank: always sends 0 to cc0, and then value to cc32
+    MIDIdef.cc((\bank++name).asSymbol, {|...args|
+      bank.value(args[0], *args);
+    }, 32, srcID: idin);
+
+    // program
+    MIDIdef.program((\program++name).asSymbol, {|...args|
+      program.value(args[0], *args);
+    }, srcID: idin);
+
     // initialize handlers with revealing code
     [
-      \key, \bend, \mod, \touch, \tempo,
+      \key, \bend, \mod, \touch, \tempo, \bank, \program
     ].do{|handlerName|
       this.perform((handlerName++\_).asSymbol, {|...args|
         this.noCallback(handlerName, *args);
@@ -76,7 +88,7 @@ MidiRemote25SL : MidiHandler {
 
   free {
     [
-      \keyDown, \keyUp, \bend, \mod, \touch, \tempo
+      \keyDown, \keyUp, \bend, \mod, \touch, \tempo, \bank, \program
     ].do{|prefix|
       var defName = (prefix ++ name).asSymbol;
       MIDIdef(defName).free;