Add mix-101 midi control
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Sat, 21 May 2022 05:03:52 +0000 (08:03 +0300)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Sat, 21 May 2022 05:03:52 +0000 (08:03 +0300)
extensions/classes/midimix.sc [new file with mode: 0644]
Хэзифу/mix101-control.scd
Хэзифу/push-control.scd
Хэзифу/test.scd

diff --git a/extensions/classes/midimix.sc b/extensions/classes/midimix.sc
new file mode 100644 (file)
index 0000000..23fdb6d
--- /dev/null
@@ -0,0 +1,106 @@
+MidiMix {
+  const <version = "0.1";
+  const <name = \Mix101;
+  classvar ledValues;
+  classvar instance = nil;
+  var <midiout, <idin;
+  var <>caro;
+  var <>joro, <>viro, <>wipu, <>wire;
+  var <>sepu, <>sere;
+  var <>sewo, <>luwo, <>fewo, <>viwo;
+  var <>sypu, <>syre;
+
+  *new {
+   if (instance == nil) {
+      ledValues = IdentityDictionary[
+        \on ->  127,
+        \light -> 127,
+        true -> 127,
+        \off -> 0,
+        \dark -> 0,
+        false -> 0
+      ];
+      instance = super.new.prInit;
+    };
+    ^instance
+  }
+
+  prInit {
+    var dest = MIDIClient.destinations.detect({ |item|
+      item.device == "Mix-101"
+    });
+    if (dest == nil) {
+      Error("Cannot connect to DJ-Tech MIX-101").throw;
+    };
+    midiout = MIDIOut.newByName(dest.device, dest.name).latency_(0);
+    idin = MIDIClient.sources.detect{|i| i.device == "Mix-101"}.uid;
+
+    // MIDI out channel selector (back of the device)
+    // velocity is the channel
+    MIDIdef.noteOn(\caro+name, {|...args|
+      caro.value(*args);
+    }, 14, srcID: idin);
+
+    // == Jog wheel
+    // Start rotating
+    MIDIdef.noteOn(\wipu+name, {|...args|
+      wipu.value(*args);
+    }, 21, srcID: idin);
+    // Stop rotating
+    MIDIdef.noteOff(\wire+name, {|...args|
+      wire.value(*args);
+    }, 21, srcID: idin);
+    // Rotating in sampler/loop/fx mode
+    MIDIdef.cc(\joro+name, {|...args|
+      joro.value(*args);
+    }, 19, srcID: idin);
+    // Rotating in cue/vinyl mode
+    MIDIdef.cc(\viro+name, {|...args|
+      viro.value(*args);
+    }, 21, srcID: idin);
+
+    // == sync/select buttons
+    // select button pushed
+    MIDIdef.noteOn(\sepu+name, {|...args|
+      sepu.value(*args);
+    }, 5, srcID: idin);
+    // select button released
+    MIDIdef.noteOff(\sere+name, {|...args|
+      sere.value(*args);
+    }, 5, srcID: idin);
+    // sync button pushed
+    MIDIdef.noteOn(\sypu+name, {|...args|
+      sypu.value(*args);
+    }, 6, srcID: idin);
+    // sync button released
+    MIDIdef.noteOff(\syre+name, {|...args|
+      syre.value(*args);
+    }, 6, srcID: idin);
+    // sampler mode activated
+    MIDIdef.noteOn(\sewo+name, {|...args|
+      sewo.value(*args);
+    }, 17, srcID: idin);
+    // loop mode activated
+    MIDIdef.noteOn(\luwo+name, {|...args|
+      luwo.value(*args);
+    }, 18, srcID: idin);
+    // fx mode activated
+    MIDIdef.noteOn(\fewo+name, {|...args|
+      fewo.value(*args);
+    }, 19, srcID: idin);
+    // cue/vinyl mode activated
+    MIDIdef.noteOn(\viwo+name, {|...args|
+      viwo.value(*args);
+    }, 20, srcID: idin);
+  }
+
+  // == LED control
+  // pfl a
+  leda {|value=true|
+    value = ledValues[value] ? value;
+    (0..15).do {|i|
+      [i, value].postln;
+      midiout.noteOn(i, 1, value);
+    };
+  }
+}
\ No newline at end of file
index 8cc1eb5..40c8a9e 100644 (file)
@@ -20,4 +20,15 @@ MIDIdef.bend(\testbend, {|...args|
 MIDIdef.sysex(\testsysex, {|...args|
   (["sysex"] ++ args).postln;
 });
+)
+
+~mix = MidiMix();
+~mix.leda(127);
+~mout = MIDIOut.newByName("Mix-101", "Mix-101").latency_(0);
+~mout.noteOn(5, 1, 127);
+
+(
+~mix.joro = {|...args|
+  args.postln;
+};
 )
\ No newline at end of file
index c5d68a8..fdc2437 100644 (file)
 
   //============================== LED control
   dest = MIDIClient.destinations.detect({ |item|
+    // TODO: optimize
     var res = false;
     if (item.device == "Ableton Push", {
       if (item.name == "Ableton Push MIDI 2", {
index b3a16c4..b719154 100644 (file)
@@ -1,9 +1,20 @@
 (
 ~push = ~pushFactory.value;
-~se = Sampler.new(\qaxi);
+~se = Sampler(\qaxi);
 ~pe = ~pedalFactory.value;
 )
-Pxrand
+
+~se.avgSize = 1;
+~se.sampDiv = 50;
+
+~se.plotter.domainSpecs_([0, 1, \lin, 0, 0, "se"].asSpec;).refresh;
+a = ~se.plotter.value;
+b = a[..a.size-5].collect {|item, index|
+  item+a[index+1]+a[index+6];
+};
+~se.plotter.value=b;
+a = a.resamp1(500);
+
 (
 ~se.buf.loadToFloatArray(action: { |array|
   {
@@ -14,19 +25,22 @@ Pxrand
 });
 )
 
-~se.soundView.setData(~data, 1024, samplerate: ~se.buf.sampleRate);
+~se.plotter.specs = \bipolar.asSpec;
 
+~se.soundView.setData(~data, 1024, samplerate: ~se.buf.sampleRate);
 ~se.soundView.data
 
 (\freq: 220).play;
 
 ~se.makeSynthEvent
 ~se.makeSynthArgs
+
+
 (
 ~notes = Array.newClear(128);
 ~amps = Array.newClear(128);
 ~pe.suDown = { |zi|
-  ~se.startRec(true);
+  ~se.startRec(false);
 };
 ~pe.suUp = { |zi|
   ~se.stopRec;
@@ -326,4 +340,10 @@ Pdef(\samei, ~se2.makeSynthBind <> Pbind(
 )).quant_(4).stop;
 )
 
-{SinOsc.ar(440, mul: 0.2)}.play
\ No newline at end of file
+{SinOsc.ar(440, mul: 0.2)}.play
+
+(
+s.waitForBoot{
+    SSampler(\reel).load([Quarks.folder ++ "/SuperSampler/Testcode/Sounds/Reel Palindruome_44.1kHz_int16.aiff"]);
+}
+)