diff options
Diffstat (limited to 'indra/newview/llvieweraudio.cpp')
-rw-r--r-- | indra/newview/llvieweraudio.cpp | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp index e7f904023a..1d935f5ab8 100644 --- a/indra/newview/llvieweraudio.cpp +++ b/indra/newview/llvieweraudio.cpp @@ -211,29 +211,60 @@ void audio_update_wind(bool force_update) // if (force_update || (last_camera_water_height * camera_water_height) < 0.f) { + static LLUICachedControl<F32> rolloff("AudioLevelRolloff", 1.0f); if (camera_water_height < 0.f) { - gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff") * LL_ROLLOFF_MULTIPLIER_UNDER_WATER); + gAudiop->setRolloffFactor(rolloff * LL_ROLLOFF_MULTIPLIER_UNDER_WATER); } else { - gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff")); + gAudiop->setRolloffFactor(rolloff); } } - // this line rotates the wind vector to be listener (agent) relative - // Only use the agent's motion to compute wind noise, otherwise the world - // feels desolate on login when you are standing still. - gRelativeWindVec = gAgent.getFrameAgent().rotateToLocal( -gAgent.getVelocity() ); + + // Scale down the contribution of weather-simulation wind to the + // ambient wind noise. Wind velocity averages 3.5 m/s, with gusts to 7 m/s + // whereas steady-state avatar walk velocity is only 3.2 m/s. + // Without this the world feels desolate on first login when you are + // standing still. + static LLUICachedControl<F32> wind_level("AudioLevelWind", 0.5f); + LLVector3 scaled_wind_vec = gWindVec * wind_level; + + // Mix in the avatar's motion, subtract because when you walk north, + // the apparent wind moves south. + LLVector3 final_wind_vec = scaled_wind_vec - gAgent.getVelocity(); + + // rotate the wind vector to be listener (agent) relative + gRelativeWindVec = gAgent.getFrameAgent().rotateToLocal( final_wind_vec ); // don't use the setter setMaxWindGain() because we don't // want to screw up the fade-in on startup by setting actual source gain // outside the fade-in. F32 master_volume = gSavedSettings.getBOOL("MuteAudio") ? 0.f : gSavedSettings.getF32("AudioLevelMaster"); F32 ambient_volume = gSavedSettings.getBOOL("MuteAmbient") ? 0.f : gSavedSettings.getF32("AudioLevelAmbient"); + F32 max_wind_volume = master_volume * ambient_volume; - F32 wind_volume = master_volume * ambient_volume; - gAudiop->mMaxWindGain = wind_volume; - + const F32 WIND_SOUND_TRANSITION_TIME = 2.f; + // amount to change volume this frame + F32 volume_delta = (LLFrameTimer::getFrameDeltaTimeF32() / WIND_SOUND_TRANSITION_TIME) * max_wind_volume; + if (force_update) + { + // initialize wind volume (force_update) by using large volume_delta + // which is sufficient to completely turn off or turn on wind noise + volume_delta = 1.f; + } + + // mute wind when not flying + if (gAgent.getFlying()) + { + // volume increases by volume_delta, up to no more than max_wind_volume + gAudiop->mMaxWindGain = llmin(gAudiop->mMaxWindGain + volume_delta, max_wind_volume); + } + else + { + // volume decreases by volume_delta, down to no less than 0 + gAudiop->mMaxWindGain = llmax(gAudiop->mMaxWindGain - volume_delta, 0.f); + } last_camera_water_height = camera_water_height; gAudiop->updateWind(gRelativeWindVec, camera_water_height); |