29 #include "nomlib/audio/AL/SoundBuffer.hpp"
34 SoundBuffer::SoundBuffer (
void ) : buffer ( 0 )
36 NOM_LOG_TRACE ( NOM );
38 AL_CHECK_ERR ( alGenBuffers ( 1, &this->
buffer ) );
41 SoundBuffer::~SoundBuffer (
void )
43 NOM_LOG_TRACE ( NOM );
46 for (
auto it = this->
sounds.begin(); it != this->
sounds.end(); ++it )
54 AL_CHECK_ERR ( alDeleteBuffers ( 1, &this->
buffer ) );
68 bool SoundBuffer::load (
const std::string& filename )
72 if ( ! fp.open ( filename ) )
74 NOM_LOG_ERR ( NOM,
"Could not load audio: " + filename );
78 if ( ! fp.read ( this->samples ) )
80 NOM_LOG_ERR ( NOM,
"Could not read audio samples: " + filename );
uint32 getChannelCount(void) const
Obtain number of channels used by audio file.
uint32 getChannelFormat(void) const
Obtain channel format; used internally by OpenAL.
uint32 get(void) const
Obtain buffer data.
uint32 getSampleRate(void) const
Obtain audio sampling rate; this is the number of samples per second.
std::set< Sound * > sounds
Internal list of sounds loaded onto a buffer object.
void detach(Sound *sound) const
Internally used for detaching a sound from our list.
uint32 buffer
Used internally by OpenAL for identification of audio buffer.
uint32 getDuration(void) const
void attach(Sound *sound) const
Internally used for attaching a sound to our list.
size_t getDataByteSize(void) const
Obtain audio data size in bytes.
const SoundBuffer * buffer
Buffer that this sound is attached to.
size_t getSampleCount(void) const
Obtain number of samples in audio file.
std::vector< int16 > samples
We load our audio data into this buffer.