|
utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
|
Represents a playable audio source managed by AudioManager. More...
#include <headers/utility/sound/audio_source.hpp>
Public Member Functions | |
| AudioSource (uint32_t sourceID, AudioManager &manager) | |
| Creates a new audio source. | |
| ~AudioSource () | |
| Destroys the audio source. | |
| void | play () |
| Starts or resumes audio playback. | |
| void | pause () |
| Pauses audio playback. | |
| void | stop () |
| Stops audio playback. | |
| void | setBuffer (std::shared_ptr< AudioBuffer > buffer) |
| Assigns an audio buffer to this source. | |
| void | setLooping (bool loop) |
| Enables or disables looping playback. | |
| void | setPitch (float pitch) |
| Sets the playback pitch. | |
| void | setGain (float gain) |
| Sets the playback gain. | |
| uint32_t | sourceID () const |
| Returns the unique identifier of this audio source. | |
Represents a playable audio source managed by AudioManager.
This class provides a high-level interface for controlling audio playback, including starting, stopping, pausing, and modifying playback properties such as gain, pitch, and looping state.
AudioSource instances do not interact with OpenAL directly. Instead, they submit commands to the associated AudioManager, which processes them asynchronously on a dedicated audio thread.
An AudioSource owns a unique source identifier used by AudioManager to reference the underlying OpenAL source object.
Definition at line 54 of file audio_source.hpp.
| utility::sound::AudioSource::AudioSource | ( | uint32_t | sourceID, |
| AudioManager & | manager | ||
| ) |
Creates a new audio source.
| sourceID | Unique identifier assigned by AudioManager. |
| manager | Reference to the AudioManager responsible for processing audio commands. |
Definition at line 25 of file audio_source.cpp.
| utility::sound::AudioSource::~AudioSource | ( | ) |
Destroys the audio source.
The associated OpenAL source is released through AudioManager.
Definition at line 32 of file audio_source.cpp.
| void utility::sound::AudioSource::pause | ( | ) |
Pauses audio playback.
Playback can later be resumed by calling play().
Definition at line 43 of file audio_source.cpp.
| void utility::sound::AudioSource::play | ( | ) |
Starts or resumes audio playback.
Playback is performed asynchronously by the audio thread.
Definition at line 37 of file audio_source.cpp.
| void utility::sound::AudioSource::setBuffer | ( | std::shared_ptr< AudioBuffer > | buffer | ) |
Assigns an audio buffer to this source.
The buffer contains the decoded audio data to be played.
| buffer | Shared audio buffer associated with this source. |
Definition at line 55 of file audio_source.cpp.
| void utility::sound::AudioSource::setGain | ( | float | gain | ) |
Sets the playback gain.
| gain | Volume multiplier. |
Definition at line 80 of file audio_source.cpp.
| void utility::sound::AudioSource::setLooping | ( | bool | loop | ) |
Enables or disables looping playback.
| loop | True to enable looping, false otherwise. |
Definition at line 64 of file audio_source.cpp.
| void utility::sound::AudioSource::setPitch | ( | float | pitch | ) |
Sets the playback pitch.
Values greater than 1.0 increase playback speed and pitch, while values lower than 1.0 decrease them.
| pitch | Pitch multiplier. |
Definition at line 72 of file audio_source.cpp.
| uint32_t utility::sound::AudioSource::sourceID | ( | ) | const |
Returns the unique identifier of this audio source.
Definition at line 88 of file audio_source.cpp.
| void utility::sound::AudioSource::stop | ( | ) |
Stops audio playback.
Stopping playback resets the playback position to the beginning of the audio stream.
Definition at line 49 of file audio_source.cpp.