1

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?

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
Torbilicious
  • 467
  • 1
  • 4
  • 17

1 Answers1

0

A bit late perhaps, but have a look at my answer in this thread:

AURenderCallback in Swift

Hope that helps you too.

Community
  • 1
  • 1
pbodsk
  • 6,787
  • 3
  • 21
  • 51