Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 30, 2009, 11:50:17 PM (14 years ago)
Author:
dafrick
Message:

Some cleanup in SoundManager and related classes. Overrall volume works now. Mute function has been implemented into the gui.
Once again you'll have to delete your orxonox.ini file to be trouble free.

File:
1 edited

Legend:

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

    r6184 r6186  
    3838#include "core/Resource.h"
    3939#include "core/XMLPort.h"
     40#include "SoundManager.h"
    4041
    4142namespace orxonox
     
    5455            assert(this->audioSource_ != 0);
    5556        }
     57       
    5658    }
    5759
     
    108110        }
    109111        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    {
    110123        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());
    131125    }
    132126
     
    200194
    201195        alSource3f(this->audioSource_, AL_POSITION,  0, 0, 0);
    202         alSourcef (this->audioSource_, AL_GAIN, this->getEffectiveVolume());
     196        this->updateVolume();
    203197        alSourcei (this->audioSource_, AL_LOOPING, (this->bLoop_ ? AL_TRUE : AL_FALSE));
    204198        if (this->isPlaying() || this->isPaused())
Note: See TracChangeset for help on using the changeset viewer.