SPARK
0.1.0
A general purpose game engine written in C++.
|
A class representing a sound that can be played. More...
#include <Sound.h>
Public Member Functions | |
Sound (const std::filesystem::path &file) | |
Instantiates a new playable sound. | |
Sound (const Sound &other) | |
Sound (Sound &&other) noexcept | |
Sound & | operator= (const Sound &other) |
Sound & | operator= (Sound &&other) noexcept |
void | play () |
Starts playing the sound. | |
void | pause () |
Pauses the sound. | |
void | stop () |
Stops the sound and resets it to the beginning. | |
void | restart () |
Restarts the sound from the beginning. | |
bool | loop () const |
Gets whether the sound is currently playing. | |
float | volume () const |
Gets the volume of the sound. | |
float | pitch () const |
Gets the pitch of the sound. | |
bool | isPlaying () const |
Checks if the sound is currently playing. | |
void | setLoop (bool loop) |
Sets the sound to loop or not. | |
void | setVolume (float volume) |
Sets the volume of the sound. | |
void | setPitch (float pitch) |
Sets the pitch of the sound. | |
Static Public Attributes | |
static const std::vector< std::string_view > | supportedExtensions = {".wav", ".ogg"} |
A class representing a sound that can be played.
|
explicit |
Instantiates a new playable sound.
file | The path to the sound file. |
|
nodiscard |
Checks if the sound is currently playing.
true
if the sound is currently playing, false
otherwise.
|
nodiscard |
Gets whether the sound is currently playing.
|
nodiscard |
Gets the pitch of the sound.
void spark::audio::Sound::setLoop | ( | bool | loop | ) |
Sets the sound to loop or not.
loop | A boolean indicating whether the sound should loop or not. |
void spark::audio::Sound::setPitch | ( | float | pitch | ) |
Sets the pitch of the sound.
pitch | A float indicating the pitch of the sound. |
void spark::audio::Sound::setVolume | ( | float | volume | ) |
Sets the volume of the sound.
volume | A float between 0 and 100 indicating the volume of the sound. |
|
nodiscard |
Gets the volume of the sound.