Coerces an unknown value into a finite number, falling back to a default when validation fails.
function coerceFiniteNumber(value: unknown, fallback: number): number;
Note: this function is defined and exported from
utilities/helpers.ts, but it is not re-exported from the package's top-levelindex.ts. It is not currently reachable asimport { coerceFiniteNumber } from "@fluex/fluexgl-dsp"— it is used internally by the effect classes (e.g.Chorus,HardClip) to sanitize constructor and setter arguments. Documented here for completeness.
The coerceFiniteNumber() function ensures that a usable finite numeric value is always returned.
It internally validates the provided value using isFiniteNumber() and:
This helper is especially useful for sanitizing external input, user-provided parameters, or messages received from AudioWorklet nodes before applying them to DSP logic.
value: unknown – The value to validate and coerce.fallback: number – The fallback value to return if validation fails.number – A guaranteed finite numeric value.This function does not emit any errors or warnings.