Changeset 9803 in orxonox.OLD for branches/new_class_id/src/lib/sound/sound_buffer_data.cc
- Timestamp:
- Sep 24, 2006, 12:58:19 PM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/sound/sound_buffer_data.cc
r9801 r9803 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SOUND 17 17 18 #include "sound_buffer .h"18 #include "sound_buffer_data.h" 19 19 20 20 #include "sound_engine.h" … … 35 35 namespace OrxSound 36 36 { 37 ObjectListDefinition(SoundBuffer );37 ObjectListDefinition(SoundBufferData); 38 38 ////////////////// 39 39 /* SOUND-BUFFER */ 40 40 ////////////////// 41 41 /** 42 * Creates a Soundbufferout of an inputfile42 * @brief Creates a SoundbufferData out of an inputfile 43 43 * @param fileName The name of the File 44 44 */ 45 SoundBuffer ::SoundBuffer(const std::string& fileName)45 SoundBufferData::SoundBufferData() 46 46 { 47 this->registerObject(this, SoundBuffer ::_objectList);48 this-> setName(fileName);47 this->registerObject(this, SoundBufferData::_objectList); 48 this->bufferID = 0; 49 49 50 // generate a Buffer 51 alGenBuffers(1, &this->bufferID); 52 SoundEngine::checkError("Generate Buffer", __LINE__); 53 if (!nocaseCmp(fileName.substr(fileName.size() - 3), "WAV")) 54 { 55 this->loadWAV(fileName); 56 } 57 else if (!nocaseCmp(fileName.substr(fileName.size() - 3), "OGG")) 58 this->loadOGG(fileName); 50 this->size = 0; 51 this->loop = AL_FALSE; 52 59 53 60 54 } 61 55 62 SoundBuffer ::~SoundBuffer()56 SoundBufferData::~SoundBufferData() 63 57 { 64 58 // SoundEngine::getInstance()->removeBuffer(this); … … 68 62 69 63 /** 64 * @brief check the File-extension and loads either Wav of Ogg 65 * @param fileName the Name of the File to load. 66 * @returns true on success (file found, and loaded.) 67 */ 68 bool SoundBufferData::load(const std::string& fileName) 69 { 70 // generate a Buffer 71 alGenBuffers(1, &this->bufferID); 72 SoundEngine::checkError("Generate Buffer", __LINE__); 73 if (!nocaseCmp(fileName.substr(fileName.size() - 3), "WAV")) 74 { 75 return this->loadWAV(fileName); 76 } 77 else if (!nocaseCmp(fileName.substr(fileName.size() - 3), "OGG")) 78 return this->loadOGG(fileName); 79 else 80 return false; 81 } 82 83 /** 70 84 * @brief loads a Waveform from the local fileSystem into this Source. 71 85 * @param fileName the Name of the File to Load. 72 86 * @returns true on success. 73 87 */ 74 bool SoundBuffer ::loadWAV(const std::string& fileName)88 bool SoundBufferData::loadWAV(const std::string& fileName) 75 89 { 76 90 SDL_AudioSpec wavSpec; … … 93 107 } 94 108 #endif 95 alBufferData(this->bufferID, SoundBuffer ::sdlAudioSpecToAlFormat(&wavSpec),109 alBufferData(this->bufferID, SoundBufferData::sdlAudioSpecToAlFormat(&wavSpec), 96 110 wavBuffer, wavLength, wavSpec.freq); 97 111 … … 112 126 * @returns true on success (file exists and is fully loaded), false otherwise. 113 127 */ 114 bool SoundBuffer ::loadOGG(const std::string& fileName)128 bool SoundBufferData::loadOGG(const std::string& fileName) 115 129 { 116 130 void* ovdata; … … 156 170 * @returns the AL_FORMAT 157 171 */ 158 ALenum SoundBuffer ::sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec)172 ALenum SoundBufferData::sdlAudioSpecToAlFormat(const SDL_AudioSpec* audiospec) 159 173 { 160 174 assert (audiospec != NULL);
Note: See TracChangeset
for help on using the changeset viewer.