Changeset 4597 in orxonox.OLD for orxonox/trunk/src/lib/sound
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (20 years ago)
- Location:
- orxonox/trunk/src/lib/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/sound/sound_engine.cc
r4519 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 40 40 SoundBuffer::SoundBuffer(const char* fileName) 41 41 { 42 this->setClassID(CL_SOUND_BUFFER, "SoundBuffer"); 43 this->setName(fileName); 44 42 45 SoundEngine::getInstance()->addBuffer(this); 43 46 … … 45 48 ALvoid* data; 46 49 ALsizei freq; 47 50 48 51 ALenum result; 49 52 … … 57 60 if ((result = alGetError()) != AL_NO_ERROR) 58 61 SoundEngine::PrintALErrorString(result); 59 62 60 63 // send the loaded wav data to the buffer 61 64 alBufferData(this->bufferID, format, data, this->size, freq); … … 83 86 SoundSource::SoundSource(SoundBuffer* buffer, PNode* sourceNode) 84 87 { 88 this->setClassID(CL_SOUND_SOURCE, "SoundSource"); 89 85 90 ALenum result; 86 91 … … 161 166 \brief standard constructor 162 167 */ 163 SoundEngine::SoundEngine () 164 { 165 this->setClassName ("SoundEngine"); 166 168 SoundEngine::SoundEngine () 169 { 170 this->setClassID(CL_SOUND_ENGINE, "SoundEngine"); 171 this->setName("SoundEngine"); 172 167 173 this->listener = NULL; 168 174 this->bufferList = new tList<SoundBuffer>; … … 179 185 180 186 */ 181 SoundEngine::~SoundEngine () 187 SoundEngine::~SoundEngine () 182 188 { 183 189 SoundEngine::singletonRef = NULL; … … 262 268 { 263 269 if (buffer == enumSource->getBuffer()) 264 270 delete enumSource; 265 271 enumSource = sourceIterator->nextElement(); 266 272 } … … 300 306 { 301 307 alListener3f(AL_POSITION, 302 303 304 308 this->listener->getAbsCoor().x, 309 this->listener->getAbsCoor().y, 310 this->listener->getAbsCoor().z); 305 311 alListener3f(AL_VELOCITY, 306 307 308 312 this->listener->getVelocity().x, 313 this->listener->getVelocity().y, 314 this->listener->getVelocity().z); 309 315 Vector absDirV = this->listener->getAbsDirV(); 310 316 ALfloat orientation [6] = {1,0,0, absDirV.x, absDirV.y, absDirV.z}; … … 321 327 if (likely(enumSource->getNode()!=NULL)) 322 328 { 323 324 325 326 327 328 329 330 329 alSource3f(enumSource->getID(), AL_POSITION, 330 enumSource->getNode()->getAbsCoor().x, 331 enumSource->getNode()->getAbsCoor().y, 332 enumSource->getNode()->getAbsCoor().z); 333 alSource3f(enumSource->getID(), AL_VELOCITY, 334 enumSource->getNode()->getVelocity().x, 335 enumSource->getNode()->getVelocity().y, 336 enumSource->getNode()->getVelocity().z); 331 337 } 332 338 enumSource = iterator->nextElement(); … … 347 353 SoundSource* enumSource = sourceIterator->nextElement(); 348 354 while (enumSource) 349 350 351 352 353 355 { 356 if (enumBuffer == enumSource->getBuffer()) 357 break; 358 enumSource = sourceIterator->nextElement(); 359 } 354 360 delete sourceIterator; 355 361 if (enumSource == NULL) 356 362 ResourceManager::getInstance()->unload(enumBuffer); 357 363 enumBuffer = bufferIterator->nextElement(); 358 364 } … … 402 408 PRINTF(4)("AL_NO_ERROR\n"); 403 409 break; 404 410 405 411 case AL_INVALID_NAME: 406 412 PRINTF(2)("AL_INVALID_NAME\n"); -
orxonox/trunk/src/lib/sound/sound_engine.h
r4519 r4597 1 /*! 1 /*! 2 2 \file sound_engine.h 3 \brief Definition of the SoundEngine singleton Class 3 \brief Definition of the SoundEngine singleton Class 4 4 */ 5 5 … … 20 20 21 21 //! A class that represents a datastructure to play Sounds. 22 class SoundBuffer 22 class SoundBuffer : public BaseObject 23 23 { 24 24 public: … … 37 37 38 38 //! A class that represents a SoundSource 39 class SoundSource 39 class SoundSource : virtual public BaseObject 40 40 { 41 41 public: 42 42 SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL); 43 43 ~SoundSource(void); 44 44 45 45 // user interaction 46 46 void play(); … … 48 48 void pause(); 49 49 void rewind(); 50 50 51 51 // development functions 52 52 /** \returns The ID of this Source */ 53 53 inline ALuint getID(void) const { return this->sourceID; } 54 54 /** \returns the SoundBuffer of this Source */ 55 inline SoundBuffer* getBuffer(void) const { return this->buffer; } 55 inline SoundBuffer* getBuffer(void) const { return this->buffer; } 56 56 /** \returns the SourceNode of this Source */ 57 57 inline PNode* getNode(void) const { return this->sourceNode;}
Note: See TracChangeset
for help on using the changeset viewer.