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,
echoescopiesspacingsteps apart, each weighingecho_decaytimes 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
| Port | Carries | Notes |
|---|---|---|
| in0 | source texture (+ control messages) | The only trigger. Required. |
| in1 | vecfield (optional) | Behind its own vs_inState. Nothing connected: the angle dial sets the direction. |
| in2 | radius mod (red channel) | Optional. radius_eff = radius * (1 + mod), clamped to 0 to 0.3. |
| in3 | frequency mod (red channel) | Optional. freq_eff = freq * (1 + mod), clamped to taps / 2. No effect on the Comb. |
| out0 | composite | mix(src, clamp(src + layer * gain, 0, 1), mix_pct / 100); alpha is the source's. |
| out1 | signed layer | Unclamped float32; alpha 1. |
| (pix dumpout) | the pix's own dumpout | Not 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
| Param | Range | Default | Description |
|---|---|---|---|
kernel | Reson / Comb | Reson | Kernel menu (0 Resonant, 1 Comb). In the title bar. |
walk | Straight / Stream | Straight | Walk menu (0 Straight, 1 Streamline). In the title bar. |
radius | 0 to 0.3 | 0.1 | Reach of the walk in UV at field magnitude 1. The taps spread over it; one step is radius / taps. |
freq | 0 to 16 | 4 | Resonant: ripples per reach, in cycles per reach. Clamped to taps / 2 (Nyquist). |
decay | 0 to 10 | 2 | Resonant: damping in e-folds per reach; the envelope is exp(-decay * i / taps). 0 is an undamped ripple. |
phase | 0 to 1 | 0 | Resonant: phase of the cosine in cycles (the codebox multiplies by 2 pi). |
taps | 4 to 64 (int) | 32 | Taps along the walk, the loop bound. More taps is finer ripple and more cost. |
direction | 0 to 2 (int) | 0 | 0 both sides, 1 forward (+field, a trail), 2 backward. Same numbering as f_vf_glow. |
spacing | 1 to 16 (int) | 3 | Comb: steps between echoes (a step is radius / taps). |
echoes | 1 to 16 (int) | 4 | Comb: number of copies, the original included. |
echo_decay | -1 to 1 | 0.5 | Comb: weight of echo m is echo_decay^m. Negative alternates sign (odd teeth). |
angle | -180 to 180 | 0 | Degrees; the direction wherever there is no field (nothing on in1, or a black texel). |
jitter | 0 to 1 | 1 | Per-pixel dither of the tap positions, up to +-0.05 step at 1. 0 is the exact FIR. |
color_mix | 0 to 1 | 0 | 0 full-color layer, 1 Rec. 709 luma only. |
gain | 0 to 1.5 | 0.8 | Layer intensity added to the source. |
mix_pct | 0 to 100 | 100 | Blend toward the driven state. The message is mix_pct, not mix (mix is a codebox operator). |
bypass | 0/1 | 0 | Panel 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 everyspacing-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, notclamp()of the coordinate). jitterusesf_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_yis below 0.02 takes theanglefallback. That also drops a real full-strength (-1, -1) vector (known quirk shared withf_vf_glowandf_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. taps1 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):
| What | Result | Log |
|---|---|---|
| Resonant impulse, ripple copies, Params take effect, bounded at extremes | match 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 echoes | closed form at 1.1e-8; comb vs mirror 1e-7 / 2e-4 | 20261125-111623-bench.log (19/19) |
| Streamline equals Straight in an axis field and an oblique field, both kernels, all directions; vortex finite and in bound | 0.0 against 1e-4 / 3e-3 | 20261125-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.2 | 0.0 to 6e-8 | 20261125-113200-bench.log (30/30) |
| Contract bench, both outlets and bypass | f_vf_resonate lists no issue | 20261125-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 Streamline | passed | Matt, live, 2026-11-25 (T053; settings not recorded) |
| Look: Comb (T042) | passed | Matt, 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.
| Size | Walk | taps 16 | taps 32 | taps 64 |
|---|---|---|---|---|
| 512 x 512 | Straight | <= 0.24 (bypassed <= 0.22) | <= 0.33 (<= 0.28) | 0.63 (0.62) |
| 512 x 512 | Streamline | <= 0.33 (<= 0.25) | 0.49 (0.49) | 0.97 (0.98) |
| 1080p | Straight | 1.22 (1.22) | 2.10 (2.11) | 3.95 (3.96) |
| 1080p | Streamline | 1.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,
angle0,freq4,decay2,gain1. Edges shed fading ripples along the line; raisefreqfor a tighter pitch,decayfor faster damping. - Trails.
direction1 with a longradiusand lowdecay: the ripples land on one side only (a causal ring-down). - Echoes. Comb,
echoes4 to 8,spacing3,echo_decay0.5; negativeecho_decaygives alternating-sign (odd) teeth. - Following a field.
f_vf_vortexinto in1 withwalkStream at a longradius: 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_mixonly 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.