From b20b3229bf9943aa63bc5c51c9401e96b33df299 Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 21 May 2008 14:47:06 +0000 Subject: [PATCH] add parameter that defines how many seconds after triggering the sound should be played (default: 0) --- simgear/sound/xmlsound.cxx | 6 ++++++ simgear/sound/xmlsound.hxx | 2 ++ 2 files changed, 8 insertions(+) diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index efd8d2ad..5d6490b9 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -70,6 +70,7 @@ SGXmlSound::SGXmlSound() _prev_value(0), _dt_play(0.0), _dt_stop(0.0), + _delay(0.0), _stopping(0.0) { } @@ -120,6 +121,8 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSoundMgr *sndmgr, SG_LOG(SG_GENERAL, SG_WARN, " Neither a condition nor a property specified"); + _delay = node->getDoubleValue("delay-sec", 0.0); + // // set volume properties // @@ -348,6 +351,9 @@ SGXmlSound::update (double dt) _stopping = 0.0; } + if (_dt_play < _delay) + return; + // // Update the volume // diff --git a/simgear/sound/xmlsound.hxx b/simgear/sound/xmlsound.hxx index 99bd9b26..de1be7b6 100644 --- a/simgear/sound/xmlsound.hxx +++ b/simgear/sound/xmlsound.hxx @@ -76,6 +76,7 @@ public: * The relative path to the audio file. * Take action if this property becomes true. * Take action if this condition becomes true. + * Time after which the sound should be played. * or Define volume or pitch settings. * Take the value of this property as a refference for the * result. @@ -144,6 +145,7 @@ private: double _prev_value; double _dt_play; double _dt_stop; + double _delay; // time after which the sound should be started (default: 0) double _stopping; // time after the sound should have stopped. // This is usefull for lost packets in in-trasit mode. -- 2.39.5