From f2abf76277127d6690711ea75f58b177f5bf2dfd Mon Sep 17 00:00:00 2001 From: Eugene Petkevich Date: Sat, 7 May 2022 11:22:38 +0300 Subject: [PATCH] Try making cross-platfrom using exception (not working) --- push-control.scd | 51 ++++++++++++++++++++++++------------------------ test.scd | 26 ++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/push-control.scd b/push-control.scd index be0d937..f0b0a64 100644 --- a/push-control.scd +++ b/push-control.scd @@ -177,14 +177,16 @@ }; //============================== LED control - MIDIClient.destinations.do({ |item| - if (item.name == "Ableton Push MIDI 2", { - push.pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2").latency_(0); - }); - }); + try { + // linux + push.pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2"); + }{ + // mac os + push.pushOut = MIDIOut.newByName("Ableton Push", "User Port"); + }; + push.pushOut.latency_(0); if (push.pushOut==nil, {"Cannot control push LEDs!"}); - push.hcPushPadLed = {|zi, row, col, light=3, color=0, whiten=false, mode=0| if ((col < 0) || (col > 7) || (row < 0) || (row > 7), {}, { zi.pushOut.noteOn(mode, 36+(row*8)+col, zi.pppc(color, light, whiten)); @@ -213,25 +215,25 @@ /* Test incoming MIDI messages from push ( MIDIdef.cc(\testcc, {|...args| - (["cc"] ++ args).postln; +(["cc"] ++ args).postln; }); MIDIdef.noteOn(\testnoteon, {|...args| - (["note on"] ++ args).postln; +(["note on"] ++ args).postln; }); MIDIdef.noteOff(\testnoteoff, {|...args| - (["note off"] ++ args).postln; +(["note off"] ++ args).postln; }); MIDIdef.touch(\testtouch, {|...args| - (["touch"] ++ args).postln; +(["touch"] ++ args).postln; }); MIDIdef.polytouch(\testpolytouch, {|...args| - (["polytouch"] ++ args).postln; +(["polytouch"] ++ args).postln; }); MIDIdef.bend(\testbend, {|...args| - (["bend"] ++ args).postln; +(["bend"] ++ args).postln; }); MIDIdef.sysex(\testsysex, {|...args| - (["sysex"] ++ args).postln; +(["sysex"] ++ args).postln; }); ) */ @@ -242,12 +244,12 @@ MIDIdef.sysex(\testsysex, {|...args| ( ~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); - }); +~col = (~col + delta).clip(0, 127); +~col.postln; +(0..127).do({|i| +~push.pushOut.noteOn(0, i, ~col); +~push.pushOut.control(0, i, ~col); +}); }; ) */ @@ -256,13 +258,10 @@ MIDIdef.sysex(\testsysex, {|...args| ( ~color = 1; 8.do({|i| - 8.do({|j| - ~push.pushOut.noteOn(0, 36+(i*8)+j, ~color); - ~color = ~color + 1; - }); +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 diff --git a/test.scd b/test.scd index ba7f0d0..37c0aff 100644 --- a/test.scd +++ b/test.scd @@ -110,7 +110,7 @@ MIDIdef.freeAll; }; ) -~push.pushOut.midiClock +~push.pushOut m = MIDIClockOut("Ableton Push", "Ableton Push MIDI 2"); m.port @@ -118,4 +118,26 @@ Tempo.bpm = 300; m.stop -Tempo.default.bpm = 1; \ No newline at end of file +Tempo.default.bpm = 1; + +~pushOut = nil; + +( +try { + ~pushOut = MIDIOut.newByName("Ableton Push", "Ableton Push MIDI 2").latency_(0); +} { + ~pushOut = MIDIOut.newByName("Ableton Push", "User Port").latency_(0); +}; +) + +// test exception problem + +( +~factory = { + var ret; +try { Exception.new().throw; ret = 1; } { ret = 2 }; + ret; +}; +) + +~test = ~factory.value; \ No newline at end of file -- 2.17.1