aboutsummaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/ZZZ.sc48
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;
+ }
+
}