SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::audio::Sound Class Referencefinal

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
 
Soundoperator= (const Sound &other)
 
Soundoperator= (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"}
 

Detailed Description

A class representing a sound that can be played.

Constructor & Destructor Documentation

◆ Sound()

spark::audio::Sound::Sound ( const std::filesystem::path & file)
explicit

Instantiates a new playable sound.

Parameters
fileThe path to the sound file.

Member Function Documentation

◆ isPlaying()

bool spark::audio::Sound::isPlaying ( ) const
nodiscard

Checks if the sound is currently playing.

Returns
true if the sound is currently playing, false otherwise.

◆ loop()

bool spark::audio::Sound::loop ( ) const
nodiscard

Gets whether the sound is currently playing.

Returns
A boolean indicating whether the sound is currently playing.

◆ pitch()

float spark::audio::Sound::pitch ( ) const
nodiscard

Gets the pitch of the sound.

Returns
A float indicating the pitch of the sound.

◆ setLoop()

void spark::audio::Sound::setLoop ( bool loop)

Sets the sound to loop or not.

Parameters
loopA boolean indicating whether the sound should loop or not.

◆ setPitch()

void spark::audio::Sound::setPitch ( float pitch)

Sets the pitch of the sound.

Parameters
pitchA float indicating the pitch of the sound.

◆ setVolume()

void spark::audio::Sound::setVolume ( float volume)

Sets the volume of the sound.

Parameters
volumeA float between 0 and 100 indicating the volume of the sound.

◆ volume()

float spark::audio::Sound::volume ( ) const
nodiscard

Gets the volume of the sound.

Returns
A float between 0 and 100 indicating the volume of the sound.