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 | Protected Attributes
makVrv::DtProceduralSoundBehavior Class Reference

Optional per-channel behavior hook for DtProceduralSoundPlayer.

Subclass DtProceduralSoundBehavior to take over scheduling, clip selection, gain, pitch, and/or volume for one procedural soundscape channel. The default implementations preserve the built-in data-driven behaviour.

Threading contract:

Inheritance diagram for makVrv::DtProceduralSoundBehavior:
Inheritance graph
[legend]

Public Member Functions

virtual ~DtProceduralSoundBehavior ()=default
 
virtual void setupSound (DtProceduralSound &sound, DtDe &de)
 
virtual void update (DtDe &de)
 
virtual bool isActive (const DtProceduralSoundBehaviorContext &ctx) const
 
virtual float currentVolumeDb (const DtProceduralSoundBehaviorContext &ctx, float channelBaseVolumeDb) const
 
virtual void setLocalPrecipitationOverride (bool raining, float normalizedIntensity)
 
virtual void setLocalWindSpeedOverride (bool audible, float speedMs)
 
virtual void setLocalVisibilityOverride (bool hazy, float visibilityMeters)
 
virtual void setProximityDistance (double distanceMeters)
 
virtual float proximityDistMeters () const
 
virtual bool isInRange () const
 
virtual bool usingLocalOverride () const
 
virtual void appendImGuiDebugInfo () const
 
virtual float nextIntervalSeconds (const DtProceduralSoundBehaviorContext &ctx, float builtInInterval) const
 
virtual int selectClip (const DtProceduralSoundBehaviorContext &ctx, const std::vector< float > &weights) const
 
virtual float selectGain (const DtProceduralSoundBehaviorContext &ctx, float minGain, float maxGain) const
 
virtual float selectPitch (const DtProceduralSoundBehaviorContext &ctx, float minPitch, float maxPitch) const
 
virtual bool wantRestart () const
 
- Public Member Functions inherited from makVrv::DtVirtualBaseClass
 DtVirtualBaseClass ()
 
virtual ~DtVirtualBaseClass ()
 

Protected Attributes

std::atomic< float > myProximityDistMeters {0.0f}
 

Constructor & Destructor Documentation

virtual makVrv::DtProceduralSoundBehavior::~DtProceduralSoundBehavior ( )
virtualdefault

Virtual destructor.

Member Function Documentation

virtual void makVrv::DtProceduralSoundBehavior::setupSound ( DtProceduralSound &  sound,
DtDe &  de 
)
virtual

Configure the sound's layers and clips.

Called once after construction, before any update() call. Configure layers, clips, gain ranges, pitch ranges, and Fixed Parallel settings here. Do not call sound.play() – the player handles playback lifecycle.

Parameters
soundThe procedural sound to configure; behaviour-created layers should call layer.setBehavior(this) after construction.
deDisplay engine context; use for path resolution.

Reimplemented in makVrv::DtRainSoundBehavior, makVrv::DtVisibilitySoundBehavior, and makVrv::DtWindSoundBehavior.

virtual void makVrv::DtProceduralSoundBehavior::update ( DtDe &  de)
virtual

Read simulation state and cache it in std::atomic members.

The ONLY method in this class that is permitted to access DtDe, DtScene, DtEnvironment, or any non-thread-safe simulation data. Runs on the main thread. Snapshot any state needed by audio-thread callbacks into std::atomic members before returning.

Parameters
deDisplay engine context.

Reimplemented in makVrv::DtRainSoundBehavior, makVrv::DtVisibilitySoundBehavior, and makVrv::DtWindSoundBehavior.

virtual bool makVrv::DtProceduralSoundBehavior::isActive ( const DtProceduralSoundBehaviorContext &  ctx) const
virtual

Return false to silence this channel for the current frame.

Called from the main thread after update(). Return false to stop the player and skip processing for the current tick.

Note
Do not use this as a substitute for feature-layer proximity gating. It is intended for environmental condition gates such as "it is not raining".
Parameters
ctxCurrent channel context.
Returns
true to keep the player running (default), false to stop it.

Reimplemented in makVrv::DtRainSoundBehavior, makVrv::DtTierSlotBehavior, makVrv::DtVisibilitySoundBehavior, and makVrv::DtWindSoundBehavior.

virtual float makVrv::DtProceduralSoundBehavior::currentVolumeDb ( const DtProceduralSoundBehaviorContext &  ctx,
float  channelBaseVolumeDb 
) const
virtual

Compute the effective playback volume in dB for this frame.

Called from the main thread. The proximity fade ramp is composited on top of the returned value – do not factor it in here. Return channelBaseVolumeDb unchanged to use the channel's configured value.

Parameters
ctxCurrent channel context.
channelBaseVolumeDbChannel's configured base volume in dB.
Returns
Adjusted volume in dB.

Reimplemented in makVrv::DtRainSoundBehavior, makVrv::DtTierSlotBehavior, makVrv::DtVisibilitySoundBehavior, and makVrv::DtWindSoundBehavior.

virtual void makVrv::DtProceduralSoundBehavior::setLocalPrecipitationOverride ( bool  raining,
float  normalizedIntensity 
)
virtual

Optionally override the precipitation state read from DtEnvironment.

Called from the main thread, before update(), when the channel has precipitationLocalWeatherAreaEnabled set and a local weather area query result is available. The default implementation is a no-op. Override in DtRainSoundBehavior to consume the local state inside update().

Parameters
rainingTrue when inside a rain local weather area.
normalizedIntensityBlended normalized precipitation intensity [0,1].

Reimplemented in makVrv::DtRainSoundBehavior.

virtual void makVrv::DtProceduralSoundBehavior::setLocalWindSpeedOverride ( bool  audible,
float  speedMs 
)
virtual

Optionally override the wind state read from DtEnvironment.

Called from the main thread, before update(), when the channel has windLocalWeatherAreaEnabled set and a local weather area query result is available. The default implementation is a no-op. Override in DtWindSoundBehavior to consume the local state inside update().

Parameters
audibleTrue when inside a wind local weather area with speed > 0.
speedMsBlended wind speed in metres per second.

Reimplemented in makVrv::DtWindSoundBehavior.

virtual void makVrv::DtProceduralSoundBehavior::setLocalVisibilityOverride ( bool  hazy,
float  visibilityMeters 
)
virtual

Optionally override the visibility state read from DtEnvironment.

Called from the main thread, before update(), when the channel has visibilityLocalWeatherAreaEnabled set and a local weather area query result is available. The default implementation is a no-op. Override in DtVisibilitySoundBehavior to consume the local state inside update().

Parameters
hazyTrue when inside a visibility local weather area.
visibilityMetersVisibility distance in metres from the area.

Reimplemented in makVrv::DtVisibilitySoundBehavior.

virtual void makVrv::DtProceduralSoundBehavior::setProximityDistance ( double  distanceMeters)
virtual

Supply the current distance from the audio listener to the entity.

Called from the main thread, before update(), once per frame whenever the entity has a scene object. The base implementation stores the value in myProximityDistMeters. Subclasses that implement a proximity gate (e.g., DtVisibilitySoundBehavior with maxRangeMeters > 0) should call the base and then apply their gate logic.

Parameters
distanceMetersEuclidean distance in metres from the listener to the entity.

Reimplemented in makVrv::DtVisibilitySoundBehavior.

virtual float makVrv::DtProceduralSoundBehavior::proximityDistMeters ( ) const
virtual

Returns the most recent listener-to-source distance in metres.

Returns the value stored by the most recent setProximityDistance() call. Returns 0.0 if setProximityDistance() has never been called.

virtual bool makVrv::DtProceduralSoundBehavior::isInRange ( ) const
virtual

Returns true if the entity is within the behavior's range gate.

Behaviors that implement a distance-based activation gate (e.g. DtVisibilitySoundBehavior with maxRangeMeters > 0) override this to return the current in-range state. Default returns true (no gate).

Returns
true if in range (or no gate is configured).

Reimplemented in makVrv::DtVisibilitySoundBehavior.

virtual bool makVrv::DtProceduralSoundBehavior::usingLocalOverride ( ) const
virtual

Returns true if a local weather area is currently driving this behavior.

Set to true each frame when a local weather area query result was used instead of the global environment value. Default returns false.

Returns
true when a local override is active.

Reimplemented in makVrv::DtVisibilitySoundBehavior.

virtual void makVrv::DtProceduralSoundBehavior::appendImGuiDebugInfo ( ) const
virtual

Append ImGui diagnostic information for this behavior.

Called from the main thread while the ImGui overlay is active. Subclasses override this to display current signal values (e.g., wind speed, fog intensity, precipitation intensity). Default implementation is a no-op.

Reimplemented in makVrv::DtRainSoundBehavior, makVrv::DtVisibilitySoundBehavior, and makVrv::DtWindSoundBehavior.

virtual float makVrv::DtProceduralSoundBehavior::nextIntervalSeconds ( const DtProceduralSoundBehaviorContext &  ctx,
float  builtInInterval 
) const
virtual

Override the inter-event interval for Poisson mode layers.

Warning
AUDIO THREAD. Do NOT access DtDe or any non-thread-safe simulation data. Only read values stored in std::atomic members by update().

Only called in Poisson mode (fixedParallelEvents == 0). Never called for Fixed Parallel layers.

Parameters
ctxCurrent layer context.
builtInIntervalInterval computed by the built-in Poisson scheduler.
Returns
Effective interval in seconds to use (default: builtInInterval).
virtual int makVrv::DtProceduralSoundBehavior::selectClip ( const DtProceduralSoundBehaviorContext &  ctx,
const std::vector< float > &  weights 
) const
virtual

Select a clip index given the layer's weight array.

Warning
AUDIO THREAD. Do NOT access DtDe or any non-thread-safe simulation data. Only read values stored in std::atomic members by update().

The default implementation performs weighted-random selection.

Parameters
ctxCurrent layer context.
weightsPer-clip relative weights; same size as the layer's clip list. The returned index must be in [0, weights.size()-1].
Returns
Index of the clip to play.
virtual float makVrv::DtProceduralSoundBehavior::selectGain ( const DtProceduralSoundBehaviorContext &  ctx,
float  minGain,
float  maxGain 
) const
virtual

Select a linear gain value for the next clip event.

Warning
AUDIO THREAD. Do NOT access DtDe or any non-thread-safe simulation data. Only read values stored in std::atomic members by update().

The default implementation returns a uniform-random value in [minGain, maxGain].

Parameters
ctxCurrent layer context.
minGainLayer's configured minimum gain.
maxGainLayer's configured maximum gain.
Returns
Gain value in [minGain, maxGain].
virtual float makVrv::DtProceduralSoundBehavior::selectPitch ( const DtProceduralSoundBehaviorContext &  ctx,
float  minPitch,
float  maxPitch 
) const
virtual

Select a pitch ratio for the next clip event.

Warning
AUDIO THREAD. Do NOT access DtDe or any non-thread-safe simulation data. Only read values stored in std::atomic members by update().

The default implementation returns a uniform-random value in [minPitch, maxPitch].

Parameters
ctxCurrent layer context.
minPitchLayer's configured minimum pitch ratio (1.0 = original).
maxPitchLayer's configured maximum pitch ratio.
Returns
Pitch ratio in [minPitch, maxPitch].
virtual bool makVrv::DtProceduralSoundBehavior::wantRestart ( ) const
virtual

Return true once to request that the layer discard all in-flight events and restart with a fresh cold fill.

Warning
AUDIO THREAD. Must only read std::atomic members.

Used to force an immediate clip transition when the behavior's condition tier changes (e.g. light rain -> heavy rain). The layer calls this once per chunk; a true return clears all active events so the cold-fill path fires the correct clip on the same chunk.

Implementations should consume the flag atomically (exchange) so that exactly one true is returned per transition. The default returns false.

Returns
true if the layer should restart its event queue this chunk.

Member Data Documentation

std::atomic<float> makVrv::DtProceduralSoundBehavior::myProximityDistMeters {0.0f}
protected

Cached listener-to-entity distance in metres, written by setProximityDistance().


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)