Changeset 5982
- Timestamp:
- Oct 21, 2009, 5:28:13 PM (15 years ago)
- Location:
- code/branches/sound3
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sound3/src/orxonox/sound/AmbientSound.cc
r5929 r5982 32 32 #include "core/EventIncludes.h" 33 33 #include "core/XMLPort.h" 34 #include "SoundManager.h" 34 35 35 36 namespace orxonox … … 60 61 XMLPortEventState(AmbientSound, BaseObject, "play", play, xmlelement, mode); 61 62 } 63 64 void AmbientSound::play() 65 { 66 COUT(3) << this->getSource() << ": Playing" << std::endl; 67 SoundManager::getInstance().registerAmbientSound(this); 68 SUPER(AmbientSound, play); 69 } 70 71 void AmbientSound::replay() 72 { 73 SUPER(AmbientSound, play); 74 } 75 76 void AmbientSound::stop() 77 { 78 SUPER(AmbientSound, stop); 79 SoundManager::getInstance().unregisterAmbientSound(this); 80 } 81 82 void AmbientSound::pause() 83 { 84 SUPER(AmbientSound, pause); 85 } 86 87 void AmbientSound::changedActivity() 88 { 89 COUT(3) << this->getSource() << ": ChangedActivity: " << this->isActive() << std::endl; 90 SUPER(AmbientSound, changedActivity); 91 if(this->isActive()) 92 { 93 this->play(); 94 } 95 else 96 { 97 this->stop(); 98 } 99 } 100 62 101 } -
code/branches/sound3/src/orxonox/sound/AmbientSound.h
r5929 r5982 47 47 virtual ~AmbientSound(); 48 48 49 virtual void play(); 50 virtual void replay(); // is only needed for the AmbientSound list in SoundManager 51 virtual void stop(); 52 virtual void pause(); 53 49 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 50 55 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 56 virtual void changedActivity(); 57 51 58 52 59 private: -
code/branches/sound3/src/orxonox/sound/BaseSound.cc
r5962 r5982 70 70 } 71 71 72 void BaseSound::replay() 73 { 74 BaseSound::play(); 75 } 76 72 77 void BaseSound::stop() 73 78 { … … 105 110 void BaseSound::setPlayOnLoad(bool val) 106 111 { 107 this->bPlayOnLoad_ = true; 108 this->play(); 112 this->bPlayOnLoad_ = val; 113 if(val) 114 { 115 this->play(); 116 } 109 117 } 110 118 -
code/branches/sound3/src/orxonox/sound/BaseSound.h
r5929 r5982 49 49 virtual ~BaseSound(); 50 50 51 void play(); 52 void stop(); 53 void pause(); 51 virtual void play(); 52 virtual void replay(); // is only needed for the AmbientSound list in SoundManager 53 virtual void stop(); 54 virtual void pause(); 54 55 55 56 bool isPlaying(); -
code/branches/sound3/src/orxonox/sound/SoundManager.cc
r5946 r5982 36 36 #include "core/GameMode.h" 37 37 #include "core/ScopedSingletonManager.h" 38 #include "BaseSound.h" 38 39 39 40 namespace orxonox … … 114 115 COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl; 115 116 } 117 118 void SoundManager::registerAmbientSound(BaseSound* newAmbient) 119 { 120 if (!(this->ambientSounds_.empty())) 121 { 122 this->ambientSounds_.front()->pause(); 123 } 124 this->ambientSounds_.push_front(newAmbient); 125 } 126 127 void SoundManager::unregisterAmbientSound(BaseSound* currentAmbient) 128 { 129 if(this->ambientSounds_.front() == currentAmbient) 130 { 131 this->ambientSounds_.pop_front(); 132 this->ambientSounds_.front()->replay(); 133 } 134 else 135 { 136 for(std::list<BaseSound*>::iterator it= this->ambientSounds_.begin(); it != this->ambientSounds_.end(); it++) 137 { 138 if(*it == currentAmbient) 139 { 140 this->ambientSounds_.erase(it); 141 break; 142 } 143 } 144 } 145 } 116 146 } -
code/branches/sound3/src/orxonox/sound/SoundManager.h
r5929 r5982 51 51 void setListenerPosition(const Vector3& position); 52 52 void setListenerOrientation(const Quaternion& orientation); 53 void registerAmbientSound(BaseSound* newAmbient); 54 void unregisterAmbientSound(BaseSound* currentAmbient); 53 55 54 56 private: 55 57 ALCdevice* device_; 56 58 ALCcontext* context_; 59 std::list<BaseSound*> ambientSounds_; 57 60 58 61 static SoundManager* singletonPtr_s;
Note: See TracChangeset
for help on using the changeset viewer.