AudioKit: When to use AKOperationGenerator or AKOscillator?

631 Views Asked by At

When I want to build an Oscillator with AudioKit there are different ways to go. For example you can create an AKOperation within an AKOperationGenerator like

var osc = AKOperationGenerator { parameters in
       returnAKOperation.sawtoothWave(frequency: GeneratorSource.frequency)
)

but you could also create one with

var oscillator = AKOscillator(waveform: AKTable(.sawtooth))

What's the difference and when to choose what? Thnx!

1

There are 1 best solutions below

2
Aurelius Prochazka On BEST ANSWER

If you just want one oscillator, it makes sense just to use the AKOscillator node, but if you want to do more than one thing dynamically, operations get you a lot flexibility. For instance, in your operation you can create two operation oscillators - one to oscillator the frequency and a low rate (LFO) and the other to actually oscillate the audio rate signal. There a few playgrounds that highlight when to use operations like this one:

http://audiokit.io/playgrounds/Synthesis/FM%20Oscillator%20Operation/

and the others listed in the Operations section of

http://audiokit.io/playgrounds/Synthesis/