TheAmazingAudioEngine / TheAmazingAudioEngine2

The Amazing Audio Engine is a sophisticated framework for iOS audio applications, built so you don't have to.
http://theamazingaudioengine.com/doc2
Other
544 stars 87 forks source link

iOS forcing setPreferredIOBufferDuration #67

Closed Artaches closed 5 years ago

Artaches commented 5 years ago

I ran into a problem of frame sizes being a power of 2 on iOS (tested on iPhone 6+).

For example, setting setPreferredIOBufferDuration:0.01 in "TAAESample/Classes/AEAudioController.m" will result in a buffer size of 512 on the iPhone 6+ (sample rate is 44100), which is ~11.6ms of data vs the 10ms that I'd like the buffer to contain (so a buffer size of 441).

Is this possible? If so, how would I force each buffer duration to be the specified length? Basically, I'd like to get 10ms buffers of microphone data.

michaeltyson commented 5 years ago

This is a system limitation, nothing to do with TAAE. And no, I'm afraid this isn't possible.

aure commented 5 years ago

Seems related to this stack overflow question. Maybe you could shed some light on why we use powers of 2? https://stackoverflow.com/questions/58623318/can-i-set-bufferlength-other-than-a-power-of-two-in-audiokit/58631940#58631940

michaeltyson commented 5 years ago

Hey @aure =)

It's just because we're talking to hardware, and hardware generally deals in power-of-2-sizes. Sometimes you'll see a non-power of 2 size, and that's because there's a sample rate converter in the mix somewhere.

If one needs a specific number of frames for processing, a circular buffer is what you need (but it may introduce latency).