Changeset 4203 in orxonox.OLD
- Timestamp:
- May 17, 2005, 1:47:04 AM (19 years ago)
- Location:
- orxonox/branches/openAL/src/lib/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/openAL/src/lib/sound/sound_engine.cc
r4200 r4203 12 12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 15 code has been taken from http://www.devmaster.net/articles.php?catID=6 16 The code has been applied to our needs, and many things have been changed. 14 17 */ 15 18 … … 20 23 #include "p_node.h" 21 24 #include "list.h" 25 #include "AL/alc.h" 22 26 23 27 using namespace std; … … 38 42 ALvoid* data; 39 43 ALsizei freq; 40 44 45 ALenum result; 46 47 // generate a Buffer 41 48 alGenBuffers(1, &this->bufferID); 49 if ((result = alGetError()) != AL_NO_ERROR) 50 SoundEngine::PrintALErrorString(result); 51 52 // read in the wav data 42 53 alutLoadWAVFile((ALbyte*)fileName, &format, &data, &this->size, &freq, &this->loop); 54 if ((result = alGetError()) != AL_NO_ERROR) 55 SoundEngine::PrintALErrorString(result); 56 57 // send the loaded wav data to the buffer 43 58 alBufferData(this->bufferID, format, data, this->size, freq); 59 if ((result = alGetError()) != AL_NO_ERROR) 60 SoundEngine::PrintALErrorString(result); 61 62 // remove the wav data (redundant) 44 63 alutUnloadWAV(format, data, this->size, freq); 64 if ((result = alGetError()) != AL_NO_ERROR) 65 SoundEngine::PrintALErrorString(result); 45 66 } 46 67 … … 59 80 SoundSource::SoundSource(SoundBuffer* buffer, PNode* sourceNode) 60 81 { 82 ALenum result; 83 84 // adding the Source to the SourcesList of the SoundEngine 61 85 SoundEngine::getInstance()->addSource(this); 62 86 … … 65 89 66 90 alGenSources(1, &this->sourceID); 67 68 if(alGetError() != AL_NO_ERROR) 69 PRINTF(1)("error initializing SoundSource\n"); //return AL_FALSE; 70 91 if ((result = alGetError()) != AL_NO_ERROR) 92 SoundEngine::PrintALErrorString(result); 71 93 alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID()); 72 94 alSourcef (this->sourceID, AL_PITCH, 1.0 ); 73 95 alSourcef (this->sourceID, AL_GAIN, 1.0 ); 74 // alSourcefv(sourceID, AL_POSITION, SourcePos);75 // alSourcefv(sourceID, AL_VELOCITY, SourceVel);76 96 alSourcei (sourceID, AL_LOOPING, true ); 77 97 } … … 230 250 } 231 251 252 void SoundEngine::PrintALErrorString(ALenum err) 253 { 254 switch(err) 255 { 256 case AL_NO_ERROR: 257 PRINTF(4)("AL_NO_ERROR\n"); 258 break; 259 260 case AL_INVALID_NAME: 261 PRINTF(2)("AL_INVALID_NAME\n"); 262 break; 263 264 case AL_INVALID_ENUM: 265 PRINTF(2)("AL_INVALID_ENUM\n"); 266 break; 267 268 case AL_INVALID_VALUE: 269 PRINTF(2)("AL_INVALID_VALUE\n"); 270 break; 271 272 case AL_INVALID_OPERATION: 273 PRINTF(2)("AL_INVALID_OPERATION\n"); 274 break; 275 276 case AL_OUT_OF_MEMORY: 277 PRINTF(2)("AL_OUT_OF_MEMORY\n"); 278 break; 279 }; 280 } 281 282 283 void SoundEngine::PrintALCErrorString(ALenum err) 284 { 285 switch(err) 286 { 287 case ALC_NO_ERROR: 288 PRINTF(4)("AL_NO_ERROR\n"); 289 break; 290 291 case ALC_INVALID_DEVICE: 292 PRINTF(2)("ALC_INVALID_DEVICE\n"); 293 break; 294 295 case ALC_INVALID_CONTEXT: 296 PRINTF(2)("ALC_INVALID_CONTEXT\n"); 297 break; 298 299 case ALC_INVALID_ENUM: 300 PRINTF(2)("ALC_INVALID_ENUM\n"); 301 break; 302 303 case ALC_INVALID_VALUE: 304 PRINTF(2)("ALC_INVALID_VALUE\n"); 305 break; 306 307 case ALC_OUT_OF_MEMORY: 308 PRINTF(2)("ALC_OUT_OF_MEMORY\n"); 309 break; 310 }; 311 } -
orxonox/branches/openAL/src/lib/sound/sound_engine.h
r4200 r4203 12 12 13 13 14 #define SOUND_DOPPLER_FACTOR 0. 114 #define SOUND_DOPPLER_FACTOR 0.01 15 15 #define SOUND_DOPPLER_VELOCITY 500000000 16 16 … … 81 81 void update(void); 82 82 83 84 // error handling: 85 static void PrintALErrorString(ALenum err); 86 static void PrintALCErrorString(ALenum err); 87 83 88 private: 84 89 SoundEngine(void);
Note: See TracChangeset
for help on using the changeset viewer.