Class for handling sound effects.
More...
#include <SFX.hpp>
|
| | SFX (const std::string &path) |
| | Constructor that initializes the SFX object and loads the sound effect from the specified file path. More...
|
| |
|
| SFX (const SFX &)=delete |
| | Deleted copy constructor to prevent copying of SFX objects.
|
| |
|
SFX & | operator= (const SFX &)=delete |
| | Deleted copy assignment operator to prevent copying of SFX objects.
|
| |
| int | GetVolume () const |
| | Retrieves the current volume of the sound effect. More...
|
| |
| void | SetVolume (int volume) |
| | Sets the volume of the background music. More...
|
| |
| void | LoadMedia (const std::string &path) |
| | Loads the sound effect from the specified file path. More...
|
| |
| void | VolumeUp (int step=1) |
| | Increases the volume of the sound effect by one. More...
|
| |
| void | VolumeDown (int step=1) |
| | Decreases the volume of the sound effect by one. More...
|
| |
| void | Play (int loop=0, int duration=-1) |
| | Plays the sound effect. More...
|
| |
| void | FadeIn (unsigned int tick, int oop=-1, unsigned int duration=-1) |
| | Fades in the sound effect gradually. More...
|
| |
Class for handling sound effects.
- See also
- One should use Util::BGM for long audio files since it loads audio from disk instead of memory. (https://wiki.libsdl.org/SDL2_mixer/Mix_LoadMUS#remarks)
◆ SFX()
| Util::SFX::SFX |
( |
const std::string & |
path | ) |
|
|
explicit |
Constructor that initializes the SFX object and loads the sound effect from the specified file path.
- Parameters
-
| path | The file path of the sound effect to be loaded. |
◆ FadeIn()
| void Util::SFX::FadeIn |
( |
unsigned int |
tick, |
|
|
int |
oop = -1, |
|
|
unsigned int |
duration = -1 |
|
) |
| |
Fades in the sound effect gradually.
- Parameters
-
| tick | The duration of the fade-in effect, in milliseconds. |
| loop | The number of times the sound effect will loop after the fade-in is complete.
A value of -1 means it will loop indefinitely. |
| duration | The duration of the sound effect in milliseconds.
A value of -1 means it will play the entire sound effect. |
◆ GetVolume()
| int Util::SFX::GetVolume |
( |
| ) |
const |
Retrieves the current volume of the sound effect.
- Returns
- The current volume of the sound effect.
◆ LoadMedia()
| void Util::SFX::LoadMedia |
( |
const std::string & |
path | ) |
|
Loads the sound effect from the specified file path.
- Parameters
-
| path | The file path of the sound effect to be loaded. |
◆ Play()
| void Util::SFX::Play |
( |
int |
loop = 0, |
|
|
int |
duration = -1 |
|
) |
| |
Plays the sound effect.
- Parameters
-
| loop | The number of times the sound effect will loop.
A value of 0 means it will play once (no looping). |
| duration | The duration of the sound effect in milliseconds.
A value of -1 means it will play the entire sound effect. |
◆ SetVolume()
| void Util::SFX::SetVolume |
( |
int |
volume | ) |
|
Sets the volume of the background music.
- Parameters
-
| volume | The desired volume level for the background music. The valid range is [0, 128].
A value of 0 mutes the music, and a value of 128 sets the maximum volume. |
◆ VolumeDown()
| void Util::SFX::VolumeDown |
( |
int |
step = 1 | ) |
|
Decreases the volume of the sound effect by one.
- Parameters
-
| step | The amount to decrease the volume by. |
◆ VolumeUp()
| void Util::SFX::VolumeUp |
( |
int |
step = 1 | ) |
|
Increases the volume of the sound effect by one.
- Parameters
-
| step | The amount to increase the volume by. |
The documentation for this class was generated from the following file: