I want to play very basic sounds using the AudioKit oscillator at a given frequency.
For example: play a simple sine wave at 400Hz for 50 miliseconds, then 100 ms of silence, then play 600Hz for 50ms …
I have a metal view where I render some visual stimuli. My intention was to use the basic AKOscillator and the render function of the CADisplayLink to play/stop the sound at some frames.
I tried using oscillator.play()
and oscillator.stop()
or changing the amplitude with oscillator.amplitude = 0
and oscillator.amplitude = 1
but the result in both cases is a jittering of about 10 ms.
If I first create .wav files and then played them with AKPlayer.play()
the timing is correct.
I want the flexibility to use any frequency at any time. How can I do something similar to the first approach? Wrapping the oscillator in an midi instrument is the way to go?