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:
|
| 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 |
| |
| | DtVirtualBaseClass () |
| |
| virtual | ~DtVirtualBaseClass () |
| |
| virtual makVrv::DtProceduralSoundBehavior::~DtProceduralSoundBehavior |
( |
| ) |
|
|
virtualdefault |
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
-
| sound | The procedural sound to configure; behaviour-created layers should call layer.setBehavior(this) after construction. |
| de | Display engine context; use for path resolution. |
Reimplemented in makVrv::DtRainSoundBehavior, makVrv::DtVisibilitySoundBehavior, and makVrv::DtWindSoundBehavior.
| virtual void makVrv::DtProceduralSoundBehavior::update |
( |
DtDe & |
de | ) |
|
|
virtual |
| 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
-
| raining | True when inside a rain local weather area. |
| normalizedIntensity | Blended 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
-
| audible | True when inside a wind local weather area with speed > 0. |
| speedMs | Blended 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
-
| hazy | True when inside a visibility local weather area. |
| visibilityMeters | Visibility 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
-
| distanceMeters | Euclidean distance in metres from the listener to the entity. |
Reimplemented in makVrv::DtVisibilitySoundBehavior.
| virtual float makVrv::DtProceduralSoundBehavior::proximityDistMeters |
( |
| ) |
const |
|
virtual |
| 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 |
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
-
| ctx | Current layer context. |
| builtInInterval | Interval computed by the built-in Poisson scheduler. |
- Returns
- Effective interval in seconds to use (default: builtInInterval).
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
-
| ctx | Current layer context. |
| weights | Per-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.
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
-
| ctx | Current layer context. |
| minGain | Layer's configured minimum gain. |
| maxGain | Layer's configured maximum gain. |
- Returns
- Gain value in [minGain, maxGain].
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
-
| ctx | Current layer context. |
| minPitch | Layer's configured minimum pitch ratio (1.0 = original). |
| maxPitch | Layer'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.
| std::atomic<float> makVrv::DtProceduralSoundBehavior::myProximityDistMeters {0.0f} |
|
protected |
The documentation for this class was generated from the following file: