Class AudioDepthCueCalculator
Pure math behind the positioned depth cues: how far a source is within its own range, how an
occlusion amount settles over time, and how it shapes the low-pass cutoff and the level.
Engine-free on purpose: only Math/System.MathF, never an engine type.
Inheritance
AudioDepthCueCalculator
Assembly: Serenity.AudioPlayer.Domain.dll
Syntax
public static class AudioDepthCueCalculator
Fields
FallbackDetourShareOfFull
How much of the full occlusion detour a fallback path is assumed to need when its real length is unknown, as a
share of that detour. A fallback with every path free reads the curve at this share.
Declaration
public const float FallbackDetourShareOfFull = 0.5
Field Value
FullOcclusionAmount
The occlusion amount of a sound that is fully blocked: nothing of the straight line or the route gets through.
Declaration
public const float FullOcclusionAmount = 1
Field Value
MaximumRoomMillibels
Declaration
public const float MaximumRoomMillibels = 0
Field Value
MinimumCutoffHz
Declaration
public const float MinimumCutoffHz = 10
Field Value
OcclusionOpeningTimeConstantSeconds
How fast an occlusion opens again, in seconds. Fixed: only the closing time is authorable.
Declaration
public const float OcclusionOpeningTimeConstantSeconds = 0.1
Field Value
OpenCutoffHz
Declaration
public const float OpenCutoffHz = 22000
Field Value
SilentMillibels
Declaration
public const float SilentMillibels = -10000
Field Value
Methods
ClampCutoffHz(float)
Declaration
public static float ClampCutoffHz(float cutoffHz)
Parameters
| Type |
Name |
Description |
| float |
cutoffHz |
|
Returns
IsMeaningfulChange(float, float, float)
Whether next differs from the last value written by at least epsilon; a last value that is not a number (never written) always differs.
Declaration
public static bool IsMeaningfulChange(float lastWritten, float next, float epsilon)
Parameters
Returns
IsOccluded(float)
Whether anything at all sits between the listener and a source: any occlusion amount above zero, however little.
Declaration
public static bool IsOccluded(float occlusionAmount)
Parameters
| Type |
Name |
Description |
| float |
occlusionAmount |
|
Returns
IsOccludingHit(float, float, float, bool)
Whether a linecast hit from the listener towards the source counts as a wall: not when the collider
encloses the source, and not when it lands within the source clearance.
Declaration
public static bool IsOccludingHit(float hitDistance, float segmentLength, float sourceClearanceMeters, bool hitEnclosesSource)
Parameters
| Type |
Name |
Description |
| float |
hitDistance |
|
| float |
segmentLength |
|
| float |
sourceClearanceMeters |
|
| bool |
hitEnclosesSource |
|
Returns
IsOcclusionGraded(float)
Whether an occlusion is graded by its detour: only a full detour length above zero does, anything else keeps the plain all-or-nothing occlusion.
Declaration
public static bool IsOcclusionGraded(float fullOcclusionDetourMeters)
Parameters
| Type |
Name |
Description |
| float |
fullOcclusionDetourMeters |
|
Returns
IsOcclusionShapingWetShare(float)
True when an occluded voice gets more reverb than an open one, i.e. the authored increase is above zero.
A reverb-only channel needs to probe occlusion only then.
Declaration
public static bool IsOcclusionShapingWetShare(float occludedWetShareIncrease)
Parameters
| Type |
Name |
Description |
| float |
occludedWetShareIncrease |
|
Returns
NormalizedDistance(float, float, float)
The listener distance as a 0..1 position inside the source's own min/max range.
Declaration
public static float NormalizedDistance(float distance, float minDistance, float maxDistance)
Parameters
Returns
OccludedCutoffHz(float, float, float)
The cutoff after occlusion: a logarithmic blend from the distance cutoff towards the lower of both cutoffs.
Declaration
public static float OccludedCutoffHz(float distanceCutoffHz, float occludedCutoffHz, float occlusion)
Parameters
| Type |
Name |
Description |
| float |
distanceCutoffHz |
|
| float |
occludedCutoffHz |
|
| float |
occlusion |
|
Returns
OcclusionAmountFromBlockedShare(float, float)
The occlusion amount when the real detour is unknown but a share of the probed fallback paths is blocked: the curve at
FallbackDetourShareOfFull of the full length when none is, one when all are, and linear in between.
Declaration
public static float OcclusionAmountFromBlockedShare(float blockedShare, float fullOcclusionDetourMeters)
Parameters
| Type |
Name |
Description |
| float |
blockedShare |
|
| float |
fullOcclusionDetourMeters |
|
Returns
OcclusionAmountFromDetour(float, float)
The occlusion amount for a sound that has to travel extraPathMeters more than the straight line
to get around an obstacle: a logarithmic curve (as in a diffraction model) from nothing at no detour to full occlusion at
fullOcclusionDetourMeters, bending at a tenth of it. Scale-free: only the share of the full length matters.
Not graded (the full length is zero or less): every hit is a full occlusion.
Declaration
public static float OcclusionAmountFromDetour(float extraPathMeters, float fullOcclusionDetourMeters)
Parameters
| Type |
Name |
Description |
| float |
extraPathMeters |
|
| float |
fullOcclusionDetourMeters |
|
Returns
OcclusionGain(float, float)
The linear level factor for a decibel drop scaled by the occlusion amount.
Declaration
public static float OcclusionGain(float levelDropDecibels, float occlusion)
Parameters
| Type |
Name |
Description |
| float |
levelDropDecibels |
|
| float |
occlusion |
|
Returns
ReverbWetShare(float, float, float)
The share of a voice that goes through the reverb: what its distance asks for, plus the authored
increase scaled by the occlusion amount, kept inside 0..1. A negative increase never lowers the share.
Declaration
public static float ReverbWetShare(float distanceWetShare, float occlusion, float occludedWetShareIncrease)
Parameters
| Type |
Name |
Description |
| float |
distanceWetShare |
|
| float |
occlusion |
|
| float |
occludedWetShareIncrease |
|
Returns
RoomMillibels(float, float)
The preset's own room level moved by the wet share, kept between silence and the maximum room level.
Declaration
public static float RoomMillibels(float baseRoomMillibels, float wetShare)
Parameters
| Type |
Name |
Description |
| float |
baseRoomMillibels |
|
| float |
wetShare |
|
Returns
ShouldProbe(float, float)
False when the listener is at (or within the clearance of) the source, so there is nothing to cast.
Declaration
public static bool ShouldProbe(float segmentLength, float sourceClearanceMeters)
Parameters
| Type |
Name |
Description |
| float |
segmentLength |
|
| float |
sourceClearanceMeters |
|
Returns
SmoothOcclusionTowards(float, float, float, float)
Moves the occlusion towards its target: a rising occlusion closes with closingTimeConstantSeconds
(zero, negative or not a number closes at once), a falling one always opens with OcclusionOpeningTimeConstantSeconds.
Declaration
public static float SmoothOcclusionTowards(float current, float target, float elapsedSeconds, float closingTimeConstantSeconds)
Parameters
| Type |
Name |
Description |
| float |
current |
|
| float |
target |
|
| float |
elapsedSeconds |
|
| float |
closingTimeConstantSeconds |
|
Returns
SmoothTowards(float, float, float, float)
Moves current towards target with an exponential step.
Declaration
public static float SmoothTowards(float current, float target, float elapsedSeconds, float timeConstantSeconds)
Parameters
Returns
WetShareToMillibels(float)
The reverb room level in millibels for a wet share: 2000 millibels per decade of share, silent at zero, never above full.
Declaration
public static float WetShareToMillibels(float wetShare)
Parameters
| Type |
Name |
Description |
| float |
wetShare |
|
Returns