Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 30, 2009, 8:50:44 PM (15 years ago)
Author:
dafrick
Message:

Created capability in SoundManager to set an overall volume, and to also adjust general ambient and effects volumes.
For this to work, you need to delete your config-file (orxonox.ini) so that it can be reset.
It has still som quirks, though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/sound/BaseSound.cc

    r6127 r6184  
    109109        this->volume_ = vol;
    110110        if (alIsSource(this->audioSource_))
    111             alSourcef(this->audioSource_, AL_GAIN, vol);
     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_;
    112131    }
    113132
     
    181200
    182201        alSource3f(this->audioSource_, AL_POSITION,  0, 0, 0);
    183         alSourcef (this->audioSource_, AL_GAIN, this->volume_);
     202        alSourcef (this->audioSource_, AL_GAIN, this->getEffectiveVolume());
    184203        alSourcei (this->audioSource_, AL_LOOPING, (this->bLoop_ ? AL_TRUE : AL_FALSE));
    185204        if (this->isPlaying() || this->isPaused())
Note: See TracChangeset for help on using the changeset viewer.