ZZZ{ classvar 10.0, { ^(10.0); }); ^voltage; }); } /** * Calculates amplitude for supplied voltage. * Maximum: 1.0 * Minimum: -1.0 * @return amplitude needed to achieve the voltage supplied. */ *voltageamplitude{ arg voltage; var amplitude = 0.0; if((voltage == 0.0), { ^amplitude; },{ amplitude = voltage/10.0; if(amplitude < -1.0, { ^(-1.0); }); if(amplitude > 1.0, { ^(1.0); }); ^amplitude; }); } /** * Calculates voltage for supplied cycles per second. * @return voltage for corresponding cycles per second */ *cpsvoltage{ arg cps; if(cps < noteCpsRangeMin, { cps = noteCpsRangeMin; }); if(cps > noteCpsRangeMax, { cps = noteCpsRangeMax; }); ^cps.explin(noteCpsRangeMin, noteCpsRangeMax, noteVoltageRangeMin, noteVoltageRangeMax); } /** * Calculates cycles per second for supplied voltage. * @return cycles per second for corresponding voltage */ *voltagecps{ arg voltage; if(voltage < noteVoltageRangeMin, { voltage = noteVoltageRangeMin; }); if(voltage > noteVoltageRangeMax, { voltage = noteVoltageRangeMax; }); ^voltage.linexp(noteVoltageRangeMin, noteVoltageRangeMax, noteCpsRangeMin, noteCpsRangeMax); } /** * Calculates amplitude for supplied frequency. * @return amplitude for corresponding frequency */ *cpsamp{ arg cps; ^this.voltageamplitude(this.cpsvoltage(cps)); } /** * Calculates frequency for supplied amplitude. * Wraps call to ampToVAC -> vacToHz * @return frequency for corresponding amplitude */ *ampcps{ arg amplitude; ^this.voltagecps(this.amplitudevoltage(amplitude)); } }