From 053353cf5c5f4071bca94698eedb3c30136e1d06 Mon Sep 17 00:00:00 2001 From: Eugene Petkevich Date: Fri, 3 Jun 2022 16:32:14 +0300 Subject: [PATCH] Add touchpad/fader/rotator handlers --- extensions/classes/midiremotesl.sc | 34 +++++++++++++++++++++++++----- extensions/classes/midisynths.sc | 2 +- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/extensions/classes/midiremotesl.sc b/extensions/classes/midiremotesl.sc index db00b15..1ced6b6 100644 --- a/extensions/classes/midiremotesl.sc +++ b/extensions/classes/midiremotesl.sc @@ -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; diff --git a/extensions/classes/midisynths.sc b/extensions/classes/midisynths.sc index dd6d63b..f693a30 100644 --- a/extensions/classes/midisynths.sc +++ b/extensions/classes/midisynths.sc @@ -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; }; -- 2.17.1