Reading audio buffers... just that!

Hi!

C++ developer here, completely new to audio and JUCE. I have a project where I need to do a real-time analysis of an audio signal, whether it’s something input by a microphone or something playing on an output.

I looked at a few tutorials, and most of them seem to rely on calls to getNextAudioBlock to process what’s in the input buffers. I’d like to bind my analysis on data coming in the buffers rather than being called when an device calls back to output something.

I feel like the answer lies around AudioFormatWriter::ThreadedWriter::IncomingDataReceiver but I am not so sure that I should use this class directly, as it’s quite deep in the API.

Any recommendation on how to “just” read audio whenever it’s written to an input or output buffer?

Cheers!

getNextAudioBlock and processBlock is the only place you can read/write live audio data.

If you’re trying to get intercept audio data from another application, you need an audio driver that supports that, your code would still be best placed in the proper audio callbacks though.

Juce is using a pulling pipeline model, i.e. a driver or plugin host is pulling out new samples.

What you want is a pushing pipeline, where the audio data is pushed towards the speakers / sound card once it appears. JUCE won’t work that way. You will have to add a FIFO buffer in between and have a strategy in place what to do if it runs empty or overflows. And ofc. it’s adding latency.