Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

QAmbientSound Class

A stereo overlay sound. More...

Header: #include <QAmbientSound>
CMake: find_package(Qt6 REQUIRED COMPONENTS SpatialAudio)
target_link_libraries(mytarget PRIVATE Qt6::SpatialAudio)
qmake: QT += spatialaudio
Inherits: QObject

Public Types

enum Loops { Infinite, Once }

Properties

Public Functions

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

Public Slots

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

Signals

Detailed Description

QAmbientSound represents a position and orientation independent sound. It's commonly used for background sounds (e.g. music) that is supposed to be independent of the listeners position and orientation.

Member Type Documentation

enum QAmbientSound::Loops

Lets you control the playback loop using the following values:

Constant Value Description
QAmbientSound::Infinite -1 Loops infinitely
QAmbientSound::Once 1 Stops playback after running once

Property Documentation

autoPlay : bool

Determines whether the sound should automatically start playing when a source gets specified.

The default value is true.

Access functions:

bool autoPlay() const
void setAutoPlay(bool autoPlay)

Notifier signal:

void autoPlayChanged()

loops : int

Determines how many times the sound is played before the player stops. Set to QAmbientSound::Infinite to play the current sound in a loop forever.

The default value is 1.

Access functions:

int loops() const
void setLoops(int loops)

Notifier signal:

void loopsChanged()

source : QUrl

The source file for the sound to be played.

Access functions:

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

Notifier signal:

void sourceChanged()

volume : float

Defines the volume of the sound.

Values between 0 and 1 will attenuate the sound, while values above 1 provide an additional gain boost.

Access functions:

float volume() const
void setVolume(float volume)

Notifier signal:

void volumeChanged()

Member Function Documentation

QAmbientSound::QAmbientSound(QAudioEngine *engine)

Creates a stereo sound source for engine.

[slot] void QAmbientSound::pause()

Pauses sound playback. Calling play() will continue playback.

[slot] void QAmbientSound::play()

Starts playing back the sound. Does nothing if the sound is already playing.

[slot] void QAmbientSound::stop()

Stops sound playback and resets the current position and current loop count to 0. Calling play() will start playback at the beginning of the sound file.

QAudioEngine *QAmbientSound::engine() const

Returns the engine associated with this sound.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded