aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--classes/ZZZ.sc84
1 files changed, 84 insertions, 0 deletions
diff --git a/classes/ZZZ.sc b/classes/ZZZ.sc
new file mode 100644
index 0000000..a71b1c1
--- /dev/null
+++ b/classes/ZZZ.sc
@@ -0,0 +1,84 @@
+ZZZ{
+
+ classvar <cvMinLFO = -2.5,
+ < cvMaxLFO = 2.5,
+ < cvMinADSR = 0.0,
+ < cvMaxADSR = 8.0,
+ < cvMinTriggerGateClock = 0.0,
+ < cvMaxTriggerGateClock = 5.0,
+ < ampToVACConst = 6.8925,
+ < zzzSynth;
+ var <channels;
+
+ *new{
+ arg channels;
+ ^super.newCopyArgs(channels).init;
+ }
+
+ init{
+ ("Using the following channels:").postln;
+ channels.postln;
+ }
+
+ *initClass{
+ StartUp.add{
+ //adding synth for percussive environments (trigger, gate, clock)
+ SynthDef(\ZZZPerc, { |out = 0, freq = 20000, amp = 0.0, attack = 0.001, release = 1, time = 1, curve = -4|
+ var signal, envelope;
+ envelope = EnvGen.kr(Env.perc(attack, release, amp, curve), doneAction: 2);
+ signal = SinOsc.ar(freq, 0, envelope);
+ Out.ar(out, signal);
+ }).add;
+ // adding synth for note environments (adsr, v/o)
+ SynthDef(\ZZZHold, { |out = 0, freq = 20000, amp = 0.0|
+ var signal;
+ signal = SinOsc.ar(freq, 0, amp);
+ Out.ar(out, signal);
+ }).add;
+ }
+ }
+
+ /**
+ * Calculates voltage for supplied amplitude.
+ * Linear until ampToVACConst, exponential above.
+ * Maximum voltage: 7.68096 VAC
+ * @return voltage that corresponds to the amplitude supplied.
+ */
+ *ampToVAC{
+ arg amplitude;
+ var voltage;
+ if((amplitude <= 1.0), {
+ voltage = amplitude * ampToVACConst;
+ },{
+ if((amplitude > 2.2), {
+ voltage = 2.2.log + ampToVACConst;
+ },{
+ voltage = amplitude.log + ampToVACConst;
+ });
+ });
+ voltage.postln;
+ ^voltage;
+ }
+
+ /**
+ * Calculates amplitude for supplied voltage.
+ * Linear until ampToVACConst.
+ * Maximum amplitude output: 2.2
+ * @return amplitude needed to achieve the voltage supplied.
+ */
+ *vacToAmp{
+ arg voltage;
+ var amplitude;
+ if((voltage <= ampToVACConst), {
+ amplitude = voltage/ampToVACConst;
+ },{
+ amplitude = (voltage-ampToVACConst).exp;
+ if(amplitude > 2.2, {
+ amplitude = 2.2;
+ });
+ });
+ amplitude.postln;
+ ^amplitude;
+ }
+
+}