WASAPI channel count

I think there may be an issue with the WASAPI channel count for multichannel devices. If I use the AudioDeviceManager to find WASAPI devices:

Then the devices are found correctly, but every device has only one channel available; i.e., getOutputChannelNames returns an array with one entry.

I think it has to do with numActualChannels being set to the same number of channels passed to the Initialize call:

[code] GUID session;
if (hr == S_OK
&& check (client->Initialize (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE : AUDCLNT_SHAREMODE_SHARED,
0x40000 /AUDCLNT_STREAMFLAGS_EVENTCALLBACK/,
defaultPeriod, defaultPeriod, (WAVEFORMATEX*) &format, &session)))
{
actualNumChannels = format.Format.nChannels;
const bool isFloat = format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE && format.SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
bytesPerSample = format.Format.wBitsPerSample / 8;

        updateFormat (isFloat);
        return true;
    }[/code]

The audio device manager is only asking for one channel, so actualNumChannels ends up set to one.

I was able to work around this by removing the line where actualNumChannels is changed and then judiciously changing actualNumChannels to numChannels in a few spots. It seems to work okay, except if an odd number of channels are selected.

Otherwise, I don’t see any way to discover the actual number of channels for the device; this is significant, since I’m looking for surround sound capable devices.

Cheers,

Matt

Well, if you ask it for only 1 channel, it’ll give you 1 channel! Try asking for 256 (or more) channels, and it’ll give you as many as the device can support.

Thanks; that works fine.

I think the confusion here may stem from the documentation for AudioDeviceManager::initialise:

numOutputChannelsNeeded a minimum number of output channels to open

Since that is labeled as the minimum channel count, I thought that the maximum number of channels available for the device would still be selectable.

Matt

Good point - I’ll make that comment clearer.

I think I was also mixing up the min and max channel count parameters for the AudioDeviceSelectorComponent constructor. Sorry about that.

Matt