Changeset 9686 in orxonox.OLD for branches/new_class_id/src/lib/sound
- Timestamp:
- Aug 22, 2006, 2:36:54 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/sound
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/sound/ogg_player.cc
r9406 r9686 49 49 namespace OrxSound 50 50 { 51 NewObjectListDefinition(OggPlayer); 51 52 /** 52 53 * initializes an Ogg-player from a file … … 55 56 OggPlayer::OggPlayer(const std::string& fileName) 56 57 { 57 this-> setClassID(CL_SOUND_OGG_PLAYER, "OggPlayer");58 this->registerObject(this, OggPlayer::_objectList); 58 59 59 60 this->state = OggPlayer::None; -
branches/new_class_id/src/lib/sound/ogg_player.h
r9019 r9686 25 25 class OggPlayer : public BaseObject 26 26 { 27 NewObjectListDeclaration(OggPlayer); 28 27 29 public: 28 30 /** -
branches/new_class_id/src/lib/sound/sound_buffer.cc
r8971 r9686 35 35 namespace OrxSound 36 36 { 37 NewObjectListDefinition(SoundBuffer); 37 38 ////////////////// 38 39 /* SOUND-BUFFER */ … … 44 45 SoundBuffer::SoundBuffer(const std::string& fileName) 45 46 { 46 this-> setClassID(CL_SOUND_BUFFER, "SoundBuffer");47 this->registerObject(this, SoundBuffer::_objectList); 47 48 this->setName(fileName); 48 49 -
branches/new_class_id/src/lib/sound/sound_buffer.h
r8969 r9686 18 18 class SoundBuffer : public BaseObject 19 19 { 20 NewObjectListDeclaration(SoundBuffer); 20 21 public: 21 22 SoundBuffer(const std::string& fileName); -
branches/new_class_id/src/lib/sound/sound_engine.cc
r9235 r9686 20 20 21 21 #include "sound_engine.h" 22 23 #include "class_list.h"24 22 25 23 #include "p_node.h" … … 31 29 namespace OrxSound 32 30 { 33 31 NewObjectListDefinition(SoundEngine); 34 32 ////////////////// 35 33 /* SOUND-ENGINE */ … … 40 38 SoundEngine::SoundEngine () 41 39 { 42 this-> setClassID(CL_SOUND_ENGINE, "SoundEngine");40 this->registerObject(this, SoundEngine::_objectList); 43 41 this->setName("SoundEngine"); 44 42 45 43 this->listener = NULL; 46 this->bufferList = NULL;47 this->sourceList = NULL;48 44 49 45 this->device = NULL; … … 69 65 { 70 66 // deleting all the SoundSources 71 if(this->sourceList != NULL) 72 { 73 while (this->sourceList->size() > 0) 74 delete static_cast<SoundSource*>(this->sourceList->front()); 75 } 67 while (!SoundSource::objectList().empty()) 68 delete (SoundSource::objectList().front()); 76 69 77 70 while(!this->ALSources.empty()) … … 89 82 90 83 // deleting all the SoundBuffers 91 if (this->bufferList != NULL) 92 { 93 while(this->bufferList->size() > 0) 94 ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front())); 95 } 84 while(!SoundBuffer::objectList().empty()) 85 ResourceManager::getInstance()->unload(SoundBuffer::objectList().front()); 96 86 97 87 // removing openAL from AudioResource … … 212 202 213 203 // updating all the Sources positions 214 if (likely(this->sourceList != NULL || (this->sourceList = ClassList::getList(CL_SOUND_SOURCE)) != NULL)) 215 { 216 std::list<BaseObject*>::const_iterator sourceIT; 217 SoundSource* source; 218 for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++) 204 NewObjectList<SoundSource>::const_iterator sourceIT; 205 for (sourceIT = SoundSource::objectList().begin(); 206 sourceIT != SoundSource::objectList().end(); 207 sourceIT++) 208 { 209 if ((*sourceIT)->isPlaying()) 219 210 { 220 source = static_cast<SoundSource*>(*sourceIT); 221 if (source->isPlaying()) 211 int play = 0x000; 212 alGetSourcei((*sourceIT)->getID(), AL_SOURCE_STATE, &play); 213 if (DEBUG_LEVEL > 2) 214 SoundEngine::checkError("SoundEngine::update() Play", __LINE__); 215 if(play == AL_PLAYING) 222 216 { 223 int play = 0x000; 224 alGetSourcei(source->getID(), AL_SOURCE_STATE, &play); 225 if (DEBUG_LEVEL > 2) 226 SoundEngine::checkError("SoundEngine::update() Play", __LINE__); 227 if(play == AL_PLAYING) 217 if (likely((*sourceIT)->getNode() != NULL)) 228 218 { 229 if (likely(source->getNode() != NULL)) 230 { 231 alSource3f(source->getID(), AL_POSITION, 232 source->getNode()->getAbsCoor().x, 233 source->getNode()->getAbsCoor().y, 234 source->getNode()->getAbsCoor().z); 235 if (DEBUG_LEVEL > 2) 236 SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__); 237 alSource3f(source->getID(), AL_VELOCITY, 238 source->getNode()->getVelocity().x, 239 source->getNode()->getVelocity().y, 240 source->getNode()->getVelocity().z); 241 if (DEBUG_LEVEL > 2) 242 SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__); 243 } 219 alSource3f((*sourceIT)->getID(), AL_POSITION, 220 (*sourceIT)->getNode()->getAbsCoor().x, 221 (*sourceIT)->getNode()->getAbsCoor().y, 222 (*sourceIT)->getNode()->getAbsCoor().z); 223 if (DEBUG_LEVEL > 2) 224 SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__); 225 alSource3f((*sourceIT)->getID(), AL_VELOCITY, 226 (*sourceIT)->getNode()->getVelocity().x, 227 (*sourceIT)->getNode()->getVelocity().y, 228 (*sourceIT)->getNode()->getVelocity().z); 229 if (DEBUG_LEVEL > 2) 230 SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__); 244 231 } 245 else246 {247 source->stop();248 }232 } 233 else 234 { 235 (*sourceIT)->stop(); 249 236 } 250 237 } … … 393 380 default: 394 381 case AL_NO_ERROR: 395 382 return ("AL_NO_ERROR"); 396 383 case AL_INVALID_NAME: 397 384 return ("AL_INVALID_NAME"); 398 385 case AL_INVALID_ENUM: 399 386 return ("AL_INVALID_ENUM"); 400 387 case AL_INVALID_VALUE: 401 388 return ("AL_INVALID_VALUE"); 402 389 case AL_INVALID_OPERATION: 403 390 return ("AL_INVALID_OPERATION"); 404 391 case AL_OUT_OF_MEMORY: 405 392 return ("AL_OUT_OF_MEMORY"); 406 393 }; 407 394 } … … 414 401 default: 415 402 case ALC_NO_ERROR: 416 403 return ("AL_NO_ERROR"); 417 404 case ALC_INVALID_DEVICE: 418 405 return ("ALC_INVALID_DEVICE"); 419 406 case ALC_INVALID_CONTEXT: 420 407 return("ALC_INVALID_CONTEXT"); 421 408 case ALC_INVALID_ENUM: 422 409 return("ALC_INVALID_ENUM"); 423 410 case ALC_INVALID_VALUE: 424 411 return ("ALC_INVALID_VALUE"); 425 412 case ALC_OUT_OF_MEMORY: 426 413 return("ALC_OUT_OF_MEMORY"); 427 414 }; 428 415 } -
branches/new_class_id/src/lib/sound/sound_engine.h
r7847 r9686 27 27 class SoundEngine : public BaseObject 28 28 { 29 public: 29 NewObjectListDeclaration(SoundEngine); 30 public: 30 31 virtual ~SoundEngine(); 31 32 /** @returns a Pointer to the only object of this Class */ … … 75 76 const PNode* listener; //!< The listener of the Scene 76 77 77 const std::list<BaseObject*>* bufferList; //!< A list of buffers78 const std::list<BaseObject*>* sourceList; //!< A list for all the sources in the scene.79 80 78 unsigned int maxSourceCount; //!< How many Sources is the Maximum 81 79 std::stack<ALuint> ALSources; //!< A list of real openAL-Sources, the engine allocates, and stores for reuse. -
branches/new_class_id/src/lib/sound/sound_source.cc
r8969 r9686 25 25 namespace OrxSound 26 26 { 27 NewObjectListDefinition(SoundSource); 27 28 /** 28 29 * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer … … 30 31 SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer) 31 32 { 32 this->setClassID(CL_SOUND_SOURCE, "SoundSource"); 33 33 this->registerObject(this, SoundSource::_objectList); 34 34 // adding the Source to the SourcesList of the SoundEngine 35 35 this->buffer = buffer; … … 51 51 SoundSource::SoundSource(const SoundSource& source) 52 52 { 53 this-> setClassID(CL_SOUND_SOURCE, "SoundSource");53 this->registerObject(this, SoundSource::_objectList); 54 54 55 55 // adding the Source to the SourcesList of the SoundEngine -
branches/new_class_id/src/lib/sound/sound_source.h
r8793 r9686 18 18 class SoundSource : public BaseObject 19 19 { 20 NewObjectListDeclaration(SoundSource); 20 21 public: 21 22 SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
Note: See TracChangeset
for help on using the changeset viewer.