diff options
author | David Runge <dave@sleepmap.de> | 2017-05-01 00:10:18 +0200 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2017-05-01 00:10:18 +0200 |
commit | b2b6c92bd1dc0a1e1b5f4559378d05e3d4285d57 (patch) | |
tree | eab87fff0211f0390ed3d84b88a10517552dd4ed /classes | |
parent | df13df2257f98d98fa200a32fac94c043254e19f (diff) | |
download | zzz-b2b6c92bd1dc0a1e1b5f4559378d05e3d4285d57.tar.gz zzz-b2b6c92bd1dc0a1e1b5f4559378d05e3d4285d57.tar.bz2 zzz-b2b6c92bd1dc0a1e1b5f4559378d05e3d4285d57.tar.xz zzz-b2b6c92bd1dc0a1e1b5f4559378d05e3d4285d57.zip |
classes/ZZZ.sc: Removing unused classvar zzzSynth. using lincurve and curvelin in ampToVAC and vacToAmp (respectively) for the exponential part. Adding functions to calculate voltage from frequency and frequency from voltage.
Diffstat (limited to 'classes')
-rw-r--r-- | classes/ZZZ.sc | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/classes/ZZZ.sc b/classes/ZZZ.sc index a71b1c1..3f39357 100644 --- a/classes/ZZZ.sc +++ b/classes/ZZZ.sc @@ -6,8 +6,7 @@ ZZZ{ < cvMaxADSR = 8.0, < cvMinTriggerGateClock = 0.0, < cvMaxTriggerGateClock = 5.0, - < ampToVACConst = 6.8925, - < zzzSynth; + < ampToVACConst = 6.8925; var <channels; *new{ @@ -50,11 +49,7 @@ ZZZ{ if((amplitude <= 1.0), { voltage = amplitude * ampToVACConst; },{ - if((amplitude > 2.2), { - voltage = 2.2.log + ampToVACConst; - },{ - voltage = amplitude.log + ampToVACConst; - }); + voltage = amplitude.lincurve(1.0, 2.5, ampToVACConst, 7.7, -4, nil); }); voltage.postln; ^voltage; @@ -72,13 +67,44 @@ ZZZ{ if((voltage <= ampToVACConst), { amplitude = voltage/ampToVACConst; },{ - amplitude = (voltage-ampToVACConst).exp; - if(amplitude > 2.2, { - amplitude = 2.2; - }); + amplitude = voltage.curvelin(ampToVACConst, 7.7, 1.0, 2.5, -4, \max); }); amplitude.postln; ^amplitude; } + /** + * Calculates voltage for supplied frequency. + * Frequencies below 27.5Hz will return 0. + * @return voltage for corresponding frequency + */ + *hzToVAC{ + arg frequency; + var voltage; + if(frequency < 27.5, { + voltage = 0; + },{ + voltage = frequency.explin(55, 880, 1.0, 5.0, nil); + }); + voltage.postln; + ^voltage; + } + + /** + * Calculates frequency for supplied voltage. + * Voltages below 0 will return 27.5Hz + * @return frequency for corresponding voltage + */ + *vacToHz{ + arg voltage; + var frequency; + if(voltage < 0, { + frequency = 27.5; + },{ + frequency = voltage.linexp(1.0, 5.0, 55, 880, nil); + }); + frequency.postln; + ^frequency; + } + } |