|  | Home · All Classes · Modules

# QAudioDeviceInfo Class Reference
[QtMultimedia module]

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

### Methods

- __init__ (self)
- __init__ (self, QAudioDeviceInfo)
- QStringQString deviceName (self)
- bool isFormatSupported (self, QAudioFormat)
- bool isNull (self)
- QAudioFormat nearestFormat (self, QAudioFormat)
- QAudioFormat preferredFormat (self)
- QList<QAudioFormat::Endian>list-of-QAudioFormat.Endian supportedByteOrders (self)
- QList<int>list-of-int supportedChannels (self)
- QStringListQStringList supportedCodecs (self)
- QList<int>list-of-int supportedFrequencies (self)
- QList<int>list-of-int supportedSampleSizes (self)
- QList<QAudioFormat::SampleType>list-of-QAudioFormat.SampleType supportedSampleTypes (self)

### Static Methods

- QList<QAudioDeviceInfo>list-of-QAudioDeviceInfo availableDevices (QAudio.Mode)
- QAudioDeviceInfo defaultInputDevice ()
- QAudioDeviceInfo defaultOutputDevice ()

## Detailed Description

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

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 QAudioFormat class.

The values supported by the the device for each of these parameters can be fetched with supportedByteOrders(), supportedChannels(), supportedCodecs(), supportedFrequencies(), supportedSampleSizes(), and 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 isFormatSupported(), or fetch a supported format that is as close as possible to the format with nearestFormat(). For instance:

             QAudioFormat format;
             format.setFrequency(44100);
             ...
             format.setSampleType(QAudioFormat.SignedInt);

             QAudioDeviceInfo info(QAudioDeviceInfo.defaultOutputDevice());

             if (!info.isFormatSupported(format))
                 format = info.nearestFormat(format);

A QAudioDeviceInfo is used by Qt to construct classes that communicate with the device--such as QAudioInput, and QAudioOutput. The static functions defaultInputDevice(), defaultOutputDevice(), and 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 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 deviceName().

See also QAudioOutput and QAudioInput.

## Method Documentation

### QAudioDeviceInfo.__init__ (self)

Constructs an empty QAudioDeviceInfo object.

### QAudioDeviceInfo.__init__ (self, QAudioDeviceInfo)

Constructs a copy of other.

### QList<QAudioDeviceInfo>list-of-QAudioDeviceInfo QAudioDeviceInfo.availableDevices (QAudio.Mode)

Returns a list of audio devices that support mode.

### QAudioDeviceInfo QAudioDeviceInfo.defaultInputDevice ()

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

### QAudioDeviceInfo QAudioDeviceInfo.defaultOutputDevice ()

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

### QStringQString QAudioDeviceInfo.deviceName (self)

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

### bool QAudioDeviceInfo.isFormatSupported (self, QAudioFormat)

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

### bool QAudioDeviceInfo.isNull (self)

Returns whether this QAudioDeviceInfo object holds a device definition.

### QAudioFormat QAudioDeviceInfo.nearestFormat (self, QAudioFormat)

Returns closest 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.

### QAudioFormat QAudioDeviceInfo.preferredFormat (self)

Returns 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.

### QList<QAudioFormat::Endian>list-of-QAudioFormat.Endian QAudioDeviceInfo.supportedByteOrders (self)

Returns a list of supported byte orders.

### QList<int>list-of-int QAudioDeviceInfo.supportedChannels (self)

Returns a list of supported channels.

### QStringListQStringList QAudioDeviceInfo.supportedCodecs (self)

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/

### QList<int>list-of-int QAudioDeviceInfo.supportedFrequencies (self)

Returns a list of supported frequencies.

### QList<int>list-of-int QAudioDeviceInfo.supportedSampleSizes (self)

Returns a list of supported sample sizes.

### QList<QAudioFormat::SampleType>list-of-QAudioFormat.SampleType QAudioDeviceInfo.supportedSampleTypes (self)

Returns a list of supported sample types.