Audio floats -> AAC -> floats in Realtime Audio Plug-In mac/win

Hi all,

I’m working on a macOS/Windows plugin where, to give the listener a preview of what it will sound like, I’d like to encode the input AudioBuffer<float> to AAC and then decode back to floats within the processBlock callback (is this even possible with how the AAC codec works? According to the wiki it looks like the codec works in chunks of 1024 and can dynamically switch to smaller block sizes for transients. How would the plugin’s compensation delay then be consistent?).

I’d prefer to use the mac AudioToolBox & Windows Media Foundation APIs to avoid having to purchase an AAC license (NOTE I am not a lawyer and none of what I say constitues legal advice :wink: ), although it looks like using ffmpeg could possibly be an easier cross-platform solution but requires obtaining the AAC license.

However, working with these APIs is pretty much the reason I love JUCE so much – to me they seem convoluted and error-prone where JUCE is very elegant and intuitive. I was wondering if anybody knows of any projects that already wrap these “native” AAC encoders/decoders, or if anybody has any general tips on the topic.

Many thanks in advanced :slight_smile:

You will of course have to implement the buffering scheme needed yourself, to be able to feed the encoder as much audio as it needs, as well as buffer the output of the decoder so much that you can feed the audio back into the host. The latency reported by the plugin could be the maximum amount of input you need to buffer. Or you could simply report zero latency to the host, even if that’s not correct.

Thanks for the tips. Reporting zero is an option, although making sure the transport position lines up with the audio will confuse users less. Here’s a nice guide from Apple that looks potentially useful on this particular topic.