← f_ notebook · docs/f-reference/f_vf_resonate.md

f_vf_resonate ​

Type: Processor (f_vecfield consumer) Status: Built and benched 2026-11-25 (Claude offline plus live bench runs with Matt's go); the Straight-vs-Streamline look passed live (Matt, 2026-11-25, T053). Panel layout is provisional (G-ui-density). Cost measured 2026-11-25 (T073, below). Doc written 2026-11-25 (Claude, offline) from src/f_vf_resonate/{definition.py,codebox_resonate.gen}, .specify/f_vf_resonate/tasks.md and the bench logs named below.


What it does ​

Filters the source along the field direction with the weights of an audio filter, run in space instead of time. Each pixel gathers taps source samples along a line (or a streamline) and weights them with either

  • a Resonant kernel, a decaying cosine: an edge sheds fading ripples with a pitch (freq) and a damping (decay); or
  • a Comb kernel: an edge is repeated as evenly spaced, fading copies (feedforward echoes, echoes copies spacing steps apart, each weighing echo_decay times the last).

In a uniform field the module is an exact 1D FIR filter along a line, so its impulse and frequency responses have closed forms (checked, below). With nothing on the vecfield inlet the angle dial supplies a uniform direction, so it also works as a plain directional resonator.

Two outlets: the composite (source plus the layer times gain, clamped 0 to 1) and the isolated signed layer (float32, unclamped, so the negative lobes next to an edge survive).

Compatible with any f_vf_ producer (f_vf_vortex, f_vf_vortex_multi, f_vf_fieldmap, f_vf_fluid). It is a new module, not a mode of f_vf_glow or f_vf_streak (decision G2, Matt 2026-11-24); those are untouched.

Processor archetype: only the texture on in0 triggers the pix. With no source the module outputs nothing (processor archetype; not run here).


Inlets and outlets ​

PortCarriesNotes
in0source texture (+ control messages)The only trigger. Required.
in1vecfield (optional)Behind its own vs_inState. Nothing connected: the angle dial sets the direction.
in2radius mod (red channel)Optional. radius_eff = radius * (1 + mod), clamped to 0 to 0.3.
in3frequency mod (red channel)Optional. freq_eff = freq * (1 + mod), clamped to taps / 2. No effect on the Comb.
out0compositemix(src, clamp(src + layer * gain, 0, 1), mix_pct / 100); alpha is the source's.
out1signed layerUnclamped float32; alpha 1.
(pix dumpout)the pix's own dumpoutNot part of the signal path.

Each of in1 to in3 has its own vs_inState: an unconnected inlet delivers vs_black (all zeros) and the codebox gates it with a flag Param (src_vecfield, src_radius_mod, src_freq_mod). The flag lags about 180 ms when a cable is connected or removed (library finding, vsynth-bpatcher; not measured here), so for that time a freshly connected field or mod is still ignored. For in1 the value test below covers vs_black during the lag.

The output follows the render size (render_dim), type float32, @adapt 0. Taps are in UV units, so there is no width or height dial.


Parameters ​

ParamRangeDefaultDescription
kernelReson / CombResonKernel menu (0 Resonant, 1 Comb). In the title bar.
walkStraight / StreamStraightWalk menu (0 Straight, 1 Streamline). In the title bar.
radius0 to 0.30.1Reach of the walk in UV at field magnitude 1. The taps spread over it; one step is radius / taps.
freq0 to 164Resonant: ripples per reach, in cycles per reach. Clamped to taps / 2 (Nyquist).
decay0 to 102Resonant: damping in e-folds per reach; the envelope is exp(-decay * i / taps). 0 is an undamped ripple.
phase0 to 10Resonant: phase of the cosine in cycles (the codebox multiplies by 2 pi).
taps4 to 64 (int)32Taps along the walk, the loop bound. More taps is finer ripple and more cost.
direction0 to 2 (int)00 both sides, 1 forward (+field, a trail), 2 backward. Same numbering as f_vf_glow.
spacing1 to 16 (int)3Comb: steps between echoes (a step is radius / taps).
echoes1 to 16 (int)4Comb: number of copies, the original included.
echo_decay-1 to 10.5Comb: weight of echo m is echo_decay^m. Negative alternates sign (odd teeth).
angle-180 to 1800Degrees; the direction wherever there is no field (nothing on in1, or a black texel).
jitter0 to 11Per-pixel dither of the tap positions, up to +-0.05 step at 1. 0 is the exact FIR.
color_mix0 to 100 full-color layer, 1 Rec. 709 luma only.
gain0 to 1.50.8Layer intensity added to the source.
mix_pct0 to 100100Blend toward the driven state. The message is mix_pct, not mix (mix is a codebox operator).
bypass0/10Panel toggle only: drives the codebox Param bypass_gate. The message route has no bypass selector.

Prefix: vfresonate / Object name: vfresonate_pix

The kernel and walk menus, and every dial above except bypass, are addressable as messages on in0 (the route is radius freq decay phase taps direction spacing echoes echo_decay angle jitter color_mix gain mix_pct kernel walk). Defaults are the first values in the table; the G17 numbers were placeholders until the first bench and have not been changed since.

Q, stated once ​

For the Resonant kernel the quality factor is Q = pi * freq / decay. The reach cancels out (the number of taps divides both freq and decay). This is the high-Q approximation of Q = omega / (2 d) for a damped cosine; inferred, not run.


Algorithm ​

Mirror: tests/modules/vf_resonate/vf_resonate_mirror.py; formulas binding in .specify/f_vf_resonate/tasks.md ("Formulas").

field raw r in 0..1 (RG); v = 2*r - 1
if step(0.02, r_x + r_y) == 0 or src_vecfield == 0:  v = (cos a, sin a), a = angle
s  = v * radius_eff / N                      N = taps; |v| scales the reach

Resonant  e_i = exp(-decay * i / N)
          h_i = e_i * cos(2 pi * freq_eff * i / N + 2 pi * phase)
          one side:   y = sum_i h_i * src(uv + sgn * i * s)  /  sum_i e_i        i = 0..N-1
          both sides: y = (h_0 src0 + sum_{i>=1} h_i (src(uv + i s) + src(uv - i s))) / (1 + 2 sum_{i>=1} e_i)
Comb      echo m = 0..M-1 (M = echoes) at uv + sgn * m * spacing * s, weight g^m, g = echo_decay
          y = sum_m g^m src(...) / sum_m |g|^m   (both sides: m = 0 once)
Streamline  pos_{k+1} = pos_k + v(pos_k) * radius_eff / N, the field re-read (nearest) at each position

layer  = mix(y, luma709(y), color_mix)                 signed, unclamped
driven = clamp(src + layer * gain, 0, 1)
comp   = mix(src, driven, mix_pct / 100)
out0   = mix(comp, src, bypass_gate)    out1 = mix(layer, src, bypass_gate)

Normalization rule (the safety rule) ​

The output is divided by the sum of the envelope (sum e_i, or sum |g|^m for the Comb), never by the signed sum of the weights. The center tap has e_0 = 1, so the denominator is at least 1: no divide by zero. Since |h_i| <= e_i, |y| <= max|src|: the response cannot blow up however the cosine lobes cancel. The DC gain sum(h) / sum(e) lies in [-1, 1] and is the layer's value on flat areas (it can be near zero or negative, as an audio resonator has no DC; the layer is then near black or inverted on flat regions). Contrast f_vf_streak, which divides by a signed-weight sum.

Direction numbering and walk sign ​

direction 0 is both sides (a symmetric, zero-phase filter; the center tap counts once), 1 forward (+field, causal: a trail behind anything that moves with the field), 2 backward (a lead). Forward is +field in both walks, as f_vf_glow. f_vf_streak walks -field; this module does not copy that (decision G14).

Walks ​

  • Straight: the field is read once at the pixel and the taps lie on a straight line through it, as f_vf_glow. Curves come from neighboring pixels' lines turning with the field.
  • Streamline: the field is re-read at every step (nearest, clamped) and the tap positions are the streamline. Direction 0 is that one path reflected through the pixel (2 uv - p), not a second walk. For the Comb the path advances one step at a time and a tap sits at every spacing-th step.

In a uniform field the two walks are equal (observed, below).

Edges, jitter, zero vectors ​

  • Out-of-frame taps clamp to the edge texel on all four borders (boundmode="clamp" on each read, not clamp() of the coordinate).
  • jitter uses f_vf_glow's hash (fract(sin(...) * 43758.5453), +-0.05 step). It hides banding at long reach but smears fast ripples; it breaks the exact FIR, so every closed-form check uses 0.
  • A texel whose raw_x + raw_y is below 0.02 takes the angle fallback. That also drops a real full-strength (-1, -1) vector (known quirk shared with f_vf_glow and f_vf_prism).
  • A genuine zero vector (0.5, 0.5) collapses all taps onto the pixel, so the layer there is the DC gain times the source: it is not black (the same as f_vf_glow's documented behavior). No special case.
  • taps 1 would give the source; the dial's lower bound is 4, the codebox clamps to 1 to 64.

Bypass ​

bypass_gate mixes the source onto both outlets at the end; the tap loop keeps running (no early exit). Bypass is exact on both outlets (contract bench, below).


Observed and inferred ​

Observed (live bench, Max 9, Claude ran with Matt's go, 2026-11-25):

WhatResultLog
Resonant impulse, ripple copies, Params take effect, bounded at extremesmatch the mirror at 1e-8 (whole-pixel steps), 2e-4 (fractional)tests/logs/20261125-110741-bench.log (14/14)
Comb impulse (copies at 0, 3, 6, 9 with 1, 0.5, 0.25, 0.125 over 2.75), negative decay, decay 1 with 8 echoesclosed form at 1.1e-8; comb vs mirror 1e-7 / 2e-420261125-111623-bench.log (19/19)
Streamline equals Straight in an axis field and an oblique field, both kernels, all directions; vortex finite and in bound0.0 against 1e-4 / 3e-320261125-112318-bench.log (24/24)
Mods: flags off or black texture = no modulation; fmod 0.5 at freq 4 = freq 6; clamps; frequency ramps vs mirror; radius 1 at 0.1 = radius 0.20.0 to 6e-820261125-113200-bench.log (30/30)
Contract bench, both outlets and bypassf_vf_resonate lists no issue20261125-113313-bench.log (the bench as a whole fails on the audio modules, not this one)
Look: f_vf_vortex into it, Straight against Streamline at long reach, the ripples bend with the arms in StreamlinepassedMatt, live, 2026-11-25 (T053; settings not recorded)
Look: Comb (T042)passedMatt, live, 2026-11-25 (what he looked at not recorded)

Known open item (T061, not fixed): a radius-mod ramp on a sharp source (noise, an impulse) does not match the mirror: errors 2e-2 to 6e-2, confined near the impulse. A nearest-tap model did not explain it (the rerun failed too); a mip-level blend from the coordinate derivatives is a guess, untested. The ramp is read and applied (verified on a smooth one-cycle sine source, 4.9e-4 Resonant and 1.6e-3 Comb against a 5e-3 bound), and a constant radius mod and frequency-mod ramps match exactly. So the exact response shape of a radius ramp on high-frequency content is unverified.

Inferred (not confirmed by a run):

  • Taps at per-pixel varying positions (a vortex field, a radius ramp) read nearest-like through sample(); the vortex rows are compared with the nearest-tap mirror (7.2e-3 against 7.0e-2 for the bilinear one). The cause is inferred.
  • Streamline on a vortex differs from the mirror by a path flip on about 0.05% of texels (max 1.5e-2); inferred.
  • Q = pi * freq / decay (high-Q approximation).
  • The ~180 ms flag lag is the library figure, not measured on this module.

Cost ​

Observed (Claude ran, Matt's go, 2026-11-25, tests/logs/20261125-115113-bench.log, bench_vf_resonate_cost.py): ms per pass of the shipped codebox, chain 8, Resonant, direction 0, a swirl field on in1, jitter 1, float32.

SizeWalktaps 16taps 32taps 64
512 x 512Straight<= 0.24 (bypassed <= 0.22)<= 0.33 (<= 0.28)0.63 (0.62)
512 x 512Streamline<= 0.33 (<= 0.25)0.49 (0.49)0.97 (0.98)
1080pStraight1.22 (1.22)2.10 (2.11)3.95 (3.96)
1080pStreamline1.75 (1.75)3.25 (3.22)6.39 (6.35)

"<=" marks an upper bound at the bench's own per-frame floor (the pass was not GPU bound, so it is not resolved). Bypassed cost equals active cost: the loop still runs (G20). Cost grows about linearly with taps; Streamline costs about 1.5x Straight (one nearest field read per step). At the default taps 32: 1080p is 2.1 ms Straight and 3.3 ms Streamline per pass. Float32 against char was not measured. Cost target (G18, NF-002; Matt, 2026-11-25): the library's whole-module budget, at most 5 ms at 1080p (the f_tf_hatch figure, M3 Max). Against this table: default taps 32 passes on both walks (2.1 ms Straight, 3.3 ms Streamline); taps 64 passes on Straight (3.95 ms) and fails on Streamline (6.4 ms), so Streamline above about taps 48 is over budget (inferred from the linear growth, not measured). Do not compare with f_vf_glow's 0.057 ms at 512 squared (a different, shorter loop).


Notes and recipes ​

  • A plain directional ringing. Nothing on in1, angle 0, freq 4, decay 2, gain 1. Edges shed fading ripples along the line; raise freq for a tighter pitch, decay for faster damping.
  • Trails. direction 1 with a long radius and low decay: the ripples land on one side only (a causal ring-down).
  • Echoes. Comb, echoes 4 to 8, spacing 3, echo_decay 0.5; negative echo_decay gives alternating-sign (odd) teeth.
  • Following a field. f_vf_vortex into in1 with walk Stream at a long radius: the ripples bend with the arms; Straight runs tangents.
  • Layer for compositing. out1 is signed. A downstream module that needs 0 to 1 must clamp it; the float32 type preserves the negative lobes.
  • Chromatic ringing (per-channel frequency detune) is not in v1 (User Story 6, P3); color_mix only goes from full color to luma.

Related: f_vf_glow.md (Gaussian accumulation, no signed lobes), f_vf_streak.md (8 streamline steps), f_vecfield_type.md (the field contract).


References ​

Designed in development; no code or formula copied from outside. The damped-cosine FIR, the geometric-series frequency response of a feedforward comb, and Q = omega / (2 d) are standard signal-processing results. The tap-loop idiom, the field decode and the jitter hash follow f_vf_glow in this library. Field type contract: docs/f-reference/f_vecfield_type.md.