Table Of Contents

Previous topic


Next topic




Static functions

Detailed Description

The PySide.QtMultimedia.QAudioDeviceInfo class provides an interface to query audio devices and their functionality.

PySide.QtMultimedia.QAudioDeviceInfo lets you query for audio devices–such as sound cards and USB headsets–that are currently available on the system. The audio devices available are dependent on the platform or audio plugins installed.

You can also query each device for the formats it supports. A format in this context is a set consisting of a specific byte order, channel, codec, frequency, sample rate, and sample type. A format is represented by the PySide.QtMultimedia.QAudioFormat class.

The values supported by the the device for each of these parameters can be fetched with PySide.QtMultimedia.QAudioDeviceInfo.supportedByteOrders() , PySide.QtMultimedia.QAudioDeviceInfo.supportedChannelCounts() , PySide.QtMultimedia.QAudioDeviceInfo.supportedCodecs() , PySide.QtMultimedia.QAudioDeviceInfo.supportedSampleRates() , PySide.QtMultimedia.QAudioDeviceInfo.supportedSampleSizes() , and PySide.QtMultimedia.QAudioDeviceInfo.supportedSampleTypes() . The combinations supported are dependent on the platform, audio plugins installed and the audio device capabilities. If you need a specific format, you can check if the device supports it with PySide.QtMultimedia.QAudioDeviceInfo.isFormatSupported() , or fetch a supported format that is as close as possible to the format with PySide.QtMultimedia.QAudioDeviceInfo.nearestFormat() . For instance:

<Code snippet "doc/src/snippets/audio/main.cpp:6" not found>                ...
<Code snippet "doc/src/snippets/audio/main.cpp:7" not found>

A PySide.QtMultimedia.QAudioDeviceInfo is used by Qt to construct classes that communicate with the device–such as PySide.QtMultimedia.QAudioInput , and PySide.QtMultimedia.QAudioOutput . The static functions PySide.QtMultimedia.QAudioDeviceInfo.defaultInputDevice() , PySide.QtMultimedia.QAudioDeviceInfo.defaultOutputDevice() , and PySide.QtMultimedia.QAudioDeviceInfo.availableDevices() let you get a list of all available devices. Devices are fetch according to the value of mode this is specified by the QAudio.Mode enum. The PySide.QtMultimedia.QAudioDeviceInfo returned are only valid for the QAudio.Mode .

For instance:

foreach(const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
    qDebug() << "Device name: " << deviceInfo.deviceName();

In this code sample, we loop through all devices that are able to output sound, i.e., play an audio stream in a supported format. For each device we find, we simply print the PySide.QtMultimedia.QAudioDeviceInfo.deviceName() .

class PySide.QtMultimedia.QAudioDeviceInfo
class PySide.QtMultimedia.QAudioDeviceInfo(other)

Constructs an empty PySide.QtMultimedia.QAudioDeviceInfo object.

Constructs a copy of other .

static PySide.QtMultimedia.QAudioDeviceInfo.availableDevices(mode)
Return type:
static PySide.QtMultimedia.QAudioDeviceInfo.defaultInputDevice()
Return type:PySide.QtMultimedia.QAudioDeviceInfo

Returns the name of the default input audio device. All platform and audio plugin implementations provide a default audio device to use.

static PySide.QtMultimedia.QAudioDeviceInfo.defaultOutputDevice()
Return type:PySide.QtMultimedia.QAudioDeviceInfo

Returns the name of the default output audio device. All platform and audio plugin implementations provide a default audio device to use.

Return type:unicode

Returns human readable name of audio device.

Device names vary depending on platform/audio plugin being used.

They are a unique string identifiers for the audio device.

eg. default, Intel, U0x46d0x9a4

Return type:PySide.QtCore.QByteArray
Return type:PySide.QtCore.bool

Returns true if settings are supported by the audio device of this PySide.QtMultimedia.QAudioDeviceInfo .

Return type:PySide.QtCore.bool

Returns whether this PySide.QtMultimedia.QAudioDeviceInfo object holds a device definition.

Return type:PySide.QtMultimedia.QAudio.Mode
Return type:PySide.QtMultimedia.QAudioFormat

Returns closest PySide.QtMultimedia.QAudioFormat to settings that system audio supports.

These settings are provided by the platform/audio plugin being used.

They also are dependent on the QAudio.Mode being used.

Return type:PySide.QtMultimedia.QAudioFormat

Returns PySide.QtMultimedia.QAudioFormat of default settings.

These settings are provided by the platform/audio plugin being used.

They also are dependent on the QAudio.Mode being used.

A typical audio system would provide something like:

  • Input settings: 8000Hz mono 8 bit.
  • Output settings: 44100Hz stereo 16 bit little endian.
Return type:unicode
Return type:

Returns a list of supported byte orders.

Return type:

Returns a list of supported channel counts.

Return type:

Use supportedChannelCount() instead.

Return type:list of strings

Returns a list of supported codecs.

All platform and plugin implementations should provide support for:

“audio/pcm” - Linear PCM

For writing plugins to support additional codecs refer to:

Return type:

Use PySide.QtMultimedia.QAudioDeviceInfo.supportedSampleRates() instead.

Return type:

Returns a list of supported sample rates.

Return type:

Returns a list of supported sample sizes.

Return type:

Returns a list of supported sample types.