I am trying to combine the AudioDeviceManager tutorial with the Visual FFT as an experiment leading to larger project. I am using a TabbedComponent to manage both in their own unique components. Hence, the DeviceManager and FFT plotter are in their own distinct classes.
What would be the best way to pass the AudioSourceChannelInfo struct buffer pointer from the DeviceManager class to the FFT plotter? I do not want to inherit the DeviceManager in the FFT plotter, since I would then have two calls to the paint() function, with overlapping graphics, and I want to have them in their own unique components.
I only want to read the buffer data in the FFT class. No writing whatsoever (at least for now). I plan to add small DSP snippets (delay, EQ, reverb etc) in their own tabbed components in the future and knowing how to pass audio (safely) from one module to another for this effects chain would be helpful.
Would handling the FFT plotter in its own thread and using a unique_ptr<AudioBuffer> with a getReadPointer() call and passing that to the “graphics thread” of the FFT in the getNextAudioBlock() be a possible solution? And if yes, how do I do this? I have never done any multithreaded JUCE coding and my C++ thread knowledge is minimal (tbh non-existent).
Is there a simpler solution?