add factory method for mouse control
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Sun, 7 Jan 2024 01:17:58 +0000 (02:17 +0100)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Sun, 7 Jan 2024 01:17:58 +0000 (02:17 +0100)
library/controls.scd [new file with mode: 0644]
startup.scd
temp.scd

diff --git a/library/controls.scd b/library/controls.scd
new file mode 100644 (file)
index 0000000..4af5f7b
--- /dev/null
@@ -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
index aa898d1..f5d44b3 100644 (file)
@@ -32,6 +32,7 @@ c = (
 
 // synths
 "./library/mixer.scd".loadRelative;
+"./library/controls.scd".loadRelative;
 "./library/instruments.scd".loadRelative;
 "./library/effects.scd".loadRelative;
 
index c47f1ca..8a074eb 100644 (file)
--- 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