diff options
-rw-r--r-- | classes/ZZZ.sc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/classes/ZZZ.sc b/classes/ZZZ.sc index 662da36..a9f89f7 100644 --- a/classes/ZZZ.sc +++ b/classes/ZZZ.sc @@ -134,11 +134,39 @@ ZZZ{ /** * Calculates frequency for supplied amplitude. - * Wraps call to ampToVAC -> vacToHz * @return frequency for corresponding amplitude */ *ampcps{ arg amplitude; ^this.voltagecps(this.amplitudevoltage(amplitude)); } + + /** + * Calculates amplitude for supplied midi note. + * @return amplitude for corresponding midi note, nil if < 0 or > 127 + */ + *midiamp{ + arg midi; + if((midi < 0 ) || (midi >127), { + ^nil; + },{ + ^this.voltageamplitude(this.cpsvoltage(midi.midicps)); + }); + } + + /** + * Calculates midi note for supplied amplitude. + * @return midi note for corresponding amplitude, nil if amplitude is not + * within the allowed octave range + */ + *ampmidi{ + arg amplitude; + if((amplitude <= ((noteVoltageRangeMin+1)/10)) || (amplitude > (((noteVoltageRangeMax-1)+(1/12*7))/10)), { + ^nil; + },{ + ^this.voltagecps(this.amplitudevoltage(amplitude)).cpsmidi; + }); + } + + } |