I am trying to build a Metronome for iOS in Swift. I am using NSTimers to trigger each click, but this is too unprecise. In various Forums people say, that i should register AURencerCallback.
Right now I have the following Code:
init()
{
let audioUnit:AudioUnit
AudioUnitInitialize(audioUnit)
AudioUnitAddRenderNotify(audioUnit, renderTone, self);
}
My Callback-Function:
func callback(
inRefCon:UnsafeMutablePointer<Void>,
ioActionFlags:UnsafeMutablePointer<AudioUnitRenderActionFlags>,
inTimeStamp:UnsafePointer<AudioTimeStamp>,
inBusNumber:UInt32,
inNumberFrames:UInt32,
ioData:UnsafeMutablePointer<AudioBufferList>) -> (OSStatus)
{
return 0;
}
Could someone please show what I need to do, or show me examples of working code?