Create a realtime AuAudioAudio with custom buffer size

I'm creating an effect. It can only process with a 2048 block size. The incoming frameCount to AUInternalRenderBlock is always 256, 512 or 1024.

How can I accumulate enough buffer for 2048 before I return from AUInternalRenderBlock? Or what is the trick to do so?

Thanks
Casper

Replies

One approach would be to preallocate a 2048-byte block (or larger, depending on your algorithm) as one of the audio unit's resources, and to process your data into that block.

When the render block is called, pull enough input to fill your 2048-byte buffer, then copy the requested number of frames to the output. On subsequent calls, either fulfill the request with data in your buffer, or re-fill your buffer as necessary.

You'll need to keep track of how full your buffer is, along with any needed state to process your effect into the buffer.

When the render block is called, pull enough input to fill your 2048-byte buffer, then copy the requested number of frames to the output. On subsequent calls, either fulfill the request with data in your buffer, or re-fill your buffer as necessary.

Could you clarify how to pull enough input to fill my 2048 block from upstream?
Shall I call AURenderPullInputBlock() with 2048 frameCount? Or
Shall I call multiple time in a single render block call?

And also if the render block is asking for 512 frame, can I push 2048 instead?

Thanks