Add touchpad/fader/rotator handlers
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Fri, 3 Jun 2022 13:32:14 +0000 (16:32 +0300)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Fri, 3 Jun 2022 13:32:14 +0000 (16:32 +0300)
extensions/classes/midiremotesl.sc
extensions/classes/midisynths.sc

index db00b15..1ced6b6 100644 (file)
@@ -8,6 +8,7 @@
 // 49..56 — pads
 // 64, 65 — pedals
 // 66 — joystick
+// 70, 71 — touchpad
 // 73..80 — upper right buttons
 // 81..88 — lower right buttons
 // 94, 95 — tempo change selector
@@ -17,10 +18,12 @@ MidiRemote25SL : MidiHandler {
   var <>key;
   var <>bend;
   var <>mod;
-  var <>touch;
+  var <>press;
   var <>tempo, bpm=127;
   var <>bank;
   var <>program;
+  var <>touchx, <>touchy;
+  var <>uprot, <>lowrot, <>fader;
 
   *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;
@@ -48,8 +51,8 @@ MidiRemote25SL : MidiHandler {
     }, 66, srcID: idin);
 
     // pressure
-    MIDIdef.touch((\touch++name).asSymbol, {|...args|
-      touch.value(args[0].linlin(0, 127, 0, 1), *args);
+    MIDIdef.touch((\press++name).asSymbol, {|...args|
+      press.value(args[0].linlin(0, 127, 0, 1), *args);
     }, srcID: idin);
 
     // tempo
@@ -75,9 +78,29 @@ MidiRemote25SL : MidiHandler {
       program.value(args[0], *args);
     }, srcID: idin);
 
+    // touchpad
+    MIDIdef.cc((\touchx++name).asSymbol, {|...args|
+      touchx.value(args[0].linlin(0, 127, 0, 1), *args);
+    }, 70, srcID: idin);
+    MIDIdef.cc((\touchy++name).asSymbol, {|...args|
+      touchy.value(args[0].linlin(0, 127, 0, 1), *args);
+    }, 71, srcID: idin);
+
+    // rotators and faders
+    MIDIdef.cc((\uprot++name).asSymbol, {|...args|
+      uprot.value(args[0]-64, args[1]-1, *args);
+    }, (1..8), srcID: idin);
+    MIDIdef.cc((\lowrot++name).asSymbol, {|...args|
+      lowrot.value(args[0].linlin(0, 127, 0, 1), args[1]-9, *args);
+    }, (9..16), srcID: idin);
+    MIDIdef.cc((\fader++name).asSymbol, {|...args|
+      fader.value(args[0].linlin(0, 127, 0, 1), args[1]-17, *args);
+    }, (17..24), srcID: idin);
+
     // initialize handlers with revealing code
     [
-      \key, \bend, \mod, \touch, \tempo, \bank, \program
+      \key, \bend, \mod, \press, \tempo, \bank, \program,
+      \touchx, \touchy, \uprot, \lowrot, \fader
     ].do{|handlerName|
       this.perform((handlerName++\_).asSymbol, {|...args|
         this.noCallback(handlerName, *args);
@@ -88,7 +111,8 @@ MidiRemote25SL : MidiHandler {
 
   free {
     [
-      \keyDown, \keyUp, \bend, \mod, \touch, \tempo, \bank, \program
+      \keyDown, \keyUp, \bend, \mod, \press, \tempo, \bank, \program,
+      \touchx, \touchy, \uprot, \lowrot, \fader
     ].do{|prefix|
       var defName = (prefix ++ name).asSymbol;
       MIDIdef(defName).free;
index dd6d63b..f693a30 100644 (file)
@@ -54,7 +54,7 @@ KeySynth {
 ~m = KeySynth(~kedi, \dyti, amp: 0.2, panAcross: true);
 (
 ~m.params[\modAmp] = 0.0;
-~kedi.touch_{|v|
+~kedi.press_{|v|
   ~m.group.set(\modAmp, v);
   ~m.params[\modAmp] = v;
 };