Fade in the sound exponentially at startup
This commit is contained in:
parent
88fc98f57b
commit
ed4a9337d9
2 changed files with 10 additions and 2 deletions
|
@ -59,7 +59,8 @@ void Listener::valueChanged(SGPropertyNode * node)
|
||||||
}
|
}
|
||||||
|
|
||||||
FGSoundManager::FGSoundManager()
|
FGSoundManager::FGSoundManager()
|
||||||
: _is_initialized(false),
|
: _active_dt(0.0),
|
||||||
|
_is_initialized(false),
|
||||||
_enabled(false),
|
_enabled(false),
|
||||||
_listener(new Listener(this))
|
_listener(new Listener(this))
|
||||||
{
|
{
|
||||||
|
@ -189,7 +190,13 @@ void FGSoundManager::update(double dt)
|
||||||
|
|
||||||
set_velocity( velocity );
|
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);
|
SGSoundMgr::update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ private:
|
||||||
|
|
||||||
SGSharedPtr<FGSampleQueue> _chatterQueue;
|
SGSharedPtr<FGSampleQueue> _chatterQueue;
|
||||||
|
|
||||||
|
double _active_dt;
|
||||||
bool _is_initialized, _enabled;
|
bool _is_initialized, _enabled;
|
||||||
SGPropertyNode_ptr _sound_working, _sound_enabled, _volume, _device_name;
|
SGPropertyNode_ptr _sound_working, _sound_enabled, _volume, _device_name;
|
||||||
SGPropertyNode_ptr _velocityNorthFPS, _velocityEastFPS, _velocityDownFPS;
|
SGPropertyNode_ptr _velocityNorthFPS, _velocityEastFPS, _velocityDownFPS;
|
||||||
|
|
Loading…
Add table
Reference in a new issue