- Timestamp:
- Dec 17, 2009, 11:10:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
r6340 r6370 145 145 void BaseSound::setVolume(float vol) 146 146 { 147 if (vol > 1 || vol < 0) 148 { 149 COUT(2) << "Sound warning: volume out of range, cropping value." << std::endl; 150 vol = vol > 1 ? 1 : vol; 151 vol = vol < 0 ? 0 : vol; 152 } 153 this->volume_ = vol; 154 147 this->volume_ = clamp(vol, 0.0f, 1.0f); 148 if (this->volume_ != vol) 149 COUT(2) << "Sound warning: volume out of range, clamping value." << std::endl; 155 150 this->updateVolume(); 156 151 } 157 152 158 float BaseSound::getVolumeGain() 159 { 160 assert(GameMode::playsSound()); 161 return SoundManager::getInstance().getVolume(SoundType::none); 162 } 163 164 void BaseSound::updateVolume(void) 165 { 166 if (alIsSource(this->audioSource_)) 167 { 168 float volume = this->volume_ * this->getVolumeGain(); 153 void BaseSound::updateVolume() 154 { 155 if (alIsSource(this->audioSource_)) 156 { 157 float volume = this->volume_ * this->getRealVolume(); 169 158 alSourcef(this->audioSource_, AL_GAIN, volume); 170 159 if (int error = alGetError())
Note: See TracChangeset
for help on using the changeset viewer.