- Timestamp:
- Nov 30, 2009, 11:50:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
r6184 r6186 38 38 #include "core/Resource.h" 39 39 #include "core/XMLPort.h" 40 #include "SoundManager.h" 40 41 41 42 namespace orxonox … … 54 55 assert(this->audioSource_ != 0); 55 56 } 57 56 58 } 57 59 … … 108 110 } 109 111 this->volume_ = vol; 112 113 this->updateVolume(); 114 } 115 116 float BaseSound::getVolumeGain() 117 { 118 return SoundManager::getInstance().getVolume(SoundType::none); 119 } 120 121 void BaseSound::updateVolume(void) 122 { 110 123 if (alIsSource(this->audioSource_)) 111 alSourcef(this->audioSource_, AL_GAIN, this->getEffectiveVolume()); 112 } 113 114 void BaseSound::setVolumeGain(float gain) 115 { 116 COUT(1) << "blubb: " << gain << std::endl; 117 if (gain > 1 || gain < 0) 118 { 119 COUT(2) << "Sound warning: volume gain out of range, cropping value." << std::endl; 120 gain = gain > 1 ? 1 : gain; 121 gain = gain < 0 ? 0 : gain; 122 } 123 this->volumeGain_ = gain; 124 if (alIsSource(this->audioSource_)) 125 alSourcef(this->audioSource_, AL_GAIN, this->getEffectiveVolume()); 126 } 127 128 float BaseSound::getEffectiveVolume(void) 129 { 130 return this->volume_*this->volumeGain_; 124 alSourcef(this->audioSource_, AL_GAIN, this->volume_*this->getVolumeGain()); 131 125 } 132 126 … … 200 194 201 195 alSource3f(this->audioSource_, AL_POSITION, 0, 0, 0); 202 alSourcef (this->audioSource_, AL_GAIN, this->getEffectiveVolume());196 this->updateVolume(); 203 197 alSourcei (this->audioSource_, AL_LOOPING, (this->bLoop_ ? AL_TRUE : AL_FALSE)); 204 198 if (this->isPlaying() || this->isPaused())
Note: See TracChangeset
for help on using the changeset viewer.