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は、位置や向きに依存しない音を表す。リスナーの位置や向きに依存しない背景音(音楽など)によく使われます。

メンバー型ドキュメント

enum QAmbientSound::Loops

以下の値を使用して再生ループを制御できます:

定数説明
QAmbientSound::Infinite-1無限ループ
QAmbientSound::Once11回実行したら再生を停止する

プロパティの説明

autoPlay : bool

ソースが指定されたときにサウンドを自動的に再生開始するかどうかを決定する。

デフォルト値はtrue

アクセス関数:

bool autoPlay() const
void setAutoPlay(bool autoPlay)

Notifierシグナル:

void autoPlayChanged()

loops : int

プレーヤーが停止するまでに何回サウンドを再生するかを決定する。現在のサウンドを永遠にループ再生するには、QAmbientSound::Infinite を設定します。

デフォルト値は1

アクセス関数:

int loops() const
void setLoops(int loops)

Notifierシグナル:

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)

Notifierシグナル

void volumeChanged()

メンバ関数ドキュメント

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

engine 用のステレオ音源を作成する。

QAudioEngine *QAmbientSound::engine() const

このサウンドに関連するエンジンを返します。

[slot] void QAmbientSound::pause()

サウンド再生を一時停止する。play() を呼び出すと再生を続行します。

[slot] void QAmbientSound::play()

サウンドの再生を開始します。すでに音が再生されている場合は何もしません。

[slot] void QAmbientSound::stop()

サウンドの再生を停止し、現在の位置と現在のループカウントを0にリセットする。play ()を呼び出すと、サウンドファイルの先頭から再生を開始する。

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