How to capture input device audio and playback in realtime to an output device

Hi,

I am new to JUCE and am trying to understand how to use JUCE to capture audio from an input device(microphone, guitar via digital audio box etc.) and playback in realtime to an output device (speaker etc.)

To start with I am trying to do this from a console application.

So far I have an AudioApp class that accepts two audio device manager instances, corresponding to the input and output audio devices.

How do then connect the input device to the output device in realtime?
Do I have to use the addAudioCallback method?

_inputDeviceManager.addAudioCallback(&this->_audioSourcePlayer)

#ifndef h_App
#define h_App

#include <JuceHeader.h>

/**
 * This is the entrypoint console app
 * It has-a
 *  AudioDeviceManager
 *  AudioProcessorPlayer
 *  AudioProcessorGraph
 *
 * The dumpInfo method outputs audio device setup to console 
 */
class AudioApp
{
public:
    /** Initialise audio device manager */
    AudioApp(juce::AudioDeviceManager &deviceManager, juce::AudioDeviceManager &output);
    
    /** Deconstructor */
    ~AudioApp();
    
    /** Dump audio setup info to the console */
    void dumpInfo();

    /** Stream audio from input device to output device */
    void play();
private:
    juce::AudioDeviceManager &_deviceManager;
    juce::AudioDeviceManager &_outputDeviceManager;
    juce::AudioSourcePlayer _audioSourcePlayer;

    JUCE_DECLARE_NON_COPYABLE(AudioApp)
};

#endif

Trying to use 2 different audio devices is going to be complicated and Juce does not directly support that use case, as far as I know.

What operating system are you using? If you are on Mac Os, that has support in the OS to define “aggregate devices” which will look like a single device and could be used simply in Juce with just a single AudioDeviceManager instance.

Hi, thanks for responding. Yeah I am on MacOS, so could try out the aggregate devices.

Many thanks