Changeset 5386 in orxonox.OLD for trunk/src/lib/sound/sound_buffer.cc
- Timestamp:
- Oct 15, 2005, 11:44:14 PM (19 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/sound/sound_buffer.cc
r5382 r5386 10 10 11 11 ### File Specific: 12 main-programmer: ...12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 14 */ 15 15 16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SOUND 17 17 18 #include "proto_class.h" 18 #include "sound_buffer.h" 19 20 #include "sound_engine.h" 21 19 22 20 23 using namespace std; 21 24 22 25 26 ////////////////// 27 /* SOUND-BUFFER */ 28 ////////////////// 23 29 /** 24 * standard constructor25 * @ todo this constructor is not jet implemented - do it26 */27 ProtoClass::ProtoClass ()30 * Creates a Soundbuffer out of an inputfile 31 * @param fileName The name of the File 32 */ 33 SoundBuffer::SoundBuffer(const char* fileName) 28 34 { 29 this->setClassID(CL_PROTO_ID, "ProtoClass"); 35 this->setClassID(CL_SOUND_BUFFER, "SoundBuffer"); 36 this->setName(fileName); 30 37 31 /* If you make a new class, what is most probably the case when you write this file 32 don't forget to: 33 1. Add the new file new_class.cc to the ./src/Makefile.am 34 2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS 38 SoundEngine::getInstance()->addBuffer(this); 35 39 36 Advanced Topics: 37 - if you want to let your object be managed via the ObjectManager make sure to read 38 the object_manager.h header comments. You will use this most certanly only if you 39 make many objects of your class, like a weapon bullet. 40 */ 40 ALenum format; 41 ALvoid* data; 42 ALsizei freq; 43 44 ALenum result; 45 46 // generate a Buffer 47 alGenBuffers(1, &this->bufferID); 48 if ((result = alGetError()) != AL_NO_ERROR) 49 SoundEngine::PrintALErrorString(result); 50 51 // read in the wav data 52 /* according to http://www.edenwaith.com/products/pige/tutorials/openal.php the alutLoadWAVFile differs from platform to platform*/ 53 #ifdef __APPLE__ 54 alutLoadWAVFile((ALbyte*)fileName, &format, &data, &this->size, &freq); 55 #elif defined __WIN32__ 56 alutLoadWAVFile(fileName, &format, &data, &size, &freq, &this->loop); 57 #else 58 alutLoadWAVFile((ALbyte*)fileName, &format, &data, &this->size, &freq, &this->loop); 59 #endif 60 if ((result = alGetError()) != AL_NO_ERROR) 61 SoundEngine::PrintALErrorString(result); 62 63 // send the loaded wav data to the buffer 64 alBufferData(this->bufferID, format, data, this->size, freq); 65 if ((result = alGetError()) != AL_NO_ERROR) 66 SoundEngine::PrintALErrorString(result); 67 68 // remove the wav data (redundant) 69 alutUnloadWAV(format, data, this->size, freq); 70 if ((result = alGetError()) != AL_NO_ERROR) 71 SoundEngine::PrintALErrorString(result); 41 72 } 42 73 43 44 /** 45 * standard deconstructor 46 */ 47 ProtoClass::~ProtoClass () 74 SoundBuffer::~SoundBuffer() 48 75 { 49 // delete what has to be deleted here 76 // SoundEngine::getInstance()->removeBuffer(this); 77 alDeleteBuffers(1, &this->bufferID); 50 78 }
Note: See TracChangeset
for help on using the changeset viewer.