VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
makVrv::DtFogSignalController Class Reference

Drives the on/off sequence of a single buoy or beacon fog signal.

Owns one DtSoundComponent (positional, world-position, no scene object) and advances through the parsed S-57 SIGSEQ slot list every tick. Playback is driven by a silence/sounding state machine: on any transition INTO a sounding slot (silence-to-sounding, or the sounding-to-sounding boundary of an adjacent grouping produced by SIGSEQ groups) the component's playOnce() is called, which routes through DtAudioManager::playOneShot3D to fire a fresh voice at the buoy's world position starting from sample zero. Transitions to silence take no action; the previous voice plays to natural completion. This matches the pre-existing fog-signal playback model and ensures audibility for world-position sounds (the persistent DtSoundComponent play()/stop() path is designed for scene-object- attached voices and does not produce audio for detached fog signal sources).

Samples authored longer than the 2 s sounding slot will play through into the silence phase; this is the same behavior every fog signal exhibited before the wave-action feature. The 3 s period floor imposed by DtFogWaveAction::periodForWindSpeed guarantees at least 1 s between consecutive shot triggers, so authored short-sample buoys behave sensibly at rough-sea cadences.

When a wave-action configuration is attached via setWaveAction(), the slot vector is regenerated at each cycle rollover from a two-anchor (calm/rough) wind-to-period interpolation. The controller reads the global scene wind speed by default and, when the manager pushes a per-tick local wind override via setLocalWindOverride(), uses that instead for the next cycle rollover.

Fog-visibility gating: wave-action controllers update every tick regardless of fog visibility (their raison d'etre is to reflect sea state via cadence, which mariners hear whether or not there is fog). Non-wave-action controllers remain gated on the fog-visibility threshold in DtFogSignalManager::slot_postTick.

Lifetime is managed by DtFogSignalManager, which creates one controller per buoy or beacon that emits signal_buoyOrBeaconFogSignalRequested and destroys it on signal_buoyOrBeaconAboutToBeDestroyed.

See Also
DtFogSignalManager, DtSigseqSlot, DtSoundComponent

Public Member Functions

 DtFogSignalController (DtDe &de, const DtVector &position, const std::string &category, const std::string &soundFilepath, const std::vector< DtSigseqSlot > &slots, float decibels, const std::string &rawSigseq, float minAudibleDistanceM, float maxAudibleDistanceM, makAudio::DtAbstractAudio::Priority priority)
 
 ~DtFogSignalController ()
 
 DtFogSignalController (const DtFogSignalController &)=delete
 
DtFogSignalController & operator= (const DtFogSignalController &)=delete
 
void update (double tNow)
 
void resync (double tNow)
 
void setPosition (const DtVector &position)
 
const DtVector & position () const
 
const std::string & category () const
 
const std::string & soundFilepath () const
 
const std::string & rawSigseq () const
 
int slotCursor () const
 
int slotCount () const
 
bool isCurrentSlotSounding () const
 
float totalPeriodSec () const
 
void setWaveAction (std::unique_ptr< makVrv::DtFogWaveAction > waveAction)
 
void setLocalWindOverride (bool audible, float speedMs)
 
bool hasWaveAction () const
 
float currentWindMs () const
 
float currentPeriodSeconds () const
 
bool isCurrentlySounding () const
 
bool usingLocalWeather () const
 
float minAudibleDistanceM () const
 
float maxAudibleDistanceM () const
 

Private Attributes

DtDe & myDe
 
DtVector myPosition
 
std::string myCategory
 
std::string mySoundFilepath
 
std::string myRawSigseq
 
std::vector< DtSigseqSlot > mySlotSequence
 
int mySlotCursor
 
double myTimer
 
float myMinAudibleDistanceM
 
float myMaxAudibleDistanceM
 
makAudio::DtAbstractAudio::Priority myPriority
 
std::unique_ptr< DtSoundComponent > mySoundComponent
 
std::unique_ptr
< makVrv::DtFogWaveAction > 
myWaveAction
 
bool myIsCurrentlySounding = false
 
bool myHasLocalWindOverride = false
 
float myLocalWindMsOverride = 0.0f
 
float myLastWindMs = 0.0f
 
float myLastComputedPeriodSeconds = 0.0f
 

Constructor & Destructor Documentation

makVrv::DtFogSignalController::DtFogSignalController ( DtDe &  de,
const DtVector &  position,
const std::string &  category,
const std::string &  soundFilepath,
const std::vector< DtSigseqSlot > &  slots,
float  decibels,
const std::string &  rawSigseq,
float  minAudibleDistanceM,
float  maxAudibleDistanceM,
makAudio::DtAbstractAudio::Priority  priority 
)

Constructs the controller and its embedded sound component.

Parameters
deSimulation environment used by the sound component.
positionWorld position of the buoy or beacon.
categoryParsed CATFOG category label (e.g. "bell", "horn"). Retained for debug display only.
soundFilepathResolved path to the audio file to play on each sounding slot. May be empty, in which case the controller is silent.
slotsParsed SIGSEQ slot sequence (alternating sounding/silent durations). May be empty.
decibelsAuthored source loudness in dBFS.
rawSigseqRaw S-57 SIGSEQ string (empty when SIGSEQ was absent and the slot sequence was synthesised). Retained for debug display only.
minAudibleDistanceMInner-radius override for 3D distance attenuation, in metres. Value equal to DtAudioLevel::kUseDefaultDistance leaves the audio engine's physical-model reference distance in place.
maxAudibleDistanceMOuter-radius override for 3D distance attenuation, in metres. Value equal to DtAudioLevel::kUseDefaultDistance leaves the audio engine's physical-model max-falloff distance in place.
priorityVoice-pool preemption priority for this sound.
makVrv::DtFogSignalController::~DtFogSignalController ( )

Destructor.

makVrv::DtFogSignalController::DtFogSignalController ( const DtFogSignalController &  )
delete

Copy operations are deleted; controllers are non-copyable.

Member Function Documentation

DtFogSignalController& makVrv::DtFogSignalController::operator= ( const DtFogSignalController &  )
delete
void makVrv::DtFogSignalController::update ( double  tNow)

Advance the slot state machine and drive playback on slot transitions.

While the current slot timer has expired the cursor is advanced; at each advance the state machine applies:

  • Silence to Sounding: stop() then play(); marks the controller as currently sounding.
  • Sounding to Silence: stop(); clears the currently-sounding flag.
  • Sounding to Sounding across a grouping boundary (adjacent sounding slots produced by SIGSEQ groups such as "(2)"): stop() then play() to restart the burst from sample zero.

When a wave-action configuration is attached and the cursor wraps from the last slot back to slot 0, the slot vector is regenerated from the current wind speed via DtFogSignalSequenceGenerator::generateFogSigseq(). Regeneration never happens mid-cycle.

Any per-tick local wind override installed via setLocalWindOverride(true, ...) is consumed and cleared at the end of this call so the override does not stick if the manager stops pushing it.

A while loop collapses any number of missed slots after a long render stall or sim-time jump so playback never drifts behind sim time. Fog-visibility gating is applied by the caller (DtFogSignalManager::slot_postTick): wave-action controllers are updated every tick regardless of fog; non-wave-action controllers are updated only while foggy. When a non-wave- action controller becomes dormant on a foggy-to-clear transition, the manager calls resync() on the next fog onset to snap the cursor back to the start of a fresh cycle before resuming updates.

Parameters
tNowCurrent simulation time in seconds.
void makVrv::DtFogSignalController::resync ( double  tNow)

Align the slot cursor and playback state to the current sim-time phase.

Called by the manager on two occasions:

  1. At construction time for a wave-action controller, to arm the slot timer and (if appropriate) start playback immediately. Wave-action controllers update every tick regardless of fog and cannot afford the dormant-until-first-fog state.
  2. On a clear-to-foggy transition for a non-wave-action controller, so a fleet of controllers does NOT emit a synchronized wall of blasts.

Computes offset = fmod(tNow, totalPeriodSec()), walks the slot list to find the slot containing offset, sets the cursor to that slot, arms myTimer to expire at the slot's end, and calls stop() (silence) or stop() + play() (sounding) on the sound component so playback state matches the resolved phase. Sample position resets to zero on any sounding entry.

Parameters
tNowCurrent simulation time in seconds.
void makVrv::DtFogSignalController::setPosition ( const DtVector &  position)

Reposition the embedded sound source.

Parameters
positionNew world position.
const DtVector& makVrv::DtFogSignalController::position ( ) const

World position of the buoy or beacon.

const std::string& makVrv::DtFogSignalController::category ( ) const

Parsed CATFOG category label (e.g. "bell", "horn").

const std::string& makVrv::DtFogSignalController::soundFilepath ( ) const

Resolved sound filepath; empty when the controller is silent.

const std::string& makVrv::DtFogSignalController::rawSigseq ( ) const

Raw S-57 SIGSEQ string from the source feature; empty when SIGSEQ was absent and the slot sequence was synthesised.

int makVrv::DtFogSignalController::slotCursor ( ) const

Index of the slot currently being timed; 0 when the slot sequence is empty.

int makVrv::DtFogSignalController::slotCount ( ) const

Number of parsed slots; 0 when the slot sequence is empty.

bool makVrv::DtFogSignalController::isCurrentSlotSounding ( ) const

True when the slot currently being timed is a sounding slot; false when the slot sequence is empty.

float makVrv::DtFogSignalController::totalPeriodSec ( ) const

Total period in seconds (sum of every slot duration).

void makVrv::DtFogSignalController::setWaveAction ( std::unique_ptr< makVrv::DtFogWaveAction >  waveAction)

Attach or replace the wave-action configuration.

Ownership of waveAction transfers to the controller. Pass nullptr to detach wave action. When attached, the slot vector is regenerated at each cycle rollover using the current wind speed and the two-anchor interpolation in waveAction.

Parameters
waveActionConfiguration to install, or nullptr to detach.
void makVrv::DtFogSignalController::setLocalWindOverride ( bool  audible,
float  speedMs 
)

Push a per-tick local wind override for this frame.

When audible is true, speedMs replaces the global scene wind speed for the next cycle-rollover regeneration. The override is consumed and cleared at the end of update(), so the manager must push a fresh value each tick to keep it active. When audible is false the override is cleared and update() falls back to the global scene wind speed.

Parameters
audibleTrue to install an override; false to clear it.
speedMsLocal wind speed in metres per second. Ignored when audible is false.
bool makVrv::DtFogSignalController::hasWaveAction ( ) const
inline

Returns true when a wave-action configuration is attached.

float makVrv::DtFogSignalController::currentWindMs ( ) const
inline

Wind speed (m/s) used for the most recent cycle-rollover regeneration. Zero until the first rollover.

float makVrv::DtFogSignalController::currentPeriodSeconds ( ) const
inline

Interpolated cycle period (seconds) used for the most recent cycle-rollover regeneration. Zero until the first rollover.

bool makVrv::DtFogSignalController::isCurrentlySounding ( ) const
inline

True when the current slot is sounding and the sound component was started.

bool makVrv::DtFogSignalController::usingLocalWeather ( ) const
inline

True when the attached wave-action configuration asks the runtime to consult DtLocalWeatherQuery before the global wind speed.

float makVrv::DtFogSignalController::minAudibleDistanceM ( ) const
inline

Inner-radius (reference-distance) override authored on the FogSignalSounds schema for this controller, in metres. DtAudioLevel::kUseDefaultDistance when not authored.

float makVrv::DtFogSignalController::maxAudibleDistanceM ( ) const
inline

Outer-radius override authored on the FogSignalSounds schema for this controller, in metres. DtAudioLevel::kUseDefaultDistance when not authored.

Member Data Documentation

DtDe& makVrv::DtFogSignalController::myDe
private

Simulation environment reference.

DtVector makVrv::DtFogSignalController::myPosition
private

World position of the buoy or beacon.

std::string makVrv::DtFogSignalController::myCategory
private

Parsed CATFOG category label, retained for debug display.

std::string makVrv::DtFogSignalController::mySoundFilepath
private

Resolved sound filepath, retained for debug display.

std::string makVrv::DtFogSignalController::myRawSigseq
private

Raw S-57 SIGSEQ string, retained for debug display. Empty when SIGSEQ was absent and the slot sequence was synthesised.

std::vector<DtSigseqSlot> makVrv::DtFogSignalController::mySlotSequence
private

Parsed SIGSEQ slot sequence. Empty when the buoy has no signal.

int makVrv::DtFogSignalController::mySlotCursor
private

Index of the slot currently being timed.

double makVrv::DtFogSignalController::myTimer
private

Absolute simulation time at which the current slot expires.

float makVrv::DtFogSignalController::myMinAudibleDistanceM
private

Inner-radius override for 3D distance attenuation, in metres. DtAudioLevel::kUseDefaultDistance = use engine physical-model default.

float makVrv::DtFogSignalController::myMaxAudibleDistanceM
private

Outer-radius override for 3D distance attenuation, in metres. DtAudioLevel::kUseDefaultDistance = use engine physical-model default.

makAudio::DtAbstractAudio::Priority makVrv::DtFogSignalController::myPriority
private

Voice-pool preemption priority for this sound.

std::unique_ptr<DtSoundComponent> makVrv::DtFogSignalController::mySoundComponent
private

Embedded positional sound. Held by unique_ptr because DtSoundComponent's default constructor is deleted.

std::unique_ptr<makVrv::DtFogWaveAction> makVrv::DtFogSignalController::myWaveAction
private

Wave-action configuration. Null when disabled (default).

bool makVrv::DtFogSignalController::myIsCurrentlySounding = false
private

True when the current slot is sounding and the sound component has been started. Drives the slot-transition state machine.

bool makVrv::DtFogSignalController::myHasLocalWindOverride = false
private

True when the manager has pushed a local wind override for this tick. Cleared at the end of update().

float makVrv::DtFogSignalController::myLocalWindMsOverride = 0.0f
private

Local wind speed override in m/s, consumed when myHasLocalWindOverride is true.

float makVrv::DtFogSignalController::myLastWindMs = 0.0f
private

Wind speed (m/s) used for the most recent cycle-rollover regeneration; also exposed to the HUD.

float makVrv::DtFogSignalController::myLastComputedPeriodSeconds = 0.0f
private

Interpolated cycle period (seconds) used for the most recent cycle-rollover regeneration; also exposed to the HUD.


The documentation for this class was generated from the following file:

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)