QAudioDevice

The QAudioDevice class provides an information about audio devices and their functionality. More

Inheritance diagram of PySide6.QtMultimedia.QAudioDevice

Synopsis

Functions

Detailed Description

QAudioDevice describes an audio device available in the system, either for input or for playback.

A QAudioDevice is used by Qt to construct classes that communicate with the device – such as QAudioSource , and QAudioSink . It is also used to determine the input or output device to use in a capture session or during media playback.

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

The values supported by the device for each of these parameters can be fetched with minimumChannelCount() , maximumChannelCount() , minimumSampleRate() , maximumSampleRate() and supportedSampleFormats() . The combinations supported are dependent on 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:

format = QAudioFormat()
format.setSampleRate(44100)
# ... other format parameters
format.setSampleFormat(QAudioFormat.Int16)

The set of available devices can be retrieved from the QMediaDevices class.

For instance:

deviceInfos = QMediaDevices.availableDevices(QAudioDevice.Output)
for deviceInfo in deviceInfos:
    print("Device: ", deviceInfo.description())

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().

class PySide6.QtMultimedia.QAudioDevice

PySide6.QtMultimedia.QAudioDevice(other)

Parameters

otherPySide6.QtMultimedia.QAudioDevice

Constructs a null QAudioDevice object.

PySide6.QtMultimedia.QAudioDevice.Mode

Describes the mode of a QAudioDevice

Constant

Description

QAudioDevice.Null

A null device.

QAudioDevice.Input

An input device.

QAudioDevice.Output

An output device.

PySide6.QtMultimedia.QAudioDevice.description()
Return type

str

PySide6.QtMultimedia.QAudioDevice.id()
Return type

PySide6.QtCore.QByteArray

PySide6.QtMultimedia.QAudioDevice.isDefault()
Return type

bool

PySide6.QtMultimedia.QAudioDevice.isFormatSupported(format)
Parameters

formatPySide6.QtMultimedia.QAudioFormat

Return type

bool

Returns true if the supplied settings are supported by the audio device described by this QAudioDevice .

PySide6.QtMultimedia.QAudioDevice.isNull()
Return type

bool

Returns whether this QAudioDevice object holds a valid device definition.

PySide6.QtMultimedia.QAudioDevice.maximumChannelCount()
Return type

int

Returns the maximum number of supported channel counts.

This is typically 1 for mono sound, or 2 for stereo sound.

PySide6.QtMultimedia.QAudioDevice.maximumSampleRate()
Return type

int

Returns the maximum supported sample rate (in Hertz).

PySide6.QtMultimedia.QAudioDevice.minimumChannelCount()
Return type

int

Returns the minimum number of supported channel counts.

This is typically 1 for mono sound, or 2 for stereo sound.

PySide6.QtMultimedia.QAudioDevice.minimumSampleRate()
Return type

int

Returns the minimum supported sample rate (in Hertz).

PySide6.QtMultimedia.QAudioDevice.mode()
Return type

Mode

PySide6.QtMultimedia.QAudioDevice.__ne__(other)
Parameters

otherPySide6.QtMultimedia.QAudioDevice

Return type

bool

Returns true if this QAudioDevice class represents a different audio device than other

PySide6.QtMultimedia.QAudioDevice.__eq__(other)
Parameters

otherPySide6.QtMultimedia.QAudioDevice

Return type

bool

Returns true if this QAudioDevice class represents the same audio device as other.

PySide6.QtMultimedia.QAudioDevice.preferredFormat()
Return type

PySide6.QtMultimedia.QAudioFormat

Returns the default audio format settings for this device.

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

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

A typical audio system would provide something like:

  • Input settings: 48000Hz mono 16 bit.

  • Output settings: 48000Hz stereo 16 bit.

PySide6.QtMultimedia.QAudioDevice.supportedSampleFormats()
Return type

Returns a list of supported sample types.

PySide6.QtMultimedia.QAudioDevice.swap(other)
Parameters

otherPySide6.QtMultimedia.QAudioDevice