이 페이지에서

QAmbientSound Class

스테레오 오버레이 사운드. 더 보기...

헤더: #include <QAmbientSound>
CMake: find_package(Qt6 REQUIRED COMPONENTS SpatialAudio)
target_link_libraries(mytarget PRIVATE Qt6::SpatialAudio)
qmake: QT += spatialaudio
상속: QObject

공개 유형

enum Loops { Infinite, Once }

속성

공개 함수

QAmbientSound(QAudioEngine *engine)
bool autoPlay() const
QAudioEngine *engine() const
int loops() const
void setAutoPlay(bool autoPlay)
void setLoops(int loops)
void setSource(const QUrl &url)
void setVolume(float volume)
QUrl source() const
float volume() const

공개 슬롯

void pause()
void play()
void stop()

신호

상세 설명

QAmbientSound는 위치와 방향에 구애받지 않는 사운드를 나타냅니다. 이 클래스는 청취자의 위치나 방향과 무관하게 재생되어야 하는 배경음(예: 음악)에 주로 사용됩니다.

참고: QAmbientSound는 QAudioEngine 가 OutputMode::Stereo 또는 OutputMode::Headphone을 사용할 때만 활성화됩니다.

멤버 유형 문서

enum QAmbientSound::Loops

다음 값을 사용하여 재생 루프를 제어할 수 있습니다:

상수값설명
QAmbientSound::Infinite-1무한 반복
QAmbientSound::Once1한 번 재생된 후 중지됩니다

속성 설명

autoPlay : bool

소스가 지정되면 소리가 자동으로 재생될지 여부를 결정합니다.

기본값은 ` true`입니다.

액세스 함수:

bool autoPlay() const
void setAutoPlay(bool autoPlay)

알림 신호:

void autoPlayChanged()

loops : int

플레이어가 중지되기 전까지 소리가 몇 번 재생될지 결정합니다. ‘ QAmbientSound::Infinite ’로 설정하면 현재 소리가 무한 루프로 재생됩니다.

기본값은 1 입니다.

액세스 함수:

int loops() const
void setLoops(int loops)

알림 신호:

void loopsChanged()

source : QUrl

재생할 사운드의 소스 파일입니다.

액세스 함수:

QUrl source() const
void setSource(const QUrl &url)

알림 신호:

void sourceChanged()

volume : float

소리의 음량을 설정합니다.

0에서 1 사이의 값은 소리를 줄여주며, 1보다 큰 값은 추가적인 게인 부스트를 제공합니다.

액세스 함수:

float volume() const
void setVolume(float volume)

알림 신호:

void volumeChanged()

멤버 함수 문서

[explicit] QAmbientSound::QAmbientSound(QAudioEngine *engine)

engine 용 스테레오 음원을 생성합니다.

참고: 유효한 QAudioEngine

QAudioEngine *QAmbientSound::engine() const

이 사운드와 연결된 엔진을 반환합니다.

[slot] void QAmbientSound::pause()

소리 재생을 일시 중지합니다. ` play()`를 호출하면 재생을 계속합니다.

[slot] void QAmbientSound::play()

소리 재생을 시작합니다. 이미 소리가 재생 중이라면 아무 작업도 수행하지 않습니다.

[slot] void QAmbientSound::stop()

사운드 재생을 중지하고 현재 위치와 현재 루프 횟수를 0으로 재설정합니다. ` play()`를 호출하면 사운드 파일의 시작 부분부터 재생을 시작합니다.

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