template class EE::Audio::tSoundManager¶
Overview¶
A basic template to hold sounds and the respective buffer. More…
#include <soundmanager.hpp> template <typename T> class tSoundManager { public: // structs struct sSound; // construction ~tSoundManager(); // methods bool loadFromFile(const T& id, const std::string& filepath); bool loadFromMemory(const T& id, const char* Data, std::size_t SizeInBytes); bool loadFromSamples(const T& id, const Int16* Samples, std::size_t SamplesCount, unsigned int ChannelCount, unsigned int SampleRate); bool loadFromPack(const T& id, Pack* Pack, const std::string& FilePackPath); SoundBuffer& getBuffer(const T& id); Sound* play(const T& id); bool remove(const T& id); Sound& operator[](const T& id); Sound& getFreeSound(const T& id); };
Detailed Documentation¶
A basic template to hold sounds and the respective buffer.
Methods¶
bool loadFromFile(const T& id, const std::string& filepath)
Load the sound from file.
Parameters:
id |
The sound Id |
filepath |
The sound path |
bool loadFromMemory(const T& id, const char* Data, std::size_t SizeInBytes)
Load the sound from memory.
Parameters:
id |
The sound id |
Data |
The pointer to the data |
SizeInBytes |
The size of the file to load |
bool loadFromSamples(const T& id, const Int16* Samples, std::size_t SamplesCount, unsigned int ChannelCount, unsigned int SampleRate)
Load the sound from an array of samples.
Parameters:
id |
The sound id |
Samples |
Pointer to the array of samples in memory |
SamplesCount |
Number of samples in the array |
ChannelCount |
Number of channels (1 = mono, 2 = stereo, …) |
SampleRate |
Sample rate (number of samples to play per second) |
bool loadFromPack(const T& id, Pack* Pack, const std::string& FilePackPath)
Load the sound from a Pack file.
Parameters:
id |
The id to use to identificate the sound |
Pack |
The Pack file |
FilePackPath |
The pack file path |
SoundBuffer& getBuffer(const T& id)
Returns:
The sound buffer of the sound id
Sound* play(const T& id)
Play the sound. This method will open a new channel if the channel seted for the sound is already playing. *
Parameters:
id |
The sound id to play |
bool remove(const T& id)
Remove a sound from the sound manager.
Parameters:
id |
The sound id to remove |
Sound& operator[](const T& id)
Returns:
The sound id if exists
Sound& getFreeSound(const T& id)
Search for the sound id, and return a sound that is not playing, if all the sounds are playing, creates a new sound. *.
Returns:
The sound