setAudioChannels and changing audio devices

Hi all,

I’m just starting to use JUCE (but am an experienced C++ dev) to make a live sound processing application. I’m currently basing it off a juce::AudioAppComponent, but happy to implement my own base class if needed.

I am wondering about the interplay between juce::AudioAppComponent::setAudioChannels() and an Audio Device’s input / output channel count. If I change the audio device in use (e.g. through an juce::AudioDeviceSelectorComponent), the number of input / output channels I want the application to have may change if the new device supports a different number of channels to the last.

This feels fairly fundamental, so I am probably missing something. But, I’d welcome any advice on how to handle device changes which change the number of IO channels available to the application.

I can think of two strategies here:

  1. Set the setAudioChannels() requested channel counts to something arbitrarily high (will this even work?)
  2. Implement my own audio handling base class which tears down the AudioDeviceManager when the device changes, and rebuilds it with the new channel counts. The code for AudioAppComponent::setAudioChannels( is really simple so I can happily re-implement this to handle changes in channel counts.

Thanks for any pointers!