From c8e037ad80b2680168db788784f7e887c376c058 Mon Sep 17 00:00:00 2001 From: Eugene Petkevich Date: Sun, 7 Jan 2024 02:17:58 +0100 Subject: [PATCH] add factory method for mouse control --- library/controls.scd | 24 ++++++++++++++++++++++++ startup.scd | 1 + temp.scd | 9 ++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 library/controls.scd diff --git a/library/controls.scd b/library/controls.scd new file mode 100644 index 0000000..4af5f7b --- /dev/null +++ b/library/controls.scd @@ -0,0 +1,24 @@ +// factory methods for controllers + +~controllerNextNum = 1; +~controllers = []; + +~makeControlMouseGeneric = {|ugen, prefix| + {|min=0.0, max=1.0, warp=0| + var synthName = prefix ++ \_dejucyfu_ ++ ~controllerNextNum; + var bus = Bus.control; + synthName = synthName.asSymbol; + SynthDef(synthName, {|kout| + Out.kr(kout, ugen.kr(min, max, 1)); + }).add; + fork { + 0.5.wait; // to be sure synthdef is finalized on the server + ~controllers = ~controllers.add(Synth(synthName, [\kout, bus])); + }; + ~controllerNextNum = ~controllerNextNum + 1; + bus.asMap + } +}; + +~makeControlMouseX = ~makeControlMouseGeneric.(MouseX, \mousex); +~makeControlMouseY = ~makeControlMouseGeneric.(MouseY, \mousey); \ No newline at end of file diff --git a/startup.scd b/startup.scd index aa898d1..f5d44b3 100644 --- a/startup.scd +++ b/startup.scd @@ -32,6 +32,7 @@ c = ( // synths "./library/mixer.scd".loadRelative; +"./library/controls.scd".loadRelative; "./library/instruments.scd".loadRelative; "./library/effects.scd".loadRelative; diff --git a/temp.scd b/temp.scd index c47f1ca..8a074eb 100644 --- a/temp.scd +++ b/temp.scd @@ -59,11 +59,11 @@ Pdef(\temp3, Pbind(*[ dur: Pseq([3, 3, 2].split(4)/2, inf), release: Pwhite(0.5, 1.2)*TempoClock.tempo.reciprocal*0.2, legato: Pwhite(0.2, 0.4), - cut: ~testControl.asMap,//Pexprand(400, 3200), + cut: ~cont,//Pexprand(400, 3200), rez: Pwhite(0.6, 0.9), modFreqMin: 4, modFreqMax: 11, - modAmp: Pwhite(0.05, 0.1), + modAmp: ~conty, //Pwhite(0.05, 0.1), pan: Pwhite(-0.2, 0.2) * [-1, 1], out: a.h, ])).quant_(4).play; @@ -77,4 +77,7 @@ Pdef(\temp3, Pbind(*[ SynthDef(\testmouse, {|kout| Out.kr(kout, MouseX.kr(400, 12800, 1)); }).add; -) \ No newline at end of file +) + +~cont = ~makeControlMouseX.(200, 17000, 1); +~conty = ~makeControlMouseY.(0.001, 0.8, 0); \ No newline at end of file -- 2.17.1