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 }

속성

공공 기능

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는 시스템에서 입력 또는 재생에 사용할 수 있는 오디오 장치를 설명합니다.

QAudioDevice는 Qt에서 장치와 통신하는 클래스( QAudioSource, QAudioSink 등)를 구성하는 데 사용됩니다. 또한 캡처 세션이나 미디어 재생 중에 사용할 입력 또는 출력 장치를 결정하는 데에도 사용됩니다.

해당 물리적 장치의 연결이 끊어지거나 설정이 수정되더라도 QAudioDevice 인스턴스는 수명 내내 해당 프로퍼티를 유지합니다. 업데이트된 속성을 추적하려면 사용자는 관련 신호가 발생하면 QMediaDevices 에서 QAudioDevice의 새 인스턴스를 로드해야 합니다.

각 장치가 지원하는 포맷을 쿼리할 수도 있습니다. 여기서 포맷이란 채널 수, 샘플 레이트, 샘플 유형으로 구성된 집합입니다. 포맷은 QAudioFormat 클래스로 표시됩니다.

이러한 각 파라미터에 대해 디바이스에서 지원하는 값은 minimumChannelCount(), maximumChannelCount(), minimumSampleRate(), maximumSampleRate() 및 supportedSampleFormats()를 사용하여 가져올 수 있습니다. 지원되는 조합은 오디오 디바이스 기능에 따라 다릅니다. 특정 형식이 필요한 경우 isFormatSupported()를 사용하여 장치에서 해당 형식을 지원하는지 확인할 수 있습니다. 예를 들어

{ sourceFile.setFileName("/tmp/test.raw"); sourceFile.open(QIODevice::읽기 전용);    QAudioFormat format; // 포맷을 설정합니다, 예: format.setSampleRate(8000); format.setChannelCount(1); format.setSampleFormat(QAudioFormat::UInt8);    QAudioDevice 정보(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 &디바이스: 디바이스)    qDebug() << "Device: " << device.description();

이 코드 샘플에서는 사운드를 출력할 수 있는 모든 디바이스, 즉 지원되는 형식의 오디오 스트림을 재생할 수 있는 모든 디바이스를 반복합니다. 찾은 각 장치에 대해 deviceName()을 출력하기만 하면 됩니다.

QAudioSink, QAudioSource, QAudioFormat참조하세요 .

멤버 유형 문서

enum QAudioDevice::Mode

이 장치의 모드를 설명합니다.

Constant설명
QAudioDevice::Null0널 장치입니다.
QAudioDevice::Input1입력 장치입니다.
QAudioDevice::Output2출력 장치입니다.

속성 문서

[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()

널 QAudioDevice 객체를 생성합니다.

QAudioDevice::QAudioDevice(const QAudioDevice &other)

other 의 복사본을 생성합니다.

[noexcept] QAudioDevice::QAudioDevice(QAudioDevice &&other)

other 에서 구조체를 이동합니다.

[noexcept] QAudioDevice::~QAudioDevice()

이 오디오 장치 정보를 삭제합니다.

QAudioFormat::ChannelConfig QAudioDevice::channelConfiguration() const

디바이스의 채널 구성을 반환합니다.

bool QAudioDevice::isFormatSupported(const QAudioFormat &settings) const

제공된 settingsQAudioDevice 에 설명된 오디오 장치에서 지원되는 경우 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::모드에 따라 달라집니다.

일반적인 오디오 시스템은 다음과 같은 것을 제공합니다:

  • 입력 설정: 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를 반환합니다.

© 2025 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.