Table Of Contents

Previous topic

QAudio

Next topic

QAudioFormat

QAudioDeviceInfo

Synopsis

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)
Parameters:otherPySide.QtMultimedia.QAudioDeviceInfo

Constructs an empty PySide.QtMultimedia.QAudioDeviceInfo object.

Constructs a copy of other .

static PySide.QtMultimedia.QAudioDeviceInfo.availableDevices(mode)
Parameters:modePySide.QtMultimedia.QAudio.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.

PySide.QtMultimedia.QAudioDeviceInfo.deviceName()
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

PySide.QtMultimedia.QAudioDeviceInfo.handle()
Return type:PySide.QtCore.QByteArray
PySide.QtMultimedia.QAudioDeviceInfo.isFormatSupported(format)
Parameters:formatPySide.QtMultimedia.QAudioFormat
Return type:PySide.QtCore.bool

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

PySide.QtMultimedia.QAudioDeviceInfo.isNull()
Return type:PySide.QtCore.bool

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

PySide.QtMultimedia.QAudioDeviceInfo.mode()
Return type:PySide.QtMultimedia.QAudio.Mode
PySide.QtMultimedia.QAudioDeviceInfo.nearestFormat(format)
Parameters:formatPySide.QtMultimedia.QAudioFormat
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.

PySide.QtMultimedia.QAudioDeviceInfo.preferredFormat()
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.
PySide.QtMultimedia.QAudioDeviceInfo.realm()
Return type:unicode
PySide.QtMultimedia.QAudioDeviceInfo.supportedByteOrders()
Return type:

Returns a list of supported byte orders.

PySide.QtMultimedia.QAudioDeviceInfo.supportedChannelCounts()
Return type:

Returns a list of supported channel counts.

PySide.QtMultimedia.QAudioDeviceInfo.supportedChannels()
Return type:

Use supportedChannelCount() instead.

PySide.QtMultimedia.QAudioDeviceInfo.supportedCodecs()
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:

http://www.iana.org/assignments/media-types/audio/

PySide.QtMultimedia.QAudioDeviceInfo.supportedFrequencies()
Return type:

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

PySide.QtMultimedia.QAudioDeviceInfo.supportedSampleRates()
Return type:

Returns a list of supported sample rates.

PySide.QtMultimedia.QAudioDeviceInfo.supportedSampleSizes()
Return type:

Returns a list of supported sample sizes.

PySide.QtMultimedia.QAudioDeviceInfo.supportedSampleTypes()
Return type:

Returns a list of supported sample types.