From 03341dc80be3f13a659149a810f0a4ed67945265 Mon Sep 17 00:00:00 2001 From: Eugene Petkevich Date: Mon, 16 May 2022 20:54:20 +0300 Subject: [PATCH] =?utf8?q?Reorganize=20=D0=A5=D1=8D=D0=B7=D0=B8=D1=84?= =?utf8?q?=D1=83=20into=20supercollider-toolset?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- server.scd => startup.scd | 0 ...\201-\320\235\321\215\321\206\321\215.scd" | 0 .../bcr2000-control.scd" | 0 .../melody.scd" | 0 .../mix101-control.scd" | 23 ++ .../pedal-control.scd" | 0 .../pipelines.scd" | 0 .../push-control.scd" | 0 .../sampler.scd" | 0 .../sl25remote-control.scd" | 331 ++++++++++++++++++ .../test.scd" | 0 .../test2.scd" | 0 .../\320\235\320\265\320\267\321\213.scd" | 39 +++ 13 files changed, 393 insertions(+) rename server.scd => startup.scd (100%) rename "33.7.3.2-\321\201-\320\235\321\215\321\206\321\215.scd" => "\320\245\321\215\320\267\320\270\321\204\321\203/33.7.3.2-\321\201-\320\235\321\215\321\206\321\215.scd" (100%) rename bcr2000-control.scd => "\320\245\321\215\320\267\320\270\321\204\321\203/bcr2000-control.scd" (100%) rename melody.scd => "\320\245\321\215\320\267\320\270\321\204\321\203/melody.scd" (100%) create mode 100644 "\320\245\321\215\320\267\320\270\321\204\321\203/mix101-control.scd" rename pedal-control.scd => "\320\245\321\215\320\267\320\270\321\204\321\203/pedal-control.scd" (100%) rename pipelines.scd => "\320\245\321\215\320\267\320\270\321\204\321\203/pipelines.scd" (100%) rename push-control.scd => "\320\245\321\215\320\267\320\270\321\204\321\203/push-control.scd" (100%) rename sampler.scd => "\320\245\321\215\320\267\320\270\321\204\321\203/sampler.scd" (100%) create mode 100644 "\320\245\321\215\320\267\320\270\321\204\321\203/sl25remote-control.scd" rename test.scd => "\320\245\321\215\320\267\320\270\321\204\321\203/test.scd" (100%) rename test2.scd => "\320\245\321\215\320\267\320\270\321\204\321\203/test2.scd" (100%) create mode 100644 "\320\245\321\215\320\267\320\270\321\204\321\203/\320\235\320\265\320\267\321\213.scd" diff --git a/server.scd b/startup.scd similarity index 100% rename from server.scd rename to startup.scd diff --git "a/33.7.3.2-\321\201-\320\235\321\215\321\206\321\215.scd" "b/\320\245\321\215\320\267\320\270\321\204\321\203/33.7.3.2-\321\201-\320\235\321\215\321\206\321\215.scd" similarity index 100% rename from "33.7.3.2-\321\201-\320\235\321\215\321\206\321\215.scd" rename to "\320\245\321\215\320\267\320\270\321\204\321\203/33.7.3.2-\321\201-\320\235\321\215\321\206\321\215.scd" diff --git a/bcr2000-control.scd "b/\320\245\321\215\320\267\320\270\321\204\321\203/bcr2000-control.scd" similarity index 100% rename from bcr2000-control.scd rename to "\320\245\321\215\320\267\320\270\321\204\321\203/bcr2000-control.scd" diff --git a/melody.scd "b/\320\245\321\215\320\267\320\270\321\204\321\203/melody.scd" similarity index 100% rename from melody.scd rename to "\320\245\321\215\320\267\320\270\321\204\321\203/melody.scd" diff --git "a/\320\245\321\215\320\267\320\270\321\204\321\203/mix101-control.scd" "b/\320\245\321\215\320\267\320\270\321\204\321\203/mix101-control.scd" new file mode 100644 index 0000000..8cc1eb5 --- /dev/null +++ "b/\320\245\321\215\320\267\320\270\321\204\321\203/mix101-control.scd" @@ -0,0 +1,23 @@ +( +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; +}); +) \ No newline at end of file diff --git a/pedal-control.scd "b/\320\245\321\215\320\267\320\270\321\204\321\203/pedal-control.scd" similarity index 100% rename from pedal-control.scd rename to "\320\245\321\215\320\267\320\270\321\204\321\203/pedal-control.scd" diff --git a/pipelines.scd "b/\320\245\321\215\320\267\320\270\321\204\321\203/pipelines.scd" similarity index 100% rename from pipelines.scd rename to "\320\245\321\215\320\267\320\270\321\204\321\203/pipelines.scd" diff --git a/push-control.scd "b/\320\245\321\215\320\267\320\270\321\204\321\203/push-control.scd" similarity index 100% rename from push-control.scd rename to "\320\245\321\215\320\267\320\270\321\204\321\203/push-control.scd" diff --git a/sampler.scd "b/\320\245\321\215\320\267\320\270\321\204\321\203/sampler.scd" similarity index 100% rename from sampler.scd rename to "\320\245\321\215\320\267\320\270\321\204\321\203/sampler.scd" diff --git "a/\320\245\321\215\320\267\320\270\321\204\321\203/sl25remote-control.scd" "b/\320\245\321\215\320\267\320\270\321\204\321\203/sl25remote-control.scd" new file mode 100644 index 0000000..000712e --- /dev/null +++ "b/\320\245\321\215\320\267\320\270\321\204\321\203/sl25remote-control.scd" @@ -0,0 +1,331 @@ +// Novation SL25 Remote handler +// by Eugene Zuelum +// +// see https://github.com/Ableton/push-interface for info about ABI: +// https://github.com/Ableton/push-interface/blob/master/doc/AbletonPush2MIDIDisplayInterface.asc + +( +~pushFactory = { + var dest; + var push = Environment[ + \version -> "33.7.2.5", + + \tempo -> 2, + + \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, { + args[0] = args[0] - 128; + }); + args; + }, + + // preprocess absolute controls and notes + \ppca -> { |zi ...args| + args[0] = args[0].linlin(0, 127, 0, 1); + args; + }, + + // preprocess bend + \ppcb -> { |zi ...args| + if (args[0] >= 8192, { + args[0] = args[0].linlin(8192, 16383, 0, 1); + }, { + args[0] = args[0].linlin(0, 8192, -1, 0); + }); + args; + }, + + // preprocess push color + \pppc -> {|zi, c=0,l=3,w=false| + var color; + c = zi.padColor[c] ? c; + if (c == 0, { + color = l; + },{ + if (l == 0, { + color = 0; + }, { + if (w, { + color = c*4; + }, { + color = c*4 + 4 - l; + }); + }); + }); + color; + }, + + \hcPushTurnN -> Array.newClear(9), + \hcPushTouchN -> Array.newClear(9) + ]; + + push.know = true; + + push.controllerFuncs = [ + // Rotators + MIDIFunc.cc({ |...args| + push.hcPushTurnS(*push.ppcr(*args)); + }, 14, 0), + MIDIFunc.cc({ |...args| + push.hcPushTurnL(*push.ppcr(*args)); + }, 15, 0), + MIDIFunc.cc({ |...args| + var col = args[1] - 71; + push.hcPushTurnN[col].value(*push.ppcr(*args)); + }, + (71..79), 0), + MIDIFunc.noteOn({ |...args| + push.hcPushTouchS(true, *args); + + }, 10, 0), + MIDIFunc.noteOn({ |...args| + push.hcPushTouchL(true, *args); + + }, 9, 0), + MIDIFunc.noteOn({ |...args| + //args[1] = args[1] - 71; + push.hcPushTouchN[args[1]].value(true, *args); + }, + (0..8), 0), + MIDIFunc.noteOff({ |...args| + push.hcPushTouchS(false, *args); + + }, 10, 0), + MIDIFunc.noteOff({ |...args| + push.hcPushTouchL(false, *args); + + }, 9, 0), + MIDIFunc.noteOff({ |...args| + args[1] = args[1] - 71; + push.hcPushTouchN[args[1]].value(false, *args); + }, + (0..8), 0), + + // Left buttons + MIDIFunc.cc({ |...args| + if (args[0] == 127, { + push.playDown(*args); + }, { + push.playUp(*args); + }); + }, 85, 0), + MIDIFunc.cc({ |...args| + if (args[0] == 127, { + push.recDown(*args); + }, { + push.recUp(*args); + }); + }, 86, 0), + + // Pads + MIDIFunc.noteOn({ |...args| + var note, row, col; + note = args[1] - 36; + col = note % 8; + row = (note/ 8).asInteger; + push.padDown(row, col, *push.ppca(*args)); + }, + (36..99), 0), + + MIDIFunc.noteOff({ |...args| + var note, row, col; + note = args[1] - 36; + col = note % 8; + row = (note/ 8).asInteger; + push.padUp(row, col, *push.ppca(*args)); + }, (36..99), 0), + + MIDIFunc.polytouch({ |...args| + var note, row, col; + note = args[1] - 36; + col = note % 8; + row = (note/ 8).asInteger; + push.padPressure(row, col, *push.ppca(*args)); + }, (36..99), 0), + ]; + + //============================== Binding hc to synth parameters + + push.bindMul = { |zi, synth, param, divisor=1| + { |d| + synth.get(param, { |v| + var newVal = v*((d)/divisor).midiratio; + "%: % = %\n".postf(synth, param, newVal); + synth.set(param, newVal); + }); + } + }; + + push.bindAdd = { |zi, synth, param, divisor=1| + { |d| + synth.get(param, { |v| + var newVal = v+(d/divisor); + "%: % = %\n".postf(synth, param, newVal); + synth.set(param, newVal); + }); + } + }; + + push.bindRange = { |zi, synth, param, start, end| + { |v| + var newVal = v.linlin(0, 1, start, end); + "%: % = %\n".postf(synth, param, newVal); + synth.set(param, newVal); + } + }; + + //============================== LED control + dest = MIDIClient.destinations.detect({ |item| + var res = false; + if (item.device == "Ableton Push", { + if (item.name == "Ableton Push MIDI 2", { + res = true; + }); + if (item.name == "User Port", { + res = true; + }); + }); + res; + }); + push.pushOut = MIDIOut.newByName(dest.device, dest.name); + // The following is working by itself, + // but factory function assignment to global var + // returns nil + /*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.padLight = {|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)); + }); + }; + + push.hcPushPadLedClear = { |zi| + for (0, 7, {|i| + for (0, 7, {|j| + zi.hcPushPadLed.value(i, j, 0); + }); + }); + }; + + push.freeHC = { |zi| + zi.controllerFuncs.do({ |item| item.free; }); + zi.pushOut.free; + }; + + // todo — always send clocks, and separate start/stop from setting tempod + push.setTempo = { |zi, tempo| + { + zi.pushOut.start; + 1.do({ + 24.do({ + zi.pushOut.midiClock; + (1.0/zi.tempo/24).wait; + }); + }); + zi.pushOut.stop; + }.fork(); + }; + + // Starter message and animation + + { + (0..127).do({|i| + ~push.pushOut.noteOn(0, i, 1); + ~push.pushOut.control(0, i, 1); + }); + 1.wait; + (0..127).do({|i| + ~push.pushOut.noteOn(0, i, 0); + ~push.pushOut.control(0, i, 0); + }); + }.fork(); + + "Џяпюӈи готов к использованию 😊".postln; + + push; +}; +) + +//============================================================================= 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; +}); +}); +) +*/ diff --git a/test.scd "b/\320\245\321\215\320\267\320\270\321\204\321\203/test.scd" similarity index 100% rename from test.scd rename to "\320\245\321\215\320\267\320\270\321\204\321\203/test.scd" diff --git a/test2.scd "b/\320\245\321\215\320\267\320\270\321\204\321\203/test2.scd" similarity index 100% rename from test2.scd rename to "\320\245\321\215\320\267\320\270\321\204\321\203/test2.scd" diff --git "a/\320\245\321\215\320\267\320\270\321\204\321\203/\320\235\320\265\320\267\321\213.scd" "b/\320\245\321\215\320\267\320\270\321\204\321\203/\320\235\320\265\320\267\321\213.scd" new file mode 100644 index 0000000..d456cc9 --- /dev/null +++ "b/\320\245\321\215\320\267\320\270\321\204\321\203/\320\235\320\265\320\267\321\213.scd" @@ -0,0 +1,39 @@ +~se = ~samplerFactory.value; +( +//(note: 9, octave: 5).play; +~se.startRec; +) +~se.stopRec; + +~se.shiftPos(0.05); +~se.duration = ~se.duration + 0.2; +~se.playSample; + +( +Pdef(\stae, Pbind( + \octave, Pxrand([3, 4], inf), + \note, Prand([0, 2, 4], inf), + \dur, Pwrand([ + Pseq([1], 1), + Pseq(0.5!2, 1), + Pseq(0.25!4, 1), + ], [1, 1, 1].normalizeSum, inf), + \db, -3, + \duration, Pwhite(0.1, 0.2), +) <> ~se.makeSynthBind).quant_(4).stop; +) + +( +Pdef(\steio, Pbind( + \octave, 5, + \note, Prand([0, 2, 4, 7, 9], inf), + \dur, Pwrand([ + Pseq([3, 3, 2]/2, 1), + ], [1].normalizeSum, inf), + \db, -15, + \duration, Pwhite(0.5, 2), + \startpos, Pwhite(1, 2.0), +) <> ~se.makeSynthBind).quant_(4).stop; +) + +TempoClock.tempo = 2; \ No newline at end of file -- 2.17.1