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 类。
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() ,和 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 ,和 PySide.QtMultimedia.QAudioOutput . The static functions PySide.QtMultimedia.QAudioDeviceInfo.defaultInputDevice() , PySide.QtMultimedia.QAudioDeviceInfo.defaultOutputDevice() ,和 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 .
例如:
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() .
| 参数: | other – PySide.QtMultimedia.QAudioDeviceInfo |
|---|
构造空 PySide.QtMultimedia.QAudioDeviceInfo 对象。
构造副本为 other .
| 参数: | mode – PySide.QtMultimedia.QAudio.Mode |
|---|---|
| 返回类型: |
| 返回类型: | 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.
| 返回类型: | 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.
| 返回类型: | 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.QtCore.QByteArray |
|---|
| 参数: | format – PySide.QtMultimedia.QAudioFormat |
|---|---|
| 返回类型: | PySide.QtCore.bool |
返回 true 若 settings are supported by the audio device of this PySide.QtMultimedia.QAudioDeviceInfo .
| 返回类型: | PySide.QtCore.bool |
|---|
Returns whether this PySide.QtMultimedia.QAudioDeviceInfo object holds a device definition.
| 返回类型: | PySide.QtMultimedia.QAudio.Mode |
|---|
| 参数: | format – PySide.QtMultimedia.QAudioFormat |
|---|---|
| 返回类型: | 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 被使用。
| 返回类型: | PySide.QtMultimedia.QAudioFormat |
|---|
返回 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 被使用。
A typical audio system would provide something like:
| 返回类型: | unicode |
|---|
| 返回类型: |
|---|
Returns a list of supported byte orders.
| 返回类型: |
|---|
Returns a list of supported channel counts.
| 返回类型: |
|---|
Use supportedChannelCount() instead.
| 返回类型: | 字符串列表 |
|---|
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:
| 返回类型: |
|---|
使用 PySide.QtMultimedia.QAudioDeviceInfo.supportedSampleRates() 代替。
| 返回类型: |
|---|
Returns a list of supported sample rates.
| 返回类型: |
|---|
Returns a list of supported sample sizes.
| 返回类型: |
|---|
Returns a list of supported sample types.