Add more arguments to synth
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Fri, 24 Mar 2023 21:22:27 +0000 (22:22 +0100)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Fri, 24 Mar 2023 21:22:27 +0000 (22:22 +0100)
Зясах-Мыҏиӈё.scd

index 6e83ffa..1ad4d43 100644 (file)
@@ -1,5 +1,5 @@
 (
-~synthGen = {|n=15, prefix=\fokyxiqa|
+~synthGen = {|n=25, prefix=\fokyxiqa, numHarm = 13|
   var synthNames = Array(n);
   n.do{|i|
     var synthName = (prefix ++ i.asString).asSymbol;
@@ -8,30 +8,37 @@
       freq = 440,
       attack = 0.01,
       release = 1.0,
+      distort = 0.0,
+      detuneMax=0.15
+      lowHarm = 2,
+      highHarm = 41,
+      harmMul = 1.3,
+      harmLen = 1.0,
       amp = 1,
       pan = 0,
       out = 0
       |
       var sig;
-      var num = 13;
-      var partial, detune, detuneMax=0.15, distort, ampEnv;
+      var partial, detune, distortMul, ampEnv;
       detune = Rand(detuneMax.neg, detuneMax).midiratio;
-      freq = freq * detune;
-      sig = SinOsc.ar(freq, 2pi.rand);
+      sig = SinOsc.ar(freq * detune, 2pi.rand);
       ampEnv = EnvGen.kr(Env.perc(attack, release), doneAction: 2);
       sig = sig * ampEnv;
-      num.do({
-        var pfact = rrand(2, 41);
-        partial = SinOsc.ar(freq * pfact, 2pi.rand);
+      numHarm.do({
+        var pfact = IRand(lowHarm, highHarm);
+        detune = Rand(detuneMax.neg, detuneMax).midiratio;
+        partial = SinOsc.ar(freq * detune * pfact, 2pi.rand);
         partial = partial * EnvGen.kr(
           Env.perc(attack, release),
-          levelScale: pfact.reciprocal * 1.3.rand,
-          timeScale: 1.0.rand * pfact.reciprocal,
+          levelScale: pfact.reciprocal * harmMul.rand,
+          timeScale: harmLen.rand * pfact.reciprocal,
         );
         sig = sig + partial;
       });
-      distort = 1 + (0.1 * ampEnv);
-      sig = (sig * distort).clip(-1, 1);
+      distortMul = 1 + (distort * ampEnv);
+      sig = (sig * distortMul).clip(-2, 2);
+      sig = HPF.ar(sig, 20);
+      sig = LPF.ar(sig, 16000);
       sig = Pan2.ar(sig, pan, amp);
       Out.ar(out, sig);
     }).add;
 };
 )
 
+(
+~reverbSynths.do{|item|
+  item.set(\mix, 0.2.rand);
+};
+)
+
 (
 ~tuning = Tuning.et(13);
 ~scale = Scale.new(#[0, 3, 5, 8, 10], 13, ~tuning);
@@ -127,12 +140,6 @@ Pdef(\liwarypo, Pbind(*[
 ])).quant_(3).stop;
 )
 
-(
-~reverbSynths.do{|item|
-  item.set(\mix, 0.2.rand);
-};
-)
-
 ////
 TempoClock.tempo = 1;
 
@@ -442,6 +449,12 @@ Pdef.all.do{|i| i.stop};
     pan: [pan.neg, pan],
     scale: Pn(~scale),
     octave: octave,
+    distort: 0,
+    detuneMax: 0.1,
+    lowHarm: 2,
+    highHarm: 51,
+    harmMul: 1.3,
+    harmLen: 1.0,
     #[\dur, \degree, \db, \attack, \release]: Pseq(
       beat, inf,
     ),
@@ -452,16 +465,15 @@ Pdef.all.do{|i| i.stop};
 
 (
 TempoClock.tempo = 1/4;
-thisThread.randSeed = 302;
+thisThread.randSeed = 1011;
 Pdef(2, ~makeBeatPat.(0.1, 2, -3-100)).quant_(4).play;
-Pdef(3, ~makeBeatPat.(0.2, 3, -3-100)).quant_(4).play;
-Pdef(4, ~makeBeatPat.(0.35, 4, -6-100)).quant_(4).play;
-Pdef(5, ~makeBeatPat.(0.5, 5, -14-100)).quant_(4).play;
-Pdef(6, ~makeBeatPat.(0.75, 6, -22-100)).quant_(4).play;
-Pdef(7, ~makeBeatPat.(0.9, 6, -21-100)).quant_(4).play;
+Pdef(3, ~makeBeatPat.(0.2, 3, -5-100)).quant_(4).play;
+Pdef(4, ~makeBeatPat.(0.35, 4, -12-100)).quant_(4).play;
+Pdef(5, ~makeBeatPat.(0.5, 5, -18-100)).quant_(4).play;
+Pdef(6, ~makeBeatPat.(0.75, 6, -30-100)).quant_(4).play;
+Pdef(7, ~makeBeatPat.(0.9, 7, -39-100)).quant_(4).play;
 )
 
 ////
 
-s.record(bus: a.h);
-
+s.record(bus: a.h);
\ No newline at end of file