The QAudioDeviceInfo 類提供查詢音頻設備及其功能的接口。 更多...
| 頭: | #include <QAudioDeviceInfo> |
| Since: | Qt 4.6 |
| QAudioDeviceInfo () | |
| QAudioDeviceInfo (const QAudioDeviceInfo & other ) | |
| ~QAudioDeviceInfo () | |
| QString | deviceName () const |
| bool | isFormatSupported (const QAudioFormat & settings ) const |
| bool | isNull () const |
| QAudioFormat | nearestFormat (const QAudioFormat & settings ) const |
| QAudioFormat | preferredFormat () const |
| QList<QAudioFormat::Endian> | supportedByteOrders () const |
| QList<int> | supportedChannelCounts () const |
| QStringList | supportedCodecs () const |
| QList<int> | supportedSampleRates () const |
| QList<int> | supportedSampleSizes () const |
| QList<QAudioFormat::SampleType> | supportedSampleTypes () const |
| QAudioDeviceInfo & | operator= (const QAudioDeviceInfo & other ) |
| QList<QAudioDeviceInfo> | availableDevices (QAudio::Mode mode ) |
| QAudioDeviceInfo | defaultInputDevice () |
| QAudioDeviceInfo | defaultOutputDevice () |
The QAudioDeviceInfo 類提供查詢音頻設備及其功能的接口。
QAudioDeviceInfo 允許查詢係統中當前可用的音頻設備 (譬如:聲卡和 USB 耳機)。可用的音頻設備從屬所安裝的平颱或音頻插件。
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 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.setFrequency(44100);
...
format.setSampleType(QAudioFormat::SignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format))
format = info.nearestFormat(format);
A QAudioDeviceInfo 用於 Qt 以構造與設備通信的類,譬如 QAudioInput ,和 QAudioOutput . The static functions defaultInputDevice (), defaultOutputDevice (),和 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 .
例如:
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 ().
另請參閱 QAudioOutput and QAudioInput .
構造空的 QAudioDeviceInfo 對象。
構造副本為 other .
銷毀此音頻設備信息。
[static]
QList
<
QAudioDeviceInfo
> QAudioDeviceInfo::
availableDevices
(
QAudio::Mode
mode
)
返迴的音頻設備列錶支持 mode .
[static]
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.
[static]
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.
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.
如 default, Intel, U0x46d0x9a4
返迴 true 若 settings are supported by the audio device of this QAudioDeviceInfo .
返迴是否此 QAudioDeviceInfo object holds a device definition.
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 被使用。
返迴 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:
返迴支持的字節序列錶。
Returns a list of supported channel counts.
該函數在 Qt 4.7 引入。
返迴支持的編解碼器列錶。
所有平颱和插件實現都應提供支持:
audio/pcm - 綫性 PCM
編寫插件以支持額外編解碼器,參考:
http://www.iana.org/assignments/media-types/audio/
Returns a list of supported sample rates.
該函數在 Qt 4.7 引入。
Returns a list of supported sample sizes.
Returns a list of supported sample types.
設置 QAudioDeviceInfo 對象等於 other .