move startup stuff into separate files
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Thu, 4 Jan 2024 22:40:58 +0000 (23:40 +0100)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Thu, 4 Jan 2024 22:40:58 +0000 (23:40 +0100)
library/midi.scd [new file with mode: 0644]
library/samplers.scd
library/synths.scd [new file with mode: 0644]
startup.scd
Ка/Камыр-Хыпёдё/Хыпёдё-песня.scd

diff --git a/library/midi.scd b/library/midi.scd
new file mode 100644 (file)
index 0000000..d2acc39
--- /dev/null
@@ -0,0 +1,59 @@
+~midiup = {
+  MIDIClient.init;
+  MIDIIn.connectAll;
+};
+
+~midiup.value;
+
+Platform.case(
+  \osx, {
+    try {
+      ~moutArdour1 = MIDIOut.newByName("IAC Driver", "Bus 1").latency_(s.latency);
+      ~moutArdour2 = MIDIOut.newByName("IAC Driver", "Bus 2").latency_(s.latency);
+      ~moutArdour3 = MIDIOut.newByName("IAC Driver", "Bus 3").latency_(s.latency);
+      ~moutArdour4 = MIDIOut.newByName("IAC Driver", "Bus 4").latency_(s.latency);
+      ~moutFl = MIDIOut.newByName("IAC Driver", "Bus 5").latency_(s.latency);
+      ~moutAbleton = MIDIOut.newByName("IAC Driver", "Bus 6").latency_(s.latency);
+      ~moutHydrogen = MIDIOut.newByName("IAC Driver", "Bus 7").latency_(s.latency);
+      ~mout8 = MIDIOut.newByName("IAC Driver", "Bus 8").latency_(s.latency);
+    } {|error|
+      "Cannot connect to macbook midi out".postln;
+       error.throw;
+    };
+  },
+  \linux,     {  },
+  \windows,   {  }
+);
+
+m = (
+  arout1: ~moutArdour1,
+  arout2: ~moutArdour2,
+  arout3: ~moutArdour3,
+  arout4: ~moutArdour4,
+  about: ~moutAbleton,
+  flout: ~moutFl,
+  hyout: ~moutHydrogen,
+  out8: ~mout8
+);
+
+// hydrogen drum machine constants
+b = (
+  bass: 36,
+  side: 37,
+  snare: 38,
+  clap: 39,
+  rim: 40,
+  tomfloor: 41,
+  hatclosed: 42,
+  tomlow: 43,
+  hatpedal: 44,
+  tomhigh: 45,
+  hatopen: 46,
+  cowbell: 47,
+  ride: 48,
+  ccrash: 49,
+  ride2: 50,
+  splash: 51,
+  hatsemiopen: 52,
+  bell: 53,
+);
\ No newline at end of file
index 8356299..3edbe81 100644 (file)
@@ -1,6 +1,34 @@
-// use ~makeSampleSynths from startup.scd
+// use ~makeSampleSynths to load samples
+
+~makeSampleSynth = { arg name, sampleArray, sampleIndex, ampMultiplier;
+  SynthDef(name, {|out=0, rate=1, amp=1, pan=0|
+    var sig;
+    var buf = sampleArray[sampleIndex];
+    sig = PlayBuf.ar(2, buf, BufRateScale.kr(buf), doneAction: 2);
+    sig = sig * amp * ampMultiplier;
+    sig = Balance2.ar(sig[0], sig[1], pan);
+    Out.ar(out, sig);
+  }).add;
+};
+
+~loadSamples = { arg name, parentPath=nil;
+  var samples = Array();
+  var samplesPath = PathName(parentPath?(c.media) +/+ name);
+  samplesPath.entries.do({
+    arg path;
+    samples = samples.add(Buffer.read(s, path.fullPath));
+  });
+  samples
+};
+
+~makeSampleSynths = { arg name, params, parentPath=nil;
+  var samples = ~loadSamples.(name, parentPath);
+  params.do{|p, i|
+    ~makeSampleSynth.(p.name, samples, i, p.mul).value;
+  };
+  params.collect{|i| i.name}; // return instrument names
+};
 
-(
 // amplification coefficients for samples
 ~hahomo = (
   name: "Хахомо",
@@ -41,5 +69,4 @@
     name: \my,
     mul: 1,
   )];
-);
-)
\ No newline at end of file
+);
\ No newline at end of file
diff --git a/library/synths.scd b/library/synths.scd
new file mode 100644 (file)
index 0000000..83bfec3
--- /dev/null
@@ -0,0 +1,89 @@
+// This file contains synthesisers
+
+// reverbs
+
+SynthDef(\qahe, {|in, out=0, mix=0, t60=1.0, damp=0.0, size=1.0, earlyDiff=0.707, modDepth=0.1, modFreq=2.0, low=1.0,
+  mid=1.0, high=1.0, lowcut=500.0, highcut=2000.0|
+  var sig, rev;
+  sig = In.ar(in, 2);
+  rev = JPverb.ar(sig,
+    t60: t60,
+    damp: damp,
+    size: size,
+    earlyDiff: earlyDiff,
+    modDepth: modDepth,
+    modFreq: modFreq,
+    low: low,
+    mid: mid,
+    high: high,
+    lowcut: lowcut,
+    highcut: highcut);
+  Out.ar(out, sig + (mix * rev));
+}).add;
+
+// generators
+
+(
+~arraySynthGen = {|n=1, prefix=\testsynth, ugenFunc|
+  var synthNames = Array(n);
+  n.do{|i|
+    var synthName = (prefix ++ i).asSymbol;
+    synthNames = synthNames.add(synthName);
+    SynthDef(synthName, ugenFunc).add;
+  };
+  synthNames;
+};
+
+// marimba-glockenspiel like synth gen
+~fokyxiqaGen = {|
+  n=1,
+  prefix=\fokyxiqa,
+  numHarm = 13,
+  lowHarm = 2,
+  highHarm = 41,
+  harmMul = 1.3,
+  harmLen = 1.0
+  |
+  var synthNames = Array(n);
+  n.do{|i|
+    var synthName = (prefix ++ i.asString).asSymbol;
+    synthNames = synthNames.add(synthName);
+    SynthDef(synthName, {|
+      freq = 440,
+      attack = 0.01,
+      release = 1.0,
+      distort = 0.0,
+      detuneMax=0.15
+      amp = 1,
+      pan = 0,
+      out = 0
+      |
+      var sig;
+      var partial, detune, distortMul, ampEnv;
+      detune = Rand(detuneMax.neg, detuneMax).midiratio;
+      sig = SinOsc.ar(freq * detune, 2pi.rand);
+      ampEnv = EnvGen.kr(Env.perc(attack, release), doneAction: 2);
+      sig = sig * ampEnv;
+      numHarm.do({
+        var pfact = lowHarm.rand2(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 * harmMul.rand,
+          timeScale: harmLen.rand * pfact.reciprocal,
+        );
+        sig = sig + partial;
+      });
+      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;
+  };
+  synthNames;
+};
+
+)
\ No newline at end of file
index 2282fd4..ef2d2aa 100644 (file)
@@ -51,100 +51,17 @@ a = (
   e: 0, // external software input
 );
 
-// hydrogen drum machine constants
-b = (
-  bass: 36,
-  side: 37,
-  snare: 38,
-  clap: 39,
-  rim: 40,
-  tomfloor: 41,
-  hatclosed: 42,
-  tomlow: 43,
-  hatpedal: 44,
-  tomhigh: 45,
-  hatopen: 46,
-  cowbell: 47,
-  ride: 48,
-  ccrash: 49,
-  ride2: 50,
-  splash: 51,
-  hatsemiopen: 52,
-  bell: 53,
-);
-
 c = (
   media: "~/gart/media"
 );
 
 // ==== Samplers setup
 
-~makeSampleSynth = { arg name, sampleArray, sampleIndex, ampMultiplier;
-  SynthDef(name, {|out=0, rate=1, amp=1, pan=0|
-    var sig;
-    var buf = sampleArray[sampleIndex];
-    sig = PlayBuf.ar(2, buf, BufRateScale.kr(buf), doneAction: 2);
-    sig = sig * amp * ampMultiplier;
-    sig = Balance2.ar(sig[0], sig[1], pan);
-    Out.ar(out, sig);
-  }).add;
-};
-
-~loadSamples = { arg name, parentPath=nil;
-  var samples = Array();
-  var samplesPath = PathName(parentPath?(c.media) +/+ name);
-  samplesPath.entries.do({
-    arg path;
-    samples = samples.add(Buffer.read(s, path.fullPath));
-  });
-  samples
-};
-
-~makeSampleSynths = { arg name, params, parentPath=nil;
-  var samples = ~loadSamples.(name, parentPath);
-  params.do{|p, i|
-    ~makeSampleSynth.(p.name, samples, i, p.mul).value;
-  };
-
-  params.collect{|i| i.name}; // return instrument names
-};
+"./library/samplers.scd".loadRelative;
 
 // ==== Midi setup
-~midiup = {
-  MIDIClient.init;
-  MIDIIn.connectAll;
-};
-~midiup.value;
-
-Platform.case(
-  \osx, {
-    try {
-      ~moutArdour1 = MIDIOut.newByName("IAC Driver", "Bus 1").latency_(s.latency);
-      ~moutArdour2 = MIDIOut.newByName("IAC Driver", "Bus 2").latency_(s.latency);
-      ~moutArdour3 = MIDIOut.newByName("IAC Driver", "Bus 3").latency_(s.latency);
-      ~moutArdour4 = MIDIOut.newByName("IAC Driver", "Bus 4").latency_(s.latency);
-      ~moutFl = MIDIOut.newByName("IAC Driver", "Bus 5").latency_(s.latency);
-      ~moutAbleton = MIDIOut.newByName("IAC Driver", "Bus 6").latency_(s.latency);
-      ~moutHydrogen = MIDIOut.newByName("IAC Driver", "Bus 7").latency_(s.latency);
-      ~mout8 = MIDIOut.newByName("IAC Driver", "Bus 8").latency_(s.latency);
-    } {
-      "Cannot connect to macbook midi out".postln;
-    };
-  },
-  \linux,     {  },
-  \windows,   {  }
-);
 
-m = (
-  arout1: ~moutArdour1,
-  arout2: ~moutArdour2,
-  arout3: ~moutArdour3,
-  arout4: ~moutArdour4,
-  about: ~moutAbleton,
-  flout: ~moutFl,
-  hyout: ~moutHydrogen,
-  out8: ~mout8
-);
+"./library/midi.scd".loadRelative;
 
 // recording
 
index 1cd54b5..e2361c6 100644 (file)
     ).asPairs, ~effectGroup));
   };
 };
+~drawWindows = {
+  s.plotTree
+};
 ServerTree.add(~createGroupsBusses);
-ServerTree.add{s.plotTree};
+ServerTree.add(~drawWindows);
 )
 
 // test
@@ -106,7 +109,7 @@ ServerTree.add{s.plotTree};
 Pdef(\buben, Pbind(*[
   instrument: Prand([\bu, \bo, \be, \by], inf),
   db: -6,
-  dur: Pn(Pseq(2.split(3)++2.split(4), 4), 1),
+  dur: Pn(Pseq(2.split(3)++2.split(4), 4), inf),
   pan: Pwhite(-0.4, 0.4),
   out: ~reverbBuses[1],
 ])).quant_(4).play;
@@ -116,7 +119,7 @@ Pdef(\buben, Pbind(*[
 Pdef(\plate, Pbind(*[
   instrument: Prand([\me, \mo, \ma, \my], inf),
   db: -12,
-  dur: Pn(Pseq(2.split(4)++2.split(5), 4), 1),
+  dur: Pn(Pseq(2.split(4)++2.split(5), 4), inf),
   pan: Pwhite(-0.7, 0.7),
   out: Prand(~reverbBuses, inf),
 ])).quant_(4).play;
@@ -126,7 +129,7 @@ Pdef(\plate, Pbind(*[
 Pdef(\bass, Pbind(*[
   instrument: Prand([\da, \da], inf),
   db: -18,
-  dur: Pn(Pseq(2.split(2)++2.split(3), 4), 1),
+  dur: Pn(Pseq(2.split(2)++2.split(3), 4), inf),
   pan: Pwhite(-0.5, 0.5),
   out: Prand(~reverbBuses, inf),
 ])).quant_(4).play;
@@ -136,7 +139,7 @@ Pdef(\bass, Pbind(*[
 Pdef(\extra, Pbind(*[
   instrument: Prand([\tu, \nu], inf),
   db: -15,
-  dur: Pn(Pseq(4.split(5), 4), 1),
+  dur: Pn(Pseq(4.split(5), 4), inf),
   pan: Pwhite(-0.5, 0.5),
   out: Prand(~reverbBuses, inf),
 ])).quant_(4).play;