swiftaudiokit

How to ramp PlaygroundOscillator to value with AudioKit in Swift?


Is there a way to change the value (frequency, volume etc.) of an PlaygroundOscillator over time in AudioKit?

I have this code and would like to ramp the volume to 0 at the end, so that there is no click sound when the oscillator is stopped.

var audioEngine = AudioEngine()
var osc = PlaygroundOscillator()                        
audioEngine.output = osc
do {
    try audioEngine.start()
} catch {
    print("could not start audio engine")
}
osc.play()
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
    osc.stop()
}

I would like to do the same as in this question, but I couldn't find the Oscillator() class anymore, so I'm assuming it is deprecated.

Issue with AudioKit v5 oscillator frequency ramp


Solution

  • Unfortunately, the playground oscillator's parameters are not able to be ramped. It is a simple generator for playgrounds and tests. For anything more serious, you should use something like SoundpipeAudioKit on top of AudioKit.