Ref / Hz.Plugins / Hz.Delay

Hz.Samplo, Hz.Syntho, FluidSynth, Hz.Osc
Hz.Filt, Hz.Echo, Hz.Delay, Hz.Reverb
Hz.Mix, Hz.LFO, Hz.ADSR
see also Hz.Builtins, Plugin Explorer, Hz.Plugins Examples


Wherein we hesitate to dally in presenting details of Hz.Delay.

Hz.Delay

The delay plugin can be added to your audio scenes to introduce a delay to the input signal. This can be used for a variety of effects.

Hz.Delay supports two input and one output port. These can be configured mono or stereo. The second optional input port must be mono and supports audio-rate delivery of Delay Modulation.

Parameters

Name Id Description Range
Delay 0 Delay Time 0-180 (.25)
DelayUnits 1 Units for Delay 0:Seconds, 1:Beats * (0)
ModScale 2 Scales optional incoming Delay Modulation signal 0-1 (.1)

*: beats are controlled by the Clap Host environment using clap_transport_events. You can use TimeKeeper API to specifiy this in the Hz environment.

Preset

Delay is configured with a maximum delay time. The default value of 1 second can be overridden but this must be done during node-creation using the preset mechanism as shown here:

let delay = scene.NewAnode("Hz.Delay", {preset:{maxDelay:2.0}});

Common Uses

Comb Effect

A feedforward Comb Filter is implemented by combining a signal with a delayed version of itself.

The feedback variant of the Comb Filter can also be implemented subject to the constraints discussed below.

Echo Effect

We provide Hz.Echo to create and process a delay feedback loop. For common situations, it should be preferred over the explicit Hz.Delay methodology described here. That said, if you want to know its inner workings, read-on.

Another common use of delay is to produce echo effects by routing the output of the delay through a feedback loop and back into itself (usually through a gain reduction node).

Here's a simple snippet:

scene.Chain(delay, gainreduction, delay); // our feedback loop

And here's a graph with an echo:

This works because Hz implicitly sums all inputs to the same audio port connection so delay sees both the output of osc as well as an amplitude-reduced version of its own delayed output.

And here's the Echo Example.

Feedback in Audio Graphs, the Nitty Gritty

From a graph-theoretic point of view feedback results in a graph with cycles, and the requirement that an audio graph be acyclic is violated. This use of feedback-delay is quite common in audio applications so we need a way to make it possible. Our solution, patterned after the solution implemented in WebAudio, is to eliminate the cycle by breaking delay into two pieces. The resulting acyclic graph looks like this:

Note that there are no more cycles in this graph and that two new nodes, delay_prior and blackhole, have been introduced. blackhole represents a magic connection from the output of delay to the hidden input of delay_prior. Careful readers will notice that this doesn't really remedy the cycle unless there is an implicit audio-chunk-sized delay between the blackhole output and the input to delay_prior. This is, in fact, the case and it imposes a minimimum valid delay period on the system.

A typical value for this minimum delay is 128 samples or around 0.3 milliseconds which is small for most purposes. Typical delays for echo effects are at least 100 ms. Generally, a delay of around 30 ms is considered the threshold for perceiving a distinct echo. Delays shorter than this tend to be perceived as part of the original sound, contributing to reverberation.

Extra Gritty

This node-splitting to resolve graph cycles theoretically works with any CLAP plugin node that follows this recipe:

  1. a splittable feature is present in the CLAP plugin-feature list described in the CLAP header file, plugin-features.h
  2. the plugin's process method must be written expecting to be run twice per-audio-chunk when a graph cycle is detected, otherwise it is run once. The prior execution mode can be detected with no or constant-only inputs, while the current execution mode can be detected by constant outputs. Normal, non-split behavior is detected when inputs and outputs are both present and not constant.

See Also

Delay Examples, Echo Examples

home .. topics .. interface .. reference .. examples .. tipjar