Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@maruaudio/dsp/delays/clocked-glitch is the CHOMPI TEMPO firmware's tempo-synced stereo glitch delay. An f32 ring takes the input plus 0.975·feedback; two read voices follow interval_us · 0.192 · division samples (slewed) with 960/480-frame tap offsets. On clock edges a newlib rand() draw against 0.5·alt may re-voice the next repeat (retrigger, reverse, pitch up or down, or pitch up with random pan), with 1024-sample crossfades. Freeze loops the wet output from a second ring, restarting every division-dependent number of pulses. All arithmetic is f32 in firmware order.

Parameters

SetterValue as codedInitUnit
setClockedGlitchDelayClock(state, tempo, intervalUs, divPos)Floored; the clock manager's 2× BPM, µs interval and division position320, 187500, 0—
setClockedGlitchDelayFeedbackStored as 0.975·value, not clamped0.3linear
setClockedGlitchDelayMainBelow 0.45 event delay, above 0.55 pitch/pan delay, wet ramps 0.40–0.45 and 0.55–0.60; the centre switches off once wet is below 0.010.5 (off)normalized
setClockedGlitchDelayAltEvent probability 0.5·alt and pan width0normalized
setClockedGlitchDelayFreeze / …ToggleFreezeImmediate, or a through-zero fade when the delay is onOffflag
setClockedGlitchDelayMuteOptionMutes for one delay time after unfreezinginit argumentflag

Lifecycle

initClockedGlitchDelay(frames = 480000, muteOption, sampleRate = 48000) allocates two frames × 2 f32 rings (7,680,000 bytes at the default) and a sine table → setters → clockedGlitchDelayClockEdge and clockedGlitchDelayClockPulse (24 ppqn) as the clock arrives → clockedGlitchDelayTick(state, random, l, r), which writes then reads (outLeft, outRight) → resetClockedGlitchDelay, which clears the rings and restores the power-on state, keeping the clock inputs and mute option.

When to use it

Tempo-locked stutters, reversed and pitched repeats and frozen loops that follow a sequencer clock.

Limits

  • Stereo, wet only. Tempo-derived lengths convert at sampleRate through @maru/control-musical-clock; sample-count constants are not rescaled.
  • The rand() state is passed in, so the owner shares one stream with other consumers in upstream call order. Firmware quirks are kept, such as an edge staying pending while frozen.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Parameters

ParameterTypeSetter
Clocked glitch delay feedback clockedGlitchDelayFeedback

Upstream `setFeedback`: `val · 0.975`.

floatsetClockedGlitchDelayFeedback
Clocked glitch delay main clockedGlitchDelayMain

Upstream `setMainControl`: below 0.45 the event delay, above 0.55 the pitch-up/pan delay, with wet ramps over 0.40–0.45 and 0.55–0.60; the centre band fades the wet out and switches the delay off once it is below 0.01 (checked at the call). Values above 0.6 or below 0.4 also pick the division (`processDelay` :421-427).

floatsetClockedGlitchDelayMain
Clocked glitch delay alt clockedGlitchDelayAlt

Upstream `setAltControl`: event probability `0.5 · alt` and pan width.

floatsetClockedGlitchDelayAlt
Frozen frozen

Upstream `setBufferLock`: set the freeze immediately (no fade).

boolsetClockedGlitchDelayFreeze
Enabled enabled

The "delay unfreeze mute" option (`delay_mute_option_`).

boolsetClockedGlitchDelayMuteOption

Dependencies

Dependents

No other node imports this one.

Used by