示例#1
0
 void UpdateListenerGain() {
     if ((muteWhenMinimized.Get() and com_minimized->integer) or (muteWhenUnfocused.Get() and com_unfocused->integer)) {
         AL::SetListenerGain(0.0f);
     } else {
         AL::SetListenerGain(SliderToAmplitude(masterVolume.Get()));
     }
 }
示例#2
0
    void Sound::Update() {
        // Fade the Gain update to avoid "ticking" sounds when there is a gain discontinuity
        float targetGain = positionalGain * soundGain * SliderToAmplitude(effectsVolume.Get());

        //TODO make it framerate independant and fade out in about 1/8 seconds ?
        if (currentGain > targetGain) {
            currentGain = std::max(currentGain - 0.02f, targetGain);
            //currentGain = std::max(currentGain * 1.05f, targetGain);
        } else if (currentGain < targetGain) {
            currentGain = std::min(currentGain + 0.02f, targetGain);
            //currentGain = std::min(currentGain / 1.05f - 0.01f, targetGain);
        }

        source->SetGain(currentGain);

        InternalUpdate();
    }
示例#3
0
 // Set the gain before the source is started to avoid having a few milliseconds of very lound sound
 void Sound::FinishSetup() {
     currentGain = positionalGain * soundGain * SliderToAmplitude(effectsVolume.Get());
     source->SetGain(currentGain);
 }