I want to calculate pow() in the following context:
let generator = AKOperationGenerator { parameters in
let depth = PitchEnvVCO.freqDecayDepth.times(PitchEnvVCO.freqDecayAmount)
let wdth = pow(2.0, depth/12.0) * PitchEnvVCO.frequency // throws error
let ptch = AKOperation.exponentialSegment(
trigger: PitchEnvVCO.gate,
start: wdth,
end: PitchEnvVCO.frequency,
duration: PitchEnvVCO.freqDecayTime
)
let oscillator = AKOperation.squareWave(
frequency: ptch,
amplitude: PitchEnvVCO.amplitude.triggeredWithEnvelope(
trigger: PitchEnvVCO.gate,
attack: 0.01,
hold: 0.0,
release: PitchEnvVCO.ampDecayTime
)
)
return oscillator
}
and get the error
Cannot convert value of type 'AKOperation' to expected argument type 'Double'
I have build my generator like in the filter envelope example. How could I cast AKOperation to its Double Value? thnx!
After rethinking the concept I did the calculation outside the AKOperationGenerator and added more AKOperation.parameters to store the results: