Build with this node

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

Ask Studio

@maruaudio/dsp/filters/dc-block is a leaky differentiator, y[n] = x[n] − x[n-1] + p·y[n-1], with DaisySP DcBlock's f32 semantics. Every operation rounds through Math.fround, in the order DaisySP computes it. The CHOMPI firmware uses it on its line, mic and pre-filter FX signals.

const state = initDcBlockNode() // pole 0.99
const y = dcBlockNodeTick(state, x)

Parameters

There are no setters. The pole is passed to initDcBlockNode(pole = 0.99) and stored as an f32; there is no clamp.

Init argumentRange as codedDefaultUnit
poleAny number, rounded to f320.99per-sample feedback

Lifecycle

initDcBlockNode → dcBlockNodeTick per sample → resetDcBlockNode, which clears the one-sample input and output history and keeps the pole. There is no prepare step, because the pole does not depend on the sample rate.

When to use it

Remove a constant offset after an asymmetric distortion, a rectifier or a microphone input, before a stage that would otherwise drift or clip on DC.

Limits

  • Mono sample tick with one sample of history.
  • The pole is per sample, so the corner moves with the rate: the source notes about 76 Hz at the firmware's 48 kHz. Pass another pole for another corner.
  • No guard: a pole at or above 1 is not refused.

Implementations

Rust Output verified: The build passed and its output matches the reference implementation.

Verified on Apple Silicon macOS native and Node WASM with poles 0, 0.25, 0.9, 0.99 and 0.9999; this node has no sample-rate parameter. Output and state match the TypeScript reference, with no observed allocations, reallocations or deallocations during the tested processing, control and reset calls. Browser hosts, plugins, other operating systems and realtime deadlines have not been verified. Performance has not been measured.

View target checks and scope

Algorithm properties and proofs

Lean 4 checks specific properties of this algorithm’s mathematical model. Each model result applies within its stated domain and assumptions.

5 Lean 4 results: 4 proofs in exact arithmetic; 1 counterexample.

Proved in exact arithmetic.Adding the same DC offset to the current and previous inputs leaves the exact blocker step unchanged.Exact rational filter state, finite mathematical controls and explicit interval hypotheses
Limits and assumptions
  • Hand-written source-reviewed exact-rational model, not formal TypeScript or compiled-code refinement. Named source files and symbols are digest-bound, and executable dyadic cases are compared with canonical JavaScript. The real DC blocker frounds input, pole, difference, product and output; the model omits all those roundings and excludes NaN, infinity, overflow and signed-zero distinctions. The default 0.99f is not asserted equal to an exact design constant. Constant-response identities do not by themselves prove arbitrary-input stability, and the public pole API does not enforce a stable pole.
Theorem
MaruLean.FilterContracts.dc_offset_invariant
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Proved in exact arithmetic.Once the previous input equals a constant stream, the exact blocker output is the initial output times the pole raised to the sample count.Exact rational filter state, finite mathematical controls and explicit interval hypotheses
Limits and assumptions
  • Hand-written source-reviewed exact-rational model, not formal TypeScript or compiled-code refinement. Named source files and symbols are digest-bound, and executable dyadic cases are compared with canonical JavaScript. The real DC blocker frounds input, pole, difference, product and output; the model omits all those roundings and excludes NaN, infinity, overflow and signed-zero distinctions. The default 0.99f is not asserted equal to an exact design constant. Constant-response identities do not by themselves prove arbitrary-input stability, and the public pole API does not enforce a stable pole.
Theorem
MaruLean.FilterContracts.dc_constant_history_response
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Proved in exact arithmetic.From cleared history, a constant input produces its amplitude followed by the exact geometric pole response at every sample index.Exact rational filter state, finite mathematical controls and explicit interval hypotheses
Limits and assumptions
  • Hand-written source-reviewed exact-rational model, not formal TypeScript or compiled-code refinement. Named source files and symbols are digest-bound, and executable dyadic cases are compared with canonical JavaScript. The real DC blocker frounds input, pole, difference, product and output; the model omits all those roundings and excludes NaN, infinity, overflow and signed-zero distinctions. The default 0.99f is not asserted equal to an exact design constant. Constant-response identities do not by themselves prove arbitrary-input stability, and the public pole API does not enforce a stable pole.
Theorem
MaruLean.FilterContracts.dc_constant_after_first
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Show 2 more Lean 4 results
Proved in exact arithmetic.Explicit bounded-input, previous-input, pole and output hypotheses bound one exact blocker step.Exact rational filter state, finite mathematical controls and explicit interval hypotheses
Limits and assumptions
  • Hand-written source-reviewed exact-rational model, not formal TypeScript or compiled-code refinement. Named source files and symbols are digest-bound, and executable dyadic cases are compared with canonical JavaScript. The real DC blocker frounds input, pole, difference, product and output; the model omits all those roundings and excludes NaN, infinity, overflow and signed-zero distinctions. The default 0.99f is not asserted equal to an exact design constant. Constant-response identities do not by themselves prove arbitrary-input stability, and the public pole API does not enforce a stable pole.
Theorem
MaruLean.FilterContracts.dc_step_bound
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Counterexample.An unrestricted pole of two makes a unit constant input grow to eight by the fourth sample.Exact rational filter state, finite mathematical controls and explicit interval hypotheses
Limits and assumptions
  • Hand-written source-reviewed exact-rational model, not formal TypeScript or compiled-code refinement. Named source files and symbols are digest-bound, and executable dyadic cases are compared with canonical JavaScript. The real DC blocker frounds input, pole, difference, product and output; the model omits all those roundings and excludes NaN, infinity, overflow and signed-zero distinctions. The default 0.99f is not asserted equal to an exact design constant. Constant-response identities do not by themselves prove arbitrary-input stability, and the public pole API does not enforce a stable pole.
Theorem
MaruLean.FilterContracts.dc_unstable_pole_refuses_decay
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Explore proofs alongside performance

Ports

  • In ininput · audio · mono
  • Out outoutput · audio · mono

One sample per dcBlockNodeTick call.

Dependencies

None: this node imports no other node.

Dependents

Used by