[Interest] How to get number of channels from QAudioDeviceInfo

Glenn Ramsey gr at componic.co.nz
Fri Jan 22 05:07:19 CET 2016


Hi,

I would like to use the Qt5.x QtMultiMedia to output sound independently on
multi-channel devices such as 5.1 and 7.1 sound cards. However I can't figure
out to tell how many channels a device has.

>From the documentation I guess that QAudioDeviceInfo::supportedChannelCounts is
the call that I need but that isn't giving the answers that I expect.

PyQt5 test program (built with Qt 5.5.1 on OSX 10.10.5):

    from PyQt5.QtMultimedia import QAudioDeviceInfo, QAudio, QAudioFormat

    for d in QAudioDeviceInfo.availableDevices(QAudio.AudioOutput):
        print d.deviceName(), d.supportedChannelCounts()
        f = QAudioFormat(d.preferredFormat())
        f.setChannelCount(6)
        print d.isFormatSupported(f)

Using OSX 10.10.5 on a MacBook Pro I have a 5.1 USB audio card plugged in and
the output from the above program is:

    Built-in Output [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
    True
    USB Audio [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
    True

I was expecting some information that would tell me that the built in output has
2 channels and that 6 isn't supported and the USB audio has 6 channels. I get I
similar result on Windows 7.

What is the right way to query the number of channels on a device?

Glenn



More information about the Interest mailing list