Potential bug selecting audio input channels

Hi there,

I’ve noticed a change in JUCE 7.02 (and on latest develop commit) related to selecting input channels on an audio device in a standalone plugin. When we select the input channel we want to use, we are doing this…

int channel = 3; // this isn't real code, but instead a placeholder for a value returned via a ComboBox

auto config = deviceManager.getAudioDeviceSetup();

config.useDefaultInputChannels = false;
config.inputChannels = 0;
config.inputChannels.setBit (channel, true);

deviceManager.setAudioDeviceSetup (config, true);

If I print to the console what config.inputChannels looks like, using…

DBG (config.inputChannels.toString (2));

For selecting channel 3 only i get…


which is correct (the third channel is selected in this bit mask).

However, in AudioDeviceManager::setAudioDeviceSetup(), this value is changing from 100 to 111. If I select channel 4 and expect 1000, it changes to 1111, and similarly for other channels.

In particular, in that function, I can log it before and after this line to see the change…

error = currentAudioDevice->open (currentSetup.inputChannels,

The result of this is that when we get to AudioProcessorPlayer::audioDeviceAboutToStart(), the following line is processed:

auto numChansIn = device->getActiveInputChannels().countNumberOfSetBits();

which takes the 111 bit mask and decides there are 3 inputs, rather than the 100 which should conclude there is one input (the third one on the device).

Is this expected behaviour? It doesn’t happen in JUCE 7.0.1. It also doesn’t happen on Windows - this is occurring on macOS.