Delay

Shippingstateful
delay

Time-domain signal delay with ring buffer state persistence

Signature

Inputs

  • signalSignalrequired

Outputs

  • delayedSignal

Parameters

KeyTypeDefaultNotes
delay_modeenumsamplesone of: samples, time
delay_samplesint0
delay_timefloat0.001s
fill_modeenumconstantone of: constant, hold, nan
fill_valuefloat0.0

Description

Delay shifts a signal forward in time by an integer number of samples, emitting each input sample only after the specified lag has elapsed. Given input and delay , the output is . The delay amount is set either directly in samples (delay_mode = samples) or in seconds (delay_mode = time), in which case it is converted at runtime to using the input sample rate . Fractional-sample delays are not interpolated; the value is rounded to the nearest whole sample.

The node is stateful. A circular ring buffer (DelayState) persists the trailing samples across block boundaries, so streaming a signal in chunks yields exactly the same result as processing it in one pass — essential for continuous DAQ and closed-loop simulation. The buffer is resized whenever the effective delay signature changes.

Output length, sample rate, and physical unit are identical to the input; a pure time shift alters no magnitude, so units pass through unchanged. Per-sample uncertainty () is likewise shifted verbatim: , since delaying a sample does not change its variance. Only the pre-delay region — the first output samples that have no corresponding real input yet — is synthesized by the fill policy: constant (pad with fill_value), hold (repeat the first real sample), or nan (mark as undefined).

Mathematics

Examples

Aligning two acquisition channels

A reference channel arrives 8 samples ahead of a sensor channel due to cabling and ADC pipeline latency. Set delay_mode = samples, delay_samples = 8 on the reference path to time-align both streams before differencing. Because the delay is exact and stateful, alignment holds across every acquisition block.

Time-specified delay for an echo

To delay a audio stream by , use delay_mode = time, delay_time = 0.02. At runtime this becomes samples. Use fill_mode = constant with fill_value = 0 so the output is silent until the first delayed sample arrives:

signal_generator -> delay(delay_time=0.02) -> audio_output

Applications

  • Compensating for propagation, cabling, or ADC-pipeline latency to time-align multiple measurement channels before comparison or subtraction.
  • Building feedback and control loops in simulation, where a unit or fixed delay ($z^{-D}$) models actuator/sensor lag and prevents algebraic loops.
  • Digital audio effects such as echo, comb filtering, and delay lines feeding reverb or flanger chains.
  • Constructing custom FIR-like structures and matched-delay reference paths for cross-correlation and time-of-flight estimation.

Neat

In control-loop terms the node realizes the discrete transfer function $H(z) = z^{-D}$ — a pure phase shift with unity magnitude at all frequencies.

Because the ring buffer carries state across blocks, a large delay (up to $10^6$ samples) processed chunk-by-chunk uses only $D$ samples of memory, not the whole stream, and is bit-identical to whole-signal processing.

Known issues

Time-mode delay is rounded to the nearest whole sample: $D = \operatorname{round}(t_d f_s)$, so requested times that fall between sample periods incur up to half-a-sample quantization error and no sub-sample interpolation is performed.

With `fill_mode = nan` the pre-delay region contains NaN; downstream arithmetic nodes will propagate NaN unless those leading $D$ samples are trimmed or guarded.

See also

delaytime-shiftstatefulring-bufferlatencystreaming