~pushFactory = {
var push = Environment[
\version -> "33.7.2.5",
+
+ \padColor -> IdentityDictionary[
+ \white -> 0,
+ \red -> 1,
+ \amber -> 2,
+ \yellow -> 3,
+ \lime -> 4,
+ \green -> 5,
+ \spring -> 6,
+ \turquoise -> 7,
+ \cyan -> 8,
+ \sky -> 9,
+ \ocean -> 10,
+ \blue -> 11,
+ \orchid -> 12,
+ \magenta -> 13,
+ \pink -> 14
+ ],
+
// preprocess relative controls
\ppcr -> { |zi ...args|
if (args[0] > 64, {
// preprocess push color
\pppc -> {|zi, c=0,l=3,w=false|
var color;
+ c = zi.padColor[c] ? c;
if (c == 0, {
color = l;
},{
push.controllerFuncs = [
// Rotators
MIDIFunc.cc({ |...args|
- push.hcPushTurnS.valueArray(push.ppcr.valueArray(args));
-
+ push.hcPushTurnS(*push.ppcr(*args));
}, 14, 0),
MIDIFunc.cc({ |...args|
- push.hcPushTurnL.valueArray(push.ppcr.valueArray(args));
-
+ push.hcPushTurnL(*push.ppcr(*args));
}, 15, 0),
MIDIFunc.cc({ |...args|
var col = args[1] - 71;
- push.hcPushTurnN[col].valueArray(push.ppcr.valueArray(args));
+ push.hcPushTurnN[col].value(*push.ppcr(*args));
},
(71..79), 0),
MIDIFunc.noteOn({ |...args|
- push.hcPushTouchS.valueArray(true, args);
+ push.hcPushTouchS(true, *args);
}, 10, 0),
MIDIFunc.noteOn({ |...args|
- push.hcPushTouchL.valueArray(true, args);
+ push.hcPushTouchL(true, *args);
}, 9, 0),
MIDIFunc.noteOn({ |...args|
//args[1] = args[1] - 71;
- push.hcPushTouchN[args[1]].valueArray(true, args);
+ push.hcPushTouchN[args[1]].value(true, *args);
},
(0..8), 0),
MIDIFunc.noteOff({ |...args|
- push.hcPushTouchS.valueArray(false, args);
+ push.hcPushTouchS(false, *args);
}, 10, 0),
MIDIFunc.noteOff({ |...args|
- push.hcPushTouchL.valueArray(false, args);
+ push.hcPushTouchL(false, *args);
}, 9, 0),
MIDIFunc.noteOff({ |...args|
args[1] = args[1] - 71;
- push.hcPushTouchN[args[1]].valueArray(false, args);
+ push.hcPushTouchN[args[1]].value(false, *args);
},
(0..8), 0),
// Left buttons
//============================== LED control
MIDIClient.destinations.do({ |item|
if (item.name == "Ableton Push MIDI 2", {
- push.pushOut = MIDIOut(0, item.uid).latency_(0);
+ push.pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2").latency_(0);
});
});
if (push.pushOut==nil, {"Cannot control push LEDs!"});
push;
};
-)
\ No newline at end of file
+)
+
+//============================================================================= Testing
+
+/* Test incoming MIDI messages from push
+(
+MIDIdef.cc(\testcc, {|...args|
+ (["cc"] ++ args).postln;
+});
+MIDIdef.noteOn(\testnoteon, {|...args|
+ (["note on"] ++ args).postln;
+});
+MIDIdef.noteOff(\testnoteoff, {|...args|
+ (["note off"] ++ args).postln;
+});
+MIDIdef.touch(\testtouch, {|...args|
+ (["touch"] ++ args).postln;
+});
+MIDIdef.polytouch(\testpolytouch, {|...args|
+ (["polytouch"] ++ args).postln;
+});
+MIDIdef.bend(\testbend, {|...args|
+ (["bend"] ++ args).postln;
+});
+MIDIdef.sysex(\testsysex, {|...args|
+ (["sysex"] ++ args).postln;
+});
+)
+*/
+
+/* Test all LED colors via rotaning left rotary control
+~push = ~pushFactory.value;
+~col = 0;
+
+(
+~push.hcPushTurnS = { |zi, delta|
+ ~col = (~col + delta).clip(0, 127);
+ ~col.postln;
+ (0..127).do({|i|
+ ~push.pushOut.noteOn(0, i, ~col);
+ ~push.pushOut.control(0, i, ~col);
+ });
+};
+)
+*/
+
+/* Show first 64 colors
+(
+~color = 1;
+8.do({|i|
+ 8.do({|j|
+ ~push.pushOut.noteOn(0, 36+(i*8)+j, ~color);
+ ~color = ~color + 1;
+ });
+});
+)
+*/
+
+MPush.lights.topRowColor.keys;
+MPush.lights.padColor.keys;
\ No newline at end of file
~push = ~pushFactory.value;
(
-~color = 0;
+~color = 64;
8.do({|i|
- 4.do({|j|
- ~push.hcPushPadLed(j+4, i, 3, ~color, true, 0);
+ 8.do({|j|
+ ~push.pushOut.noteOn(0, 36+(i*8)+j, ~color);
~color = ~color + 1;
});
});
~push.hcPushKeyOn.valueArray([1, 2, 3, 4]);
(
-~push.hcPushKeyOn = {|...args|
- args[1].postln;
+MIDIdef.cc(\testcc, {|...args|
+ (["cc"] ++ args).postln;
+});
+MIDIdef.noteOn(\testnoteon, {|...args|
+ (["note on"] ++ args).postln;
+});
+MIDIdef.noteOff(\testnoteoff, {|...args|
+ (["note off"] ++ args).postln;
+});
+MIDIdef.touch(\testtouch, {|...args|
+ (["touch"] ++ args).postln;
+});
+MIDIdef.polytouch(\testpolytouch, {|...args|
+ (["polytouch"] ++ args).postln;
+});
+MIDIdef.bend(\testbend, {|...args|
+ (["bend"] ++ args).postln;
+});
+MIDIdef.sysex(\testsysex, {|...args|
+ (["sysex"] ++ args).postln;
+});
+)
+
+MIDIdef.freeAll;
+
+(
+(0..127).do({|i|
+ ~push.pushOut.noteOn(15, i, 4);
+ //~push.pushOut.control(12, i, 3.choose);
+});
+)
+
+(
+~col = 38;
+(0..127).do({|i|
+ ~push.pushOut.noteOn(0, i, ~col);
+ ~push.pushOut.control(0, i, ~col);
+});
+)
+
+~push = ~pushFactory.value;
+~col = 0;
+
+(
+~push.hcPushTurnS = { |zi, delta|
+ ~col = (~col + delta).clip(0, 127);
+ ~col.postln;
+ (0..127).do({|i|
+ ~push.pushOut.noteOn(0, i, ~col);
+ ~push.pushOut.control(0, i, ~col);
+ });
};
-)
\ No newline at end of file
+)
+
+~push.pushOut.midiClock
+
+m = MIDIClockOut("Ableton Push", "Ableton Push MIDI 2");
+m.port
+Tempo.bpm = 300;
+
+m.stop
+
+Tempo.default.bpm = 1;
\ No newline at end of file