From df13df2257f98d98fa200a32fac94c043254e19f Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 30 Apr 2017 19:36:14 +0200 Subject: classes/ZZZ.sc: Adding first version of base class for Expert Sleepers devices. The class functions ampToVAC and vacToAmp have been tested using a RME Babyface and the implemented ZZZHold SynthDef. Above an amplitude of 1.0 the output turns out to be logarithmic (ln), instead of linear, so anywhere above that should be used with caution, as the implemented calculation functions are only an approximation in that region. --- classes/ZZZ.sc | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 classes/ZZZ.sc (limited to 'classes') 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 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; + } + +} -- cgit v1.2.3-70-g09d2