1
0
Fork 0

Fade in the sound exponentially at startup

This commit is contained in:
Erik Hofman 2017-01-12 15:06:04 +01:00
parent 88fc98f57b
commit ed4a9337d9
2 changed files with 10 additions and 2 deletions

View file

@ -59,7 +59,8 @@ void Listener::valueChanged(SGPropertyNode * node)
}
FGSoundManager::FGSoundManager()
: _is_initialized(false),
: _active_dt(0.0),
_is_initialized(false),
_enabled(false),
_listener(new Listener(this))
{
@ -189,7 +190,13 @@ void FGSoundManager::update(double dt)
set_velocity( velocity );
set_volume(_volume->getFloatValue());
float vf = 1.0f;
if (_active_dt < 5.0) {
_active_dt += dt;
vf = std::min(std::pow(_active_dt*0.2, 5.0), 1.0);
}
set_volume(vf*_volume->getFloatValue());
SGSoundMgr::update(dt);
}
}

View file

@ -57,6 +57,7 @@ private:
SGSharedPtr<FGSampleQueue> _chatterQueue;
double _active_dt;
bool _is_initialized, _enabled;
SGPropertyNode_ptr _sound_working, _sound_enabled, _volume, _device_name;
SGPropertyNode_ptr _velocityNorthFPS, _velocityEastFPS, _velocityDownFPS;