内容表

上一话题

QAudioDecoderControl

下一话题

QAudioEncoderSettings

QAudioDeviceInfo

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

Inheritance diagram of PySide2.QtMultimedia.QAudioDeviceInfo

详细描述

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.

A QAudioDeviceInfo is used by Qt to construct classes that communicate with the device–such as QAudioInput ,和 QAudioOutput .

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 类。

The values supported by the device for each of these parameters can be fetched with supportedByteOrders() , supportedChannelCounts() , supportedCodecs() , supportedSampleRates() , supportedSampleSizes() ,和 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.setSampleRate(44100);
// ... other format parameters
format.setSampleType(QAudioFormat::SignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format))
    format = info.nearestFormat(format);
											

静态函数 defaultInputDevice() , defaultOutputDevice() ,和 availableDevices() let you get a list of all available devices. Devices are fetched according to the value of mode this is specified by the QAudio ::Mode enum. The QAudioDeviceInfo returned are only valid for the QAudio ::Mode.

例如:

const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
for (const QAudioDeviceInfo &deviceInfo : deviceInfos)
    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() .

class QAudioDeviceInfo

QAudioDeviceInfo(other)

param other

QAudioDeviceInfo

构造空 QAudioDeviceInfo 对象。

构造副本为 other .

static PySide2.QtMultimedia.QAudioDeviceInfo. availableDevices ( mode )
参数

mode 模式

返回类型

Returns a list of audio devices that support mode .

static PySide2.QtMultimedia.QAudioDeviceInfo. defaultInputDevice ( )
返回类型

QAudioDeviceInfo

返回默认输入音频设备的信息。所有平台和音频插件实现均提供要使用的默认音频设备。

static PySide2.QtMultimedia.QAudioDeviceInfo. defaultOutputDevice ( )
返回类型

QAudioDeviceInfo

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

PySide2.QtMultimedia.QAudioDeviceInfo. deviceName ( )
返回类型

unicode

返回音频设备的人类可读名称。

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

They are a unique string identifier for the audio device.

eg. default, Intel, U0x46d0x9a4

PySide2.QtMultimedia.QAudioDeviceInfo. isFormatSupported ( format )
参数

format QAudioFormat

返回类型

bool

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

PySide2.QtMultimedia.QAudioDeviceInfo. isNull ( )
返回类型

bool

Returns whether this QAudioDeviceInfo object holds a valid device definition.

PySide2.QtMultimedia.QAudioDeviceInfo. nearestFormat ( format )
参数

format QAudioFormat

返回类型

QAudioFormat

Returns the closest QAudioFormat to the supplied settings that the system supports.

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

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

PySide2.QtMultimedia.QAudioDeviceInfo. __ne__ ( other )
参数

other QAudioDeviceInfo

返回类型

bool

返回 true,若此 QAudioDeviceInfo class represents a different audio device than other

PySide2.QtMultimedia.QAudioDeviceInfo. __eq__ ( other )
参数

other QAudioDeviceInfo

返回类型

bool

返回 true,若此 QAudioDeviceInfo class represents the same audio device as other .

PySide2.QtMultimedia.QAudioDeviceInfo. preferredFormat ( )
返回类型

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: 8000Hz mono 8 bit.

  • Output settings: 44100Hz stereo 16 bit little endian.

PySide2.QtMultimedia.QAudioDeviceInfo. realm ( )
返回类型

unicode

Returns the key that represents the audio plugin.

另请参阅

QAudioSystemPlugin

PySide2.QtMultimedia.QAudioDeviceInfo. supportedByteOrders ( )
返回类型

Returns a list of supported byte orders.

PySide2.QtMultimedia.QAudioDeviceInfo. supportedChannelCounts ( )
返回类型

Returns a list of supported channel counts.

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

PySide2.QtMultimedia.QAudioDeviceInfo. supportedCodecs ( )
返回类型

字符串列表

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/

PySide2.QtMultimedia.QAudioDeviceInfo. supportedSampleRates ( )
返回类型

返回支持的采样率的列表 (以赫兹为单位)。

PySide2.QtMultimedia.QAudioDeviceInfo. supportedSampleSizes ( )
返回类型

返回支持的采样大小的列表 (以位为单位)。

通常这将包括 8 位和 16 位的采样大小。

PySide2.QtMultimedia.QAudioDeviceInfo. supportedSampleTypes ( )
返回类型

Returns a list of supported sample types.