![]() |
VR-Forces Developer's Guide
|
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.
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 |
| 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.
| de | Simulation environment used by the sound component. |
| position | World position of the buoy or beacon. |
| category | Parsed CATFOG category label (e.g. "bell", "horn"). Retained for debug display only. |
| soundFilepath | Resolved path to the audio file to play on each sounding slot. May be empty, in which case the controller is silent. |
| slots | Parsed SIGSEQ slot sequence (alternating sounding/silent durations). May be empty. |
| decibels | Authored source loudness in dBFS. |
| rawSigseq | Raw S-57 SIGSEQ string (empty when SIGSEQ was absent and the slot sequence was synthesised). Retained for debug display only. |
| minAudibleDistanceM | Inner-radius override for 3D distance attenuation, in metres. Value equal to DtAudioLevel::kUseDefaultDistance leaves the audio engine's physical-model reference distance in place. |
| maxAudibleDistanceM | Outer-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. |
| priority | Voice-pool preemption priority for this sound. |
| makVrv::DtFogSignalController::~DtFogSignalController | ( | ) |
Destructor.
|
delete |
Copy operations are deleted; controllers are non-copyable.
|
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:
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.
| tNow | Current 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:
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.
| tNow | Current simulation time in seconds. |
| void makVrv::DtFogSignalController::setPosition | ( | const DtVector & | position | ) |
Reposition the embedded sound source.
| position | New 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.
| waveAction | Configuration 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.
| audible | True to install an override; false to clear it. |
| speedMs | Local wind speed in metres per second. Ignored when audible is false. |
|
inline |
Returns true when a wave-action configuration is attached.
|
inline |
Wind speed (m/s) used for the most recent cycle-rollover regeneration. Zero until the first rollover.
|
inline |
Interpolated cycle period (seconds) used for the most recent cycle-rollover regeneration. Zero until the first rollover.
|
inline |
True when the current slot is sounding and the sound component was started.
|
inline |
True when the attached wave-action configuration asks the runtime to consult DtLocalWeatherQuery before the global wind speed.
|
inline |
Inner-radius (reference-distance) override authored on the FogSignalSounds schema for this controller, in metres. DtAudioLevel::kUseDefaultDistance when not authored.
|
inline |
Outer-radius override authored on the FogSignalSounds schema for this controller, in metres. DtAudioLevel::kUseDefaultDistance when not authored.
|
private |
Simulation environment reference.
|
private |
World position of the buoy or beacon.
|
private |
Parsed CATFOG category label, retained for debug display.
|
private |
Resolved sound filepath, retained for debug display.
|
private |
Raw S-57 SIGSEQ string, retained for debug display. Empty when SIGSEQ was absent and the slot sequence was synthesised.
|
private |
Parsed SIGSEQ slot sequence. Empty when the buoy has no signal.
|
private |
Index of the slot currently being timed.
|
private |
Absolute simulation time at which the current slot expires.
|
private |
Inner-radius override for 3D distance attenuation, in metres. DtAudioLevel::kUseDefaultDistance = use engine physical-model default.
|
private |
Outer-radius override for 3D distance attenuation, in metres. DtAudioLevel::kUseDefaultDistance = use engine physical-model default.
|
private |
Voice-pool preemption priority for this sound.
|
private |
Embedded positional sound. Held by unique_ptr because DtSoundComponent's default constructor is deleted.
|
private |
Wave-action configuration. Null when disabled (default).
|
private |
True when the current slot is sounding and the sound component has been started. Drives the slot-transition state machine.
|
private |
True when the manager has pushed a local wind override for this tick. Cleared at the end of update().
|
private |
Local wind speed override in m/s, consumed when myHasLocalWindOverride is true.
|
private |
Wind speed (m/s) used for the most recent cycle-rollover regeneration; also exposed to the HUD.
|
private |
Interpolated cycle period (seconds) used for the most recent cycle-rollover regeneration; also exposed to the HUD.