sur
sur

Reputation: 345

Implementing Callback for AuAudioBuffer in AVAudioEngine

I recently watched the WWDC2014, Session on AVAudioEngine in practice, I have a question about the concept explained using AVAudioBuffers with NodeTap installed on the InputNode. Callback notification to the App outside the AudioEngine

The Speaker mentioned that, its possible to notify the App module using Callback. So my question is instead of Waiting for the callback until the buffer is full, is it possible to notify the app module after certain amount of time in ms. So once when the AVAudioEngine is started, is it possible to configure / register for Callback on this buffer for every 100 milliseconds of Recording. So that the App module gets notified to process this buffer for every 100ms. Have anyone tried this before. Let me know your suggestions on how to implement this. It would be great if you point out some resource for this logic. Thanks for your support in advance. -Suresh

Upvotes: 3

Views: 392

Answers (1)

Gordon Childs
Gordon Childs

Reputation: 36084

Sadly, the promising bufferSize argument of installTapOnBus which should let you choose a buffer size of 100ms:

input.installTapOnBus(bus, bufferSize: 512, format: input.inputFormatForBus(bus)) { (buffer, time) -> Void in
    print("duration: \(buffer.frameLength, buffer.format.sampleRate) -> \((Double)(buffer.frameLength)/buffer.format.sampleRate)s")
}

is free to be ignored,

the requested size of the incoming buffers. The implementation may choose another size.

and is:

duration: (16537, 44100.0) -> 0.374988662131519s

So for more control over your input buffer size/duration, I suggest you use CoreAudio's remote io audio unit.

Upvotes: 0

Related Questions