Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QAudioDeviceInfo Class

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

Header:#include <QAudioDeviceInfo>
Since: Qt 4.6

Public Functions

QAudioDeviceInfo()
QAudioDeviceInfo(const QAudioDeviceInfo & other)
~QAudioDeviceInfo()
QStringdeviceName() const
boolisFormatSupported(const QAudioFormat & settings) const
boolisNull() const
QAudioFormatnearestFormat(const QAudioFormat & settings) const
QAudioFormatpreferredFormat() const
QList<QAudioFormat::Endian>supportedByteOrders() const
QList<int>supportedChannelCounts() const
QStringListsupportedCodecs() const
QList<int>supportedSampleRates() const
QList<int>supportedSampleSizes() const
QList<QAudioFormat::SampleType>supportedSampleTypes() const
QAudioDeviceInfo &operator=(const QAudioDeviceInfo & other)

Static Public Members

QList<QAudioDeviceInfo>availableDevices(QAudio::Mode mode)
QAudioDeviceInfodefaultInputDevice()
QAudioDeviceInfodefaultOutputDevice()

Detailed Description

TheQAudioDeviceInfo 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 theQAudioFormat class.

The values supported by the the device for each of these parameters can be fetched withsupportedByteOrders(),supportedChannelCounts(),supportedCodecs(),supportedSampleRates(),supportedSampleSizes(), andsupportedSampleTypes(). 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 withisFormatSupported(), or fetch a supported format that is as close as possible to the format withnearestFormat(). For instance:

QAudioFormat format;        format.setFrequency(44100);        ...        format.setSampleType(QAudioFormat::SignedInt);QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());if (!info.isFormatSupported(format))            format= info.nearestFormat(format);

AQAudioDeviceInfo is used by Qt to construct classes that communicate with the device--such asQAudioInput, andQAudioOutput. The static functionsdefaultInputDevice(),defaultOutputDevice(), andavailableDevices() let you get a list of all available devices. Devices are fetch according to the value of mode this is specified by theQAudio::Mode enum. TheQAudioDeviceInfo returned are only valid for theQAudio::Mode.

For instance:

foreach(constQAudioDeviceInfo&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 thedeviceName().

See alsoQAudioOutput andQAudioInput.

Member Function Documentation

QAudioDeviceInfo::QAudioDeviceInfo()

Constructs an emptyQAudioDeviceInfo object.

QAudioDeviceInfo::QAudioDeviceInfo(constQAudioDeviceInfo & other)

Constructs a copy ofother.

QAudioDeviceInfo::~QAudioDeviceInfo()

Destroy this audio device info.

[static]QList<QAudioDeviceInfo> QAudioDeviceInfo::availableDevices(QAudio::Mode mode)

Returns a list of audio devices that supportmode.

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

QString QAudioDeviceInfo::deviceName() const

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(constQAudioFormat & settings) const

Returns true ifsettings are supported by the audio device of thisQAudioDeviceInfo.

bool QAudioDeviceInfo::isNull() const

Returns whether thisQAudioDeviceInfo object holds a device definition.

QAudioFormat QAudioDeviceInfo::nearestFormat(constQAudioFormat & settings) const

Returns closestQAudioFormat tosettings that system audio supports.

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

They also are dependent on theQAudio::Mode being used.

QAudioFormat QAudioDeviceInfo::preferredFormat() const

ReturnsQAudioFormat of default settings.

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

They also are dependent on theQAudio::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> QAudioDeviceInfo::supportedByteOrders() const

Returns a list of supported byte orders.

QList<int> QAudioDeviceInfo::supportedChannelCounts() const

Returns a list of supported channel counts.

This function was introduced in Qt 4.7.

QStringList QAudioDeviceInfo::supportedCodecs() const

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> QAudioDeviceInfo::supportedSampleRates() const

Returns a list of supported sample rates.

This function was introduced in Qt 4.7.

QList<int> QAudioDeviceInfo::supportedSampleSizes() const

Returns a list of supported sample sizes.

QList<QAudioFormat::SampleType> QAudioDeviceInfo::supportedSampleTypes() const

Returns a list of supported sample types.

QAudioDeviceInfo & QAudioDeviceInfo::operator=(constQAudioDeviceInfo & other)

Sets theQAudioDeviceInfo object to be equal toother.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp