QAudioDevice Class
QAudioDevice 클래스는 오디오 장치 및 해당 기능에 대한 정보를 제공합니다. 더 보기...
| 헤더: | #include <QAudioDevice> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Multimedia) target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
| qmake: | QT += multimedia |
공개 유형
| enum | Mode { Null, Input, Output } |
속성
- description : const QString
- id : const QByteArray
- isDefault : const bool
- mode : const Mode
공개 함수
| QAudioDevice() | |
| QAudioDevice(const QAudioDevice &other) | |
| QAudioDevice(QAudioDevice &&other) | |
| ~QAudioDevice() | |
| QAudioFormat::ChannelConfig | channelConfiguration() const |
| QString | description() const |
| QByteArray | id() const |
| bool | isDefault() const |
| bool | isFormatSupported(const QAudioFormat &settings) const |
| bool | isNull() const |
| int | maximumChannelCount() const |
| int | maximumSampleRate() const |
| int | minimumChannelCount() const |
| int | minimumSampleRate() const |
| QAudioDevice::Mode | mode() const |
| QAudioFormat | preferredFormat() const |
| QList<QAudioFormat::SampleFormat> | supportedSampleFormats() const |
| void | swap(QAudioDevice &other) |
| bool | operator!=(const QAudioDevice &other) const |
| QAudioDevice & | operator=(QAudioDevice &&other) |
| QAudioDevice & | operator=(const QAudioDevice &other) |
| bool | operator==(const QAudioDevice &other) const |
상세 설명
QAudioDevice는 시스템에서 사용 가능한 오디오 장치를 설명하며, 입력용 또는 재생용일 수 있습니다.
Qt는 QAudioDevice를 사용하여 QAudioSource 및 QAudioSink 와 같이 장치와 통신하는 클래스를 생성합니다. 또한 캡처 세션이나 미디어 재생 중에 사용할 입력 또는 출력 장치를 결정하는 데에도 사용됩니다.
QAudioDevice 인스턴스는 해당 물리적 장치가 연결이 끊기거나 설정이 변경되더라도 수명 주기 내내 속성을 유지합니다. 업데이트된 속성을 추적하려면, 사용자는 관련 신호가 발생했을 때 QMediaDevices 에서 QAudioDevice의 새 인스턴스를 불러와야 합니다.
또한 각 장치가 지원하는 포맷을 조회할 수도 있습니다. 이 맥락에서 포맷이란 채널 수, 샘플 레이트, 샘플 유형으로 구성된 집합을 의미합니다. 포맷은 QAudioFormat 클래스로 표현됩니다.
각 매개변수에 대해 장치가 지원하는 값은 minimumChannelCount(), maximumChannelCount(), minimumSampleRate(), maximumSampleRate() 및 supportedSampleFormats()을 사용하여 가져올 수 있습니다. 지원되는 조합은 오디오 장치의 성능에 따라 다릅니다. 특정 형식이 필요한 경우, isFormatSupported()을 사용하여 장치가 해당 형식을 지원하는지 확인할 수 있습니다. 예를 들어:
{
sourceFile.setFileName("/tmp/test.raw");
sourceFile.open(QIODevice::ReadOnly);
QAudioFormat format;
// 포맷 설정, 예:
format.setSampleRate(44100);
format.setChannelCount(1);
format.setSampleFormat(QAudioFormat::Int16);
QAudioDevice info(QMediaDevices::defaultAudioOutput());
if (!info.isFormatSupported(format)) {
qWarning() << "Raw audio format not supported by backend, cannot play audio.";
return;
}
audio = new QAudioSink(format, this);
connect(audio, QAudioSink::stateChanged, this, &AudioInputExample::handleStateChanged);
audio->start(&sourceFile);
}사용 가능한 장치 목록은 QMediaDevices 클래스에서 가져올 수 있습니다.
예를 들어:
const auto devices = QMediaDevices::audioOutputs();
for (const QAudioDevice&device: devices)
qDebug() << "Device: " << device.description();이 코드 예제에서는 소리를 출력할 수 있는, 즉 지원되는 형식의 오디오 스트림을 재생할 수 있는 모든 장치를 순회합니다. 발견된 각 장치에 대해 deviceName()을 출력합니다.
QAudioSink, QAudioSource 및 QAudioFormat도 참조하십시오 .
멤버 유형 문서
enum QAudioDevice::Mode
이 장치의 작동 방식을 설명합니다.
| 상수 | 값 | 설명 |
|---|---|---|
QAudioDevice::Null | 0 | null 장치입니다. |
QAudioDevice::Input | 1 | 입력 장치입니다. |
QAudioDevice::Output | 2 | 출력 장치. |
속성 설명
[read-only] description : const QString
오디오 장치의 사람이 읽기 쉬운 이름을 반환합니다.
이 문자열을 사용하여 사용자에게 장치를 표시합니다.
액세스 함수:
| QString | description() const |
[read-only] id : const QByteArray
오디오 장치의 식별자를 반환합니다.
장치 이름은 사용 중인 플랫폼/오디오 플러그인에 따라 다릅니다.
이는 오디오 장치에 대한 고유 식별자입니다.
액세스 함수:
| QByteArray | id() const |
[read-only] isDefault : const bool
이 장치가 기본 오디오 장치인 경우 true를 반환합니다.
액세스 함수:
| bool | isDefault() const |
[read-only] mode : const Mode
이 장치가 입력 장치인지 출력 장치인지 여부를 반환합니다.
액세스 함수:
| QAudioDevice::Mode | mode() const |
멤버 함수 설명서
QAudioDevice::QAudioDevice()
null 값을 가진 QAudioDevice 객체를 생성합니다.
QAudioDevice::QAudioDevice(const QAudioDevice &other)
other 의 복사본을 생성합니다.
[constexpr noexcept default] QAudioDevice::QAudioDevice(QAudioDevice &&other)
other 에서 생성된 구조체를 이동합니다.
[noexcept] QAudioDevice::~QAudioDevice()
이 오디오 장치 정보를 삭제하십시오.
QAudioFormat::ChannelConfig QAudioDevice::channelConfiguration() const
장치의 채널 구성을 반환합니다.
bool QAudioDevice::isFormatSupported(const QAudioFormat &settings) const
이 QAudioDevice 에 설명된 오디오 장치가 제공된 settings 를 지원하는 경우 true를 반환합니다.
bool QAudioDevice::isNull() const
이 QAudioDevice 객체가 유효한 장치 정의를 포함하고 있는지 여부를 반환합니다.
int QAudioDevice::maximumChannelCount() const
지원되는 최대 채널 수를 반환합니다.
일반적으로 모노 사운드의 경우 1, 스테레오 사운드의 경우 2입니다.
int QAudioDevice::maximumSampleRate() const
지원되는 최대 샘플 레이트(헤르츠 단위)를 반환합니다.
int QAudioDevice::minimumChannelCount() const
지원되는 채널 수의 최소값을 반환합니다.
일반적으로 모노 사운드의 경우 1, 스테레오 사운드의 경우 2입니다.
int QAudioDevice::minimumSampleRate() const
지원되는 최소 샘플 레이트(헤르츠 단위)를 반환합니다.
QAudioFormat QAudioDevice::preferredFormat() const
이 장치의 기본 오디오 형식 설정을 반환합니다.
이러한 설정은 사용 중인 플랫폼/오디오 플러그인에서 제공됩니다.
또한 이 설정은 사용 중인 QtAudio::Mode에 따라 달라집니다.
일반적인 오디오 시스템은 다음과 같은 설정을 제공합니다:
- 입력 설정: 48000Hz 모노 16비트.
- 출력 설정: 48000Hz 스테레오 16비트.
QList<QAudioFormat::SampleFormat> QAudioDevice::supportedSampleFormats() const
지원되는 샘플 유형의 목록을 반환합니다.
[noexcept] void QAudioDevice::swap(QAudioDevice &other)
오디오 장치를 ‘ other ’로 바꿉니다.
bool QAudioDevice::operator!=(const QAudioDevice &other) const
이 ` QAudioDevice ` 클래스가 다음의 오디오 장치와 다른 오디오 장치를 나타내는 경우 `true`를 반환합니다. other
[noexcept] QAudioDevice &QAudioDevice::operator=(QAudioDevice &&other)
other 를 이 QAudioDevice 객체로 이동합니다.
QAudioDevice &QAudioDevice::operator=(const QAudioDevice &other)
QAudioDevice 객체를 other 과 동일하게 설정합니다.
bool QAudioDevice::operator==(const QAudioDevice &other) const
이 ` QAudioDevice ` 클래스가 ` other`과 동일한 오디오 장치를 나타내는 경우 `true`를 반환합니다.
© 2026 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 the GNU 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.