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 | autoPlayChanged() |
| void | loopsChanged() |
| void | sourceChanged() |
| void | volumeChanged() |
詳細な説明
QAmbientSound は、位置や向きに依存しないサウンドを表します。これは、リスナーの位置や向きとは無関係であるべき背景音(例:音楽)によく使用されます。
注:QAmbientSound は 、QAudioEngine が OutputMode::Stereo または OutputMode::Headphone を使用している場合にのみ有効です。
メンバ型のドキュメント
enum QAmbientSound::Loops
以下の値を使用して、再生ループを制御できます。
| 定数 | 値 | 説明 |
|---|---|---|
QAmbientSound::Infinite | -1 | 無限にループします |
QAmbientSound::Once | 1 | 1回再生した後に停止します |
プロパティのドキュメント
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.