VoxelEngine
 
Loading...
Searching...
No Matches
engine::AudioManager Class Reference

Public Member Functions

bool preload (const std::string &path, const std::string &key, AudioType type)
 Preloads an audio file for future use.
 
Audio playEffect (const std::string &key, AudioSettings settings=AudioSettings())
 Plays a sound effect. Sound effects are short, one-off sounds.
 
Audio playMusic (const std::string &key, AudioSettings settings=AudioSettings())
 Plays a music track. Music tracks are long, and in case of background repeating sounds.
 
void destroyAll ()
 
void updatePositionalAudio (glm::vec3 listenerPos, glm::vec3 listenerDir, glm::vec3 listenerVel)
 

Static Public Member Functions

static AudioManagerGet ()
 

Friends

class Audio
 

Member Function Documentation

◆ playEffect()

Audio AudioManager::playEffect ( const std::string &  key,
AudioSettings  settings = AudioSettings() 
)

Plays a sound effect. Sound effects are short, one-off sounds.

Parameters
keyThe identifier of the audio to play (specified in preload).
settingsThe settings for the sound effect.
Returns
The audio object for the sound effect.
Exceptions
std::runtime_errorif the audio file is not preloaded.

◆ playMusic()

Audio AudioManager::playMusic ( const std::string &  key,
AudioSettings  settings = AudioSettings() 
)

Plays a music track. Music tracks are long, and in case of background repeating sounds.

Parameters
keyThe identifier of the audio to play (specified in preload).
settingsThe settings for the music track.
Returns
The audio object for the music track.
Exceptions
std::runtime_errorif the audio file is not preloaded.
Note
If the audio is already playing, it will start from the beginning.

◆ preload()

bool AudioManager::preload ( const std::string &  path,
const std::string &  key,
AudioType  type 
)

Preloads an audio file for future use.

Parameters
pathThe path to the audio file.
keyThe identifier for this audio for future use.
typeThe type of audio file.
Returns
True if the audio file was preloaded successfully, false if the key already exists.
Exceptions
std::runtime_errorif the audio file cannot be loaded.

The documentation for this class was generated from the following files: