Connecting multiple devices

I can connect an input channel of one device to an output channel of the same device by creating, opening and starting an instance of AudioIODevice, together with a supporting instance of AudioIODeviceCallback.

However, I don't know how to connect an input channel of one device to an output channel of a different device.

If two instances of AudioIODevice and AudioIODeviceCallback are required, how do you coordinate the callbacks?

Thanks.

This is not entirely straight forward as the callbacks will be called on different threads. You will need to use some kind of FIFO buffer where one callback will write the audio data and another thead reads it. You can use JUCE's AbstractFifo class for this. Internally, JUCE already needs to combine several audio device callbacks into one. For example, the CoreAudio backend of JUCE does exactly this. See the AudioIODeviceCombiner code, for example.

1 Like

Thanks for the information.

I've studied the code in AudioIODeviceCombiner.h and have a good appreciation as to how it works.

I have a few minor questions if you don't mind.

  1. Why is the size of the device combiner's fifo calculated to be 3 times the buffer size plus 1?
  2. Both readInput() and pushOutputData() try 5 times to read and write the requisite number of samples. Why 5?
  3. In audioDeviceIOCallback(), there's a sleep(1) under certain conditions. What is this for?

Thanks.

Regards,
Jeff.

1 Like