f_util_envelope: a scalar conditioner
Started 2026-11-23. Status: ⚪ concept only, nothing specced or built.
Provenance. Written from reading ideas/f_util_analysis.md, ideas/CV_TRIGGER_INVENTORY.md and ideas/vsynth_lfo_expansion.md (offline, Claude, 2026-11-23) plus general Max knowledge. Nothing here was tried in Max. Items marked (inferred) are worked out, not observed. ideas/f_util_analysis.md already names f_util_envelope as the conditioning step; this file is the first one dedicated to it.
Scope (decided in chat 2026-11-23)
A conditioner on scalars, and lists of scalars. Not on textures, vecfields or tensors. A per-pixel temporal filter on a field is a different idea (a lag or persistence on a field, likely overlapping the temporal modules) and is out of scope here.
Why scalar: the LFO's float stream (ideas/vsynth_lfo_expansion.md), the analysis utilities' outputs and audio followers all produce scalars. One conditioner serves all three.
Correction, 2026-11-24 (docs/f-reference/f_util_profile.md, offline): f_util_profile outputs are 128x1 and 1x128 GL textures (made by js from matrices after asyncread and jit.dimop), not matrices. A list mode on a profile therefore either taps the matrix inside f_util_profile or conditions the texture directly. A texture-domain route is described in ideas/dspless_control_modules.md item 5; it is raised there and not decided.
What it is for
ideas/f_util_analysis.md: raw analysis output is noisy and jumpy, and the gap between "the GPU produces a number" and "that number usefully drives a parameter" is mostly conditioning. This is that step. It also covers the shaping ideas that came up for the LFO (slew, sample and hold, quantize, a response curve, invert), which belong here rather than inside the LFO because they work on any scalar source. Exception (Matt, 2026-11-23): f_lfo also gets its own rise/fall smoothing stage (.specify/f_lfo/spec.md, story 11) so the LFO can round its steps; this module stays the general conditioner for any other scalar.
Candidate functions
Smoothing and following
- Attack and release (separate rise and fall times). An envelope follower on a scalar.
vs_envelope_followeralready does this for audio in Vsynth (perCV_TRIGGER_INVENTORY.md); this one is for any scalar, not audio. - Slew, rise and fall separately, from instant to long. The same math as 1 with different intent; one control set could cover both.
- Frame-rate-independent time constants. Times in milliseconds, not per-frame coefficients, so the feel does not change when the draw rate does (inferred as a requirement: a per-frame smoother changes character at 30 versus 60 fps).
- Peak hold with decay (a meter-style top that falls slowly).
- Median or outlier rejection for analysis values that spike for a single frame.
Gating and holding
- Threshold with hysteresis (a Schmitt trigger), so a noisy signal does not chatter, with a gate output as well as the scalar.
- Sample and hold, clocked from Hz, a beat, or an incoming bang, with optional slew into the held value.
- Freeze (hold the current output until released).
- Dead band (ignore changes below a size).
Mapping
- Range scale (in-min, in-max, out-min, out-max) with clamp or wrap.
- Response curve (bend toward the low or high end).
- Invert and rectify.
- Quantize to N levels, which is useful for discrete-item parameters.
Derived outputs
- Rate of change (derivative, smoothed) as a second output.
f_util_analysis.mdnotes that a slowly oscillating value and a jumping one are different things, and this makes that visible. - Difference or ratio of two inputs. The same note says a ratio of two analysis outputs is often steadier than either alone. Needs a second input.
Lists
- Per-element or shared settings. For an N-list, one set of controls applied to all elements, with an option to give each element its own freeze or hold (the per-channel freeze idea from the LFO note). Open: how elements are addressed in a bpatcher UI.
Implementation direction (Matt, 2026-11-24)
Message-rate js on the draw tick, no DSP (decided). vs_render has no dac~ or DSP message and runs on a qmetro, so a gen~ module would do nothing in a video-only patch (inferred). Templates: f_lfo.js and f_util_vary.js; give the value on a float outlet and a 1x1 float32 texture outlet, as f_lfo. Times from elapsed ms with a stall clamp. Details, the texture-domain alternative and the related trigger and clock ideas are in ideas/dspless_control_modules.md.
The generator question (not decided)
Update 2026-11-24: vs_envelope already is a simple one-shot A-R generator (a 1x1 texture, fired by a button, a bang or a brightness trigger). What is still open is sustain on a gate, ms times, retrigger and per-pixel use.
A one-shot envelope (an ADSR-style shape fired by a trigger) is a separate thing from a conditioner. It could be a mode of f_lfo (retrigger and one-shot, item 7 of the LFO note) or a small module of its own. It is a scalar too, so it could share the carrier and the UI vocabulary with this module. Matt has not decided; ask again once f_lfo's shape is clearer.
Questions
- How is it wired into Vsynth? Scalar in and out as messages, or as texture inlets carrying a 1x1 value. The LFO note recommends scalar-first, which suggests message inlets and outlets; the Vsynth pattern for scalar-only modules has not been checked.
- What is new compared with Max's own objects? Smoothing, slew, scale and sample-and-hold all exist as Max objects, and
vs_envelope_followerexists (audio only:peakamp~polled byr draw, thenjit.slidewith separate up and down factors; read offline 2026-11-24). Vsynth's texture modules also work on a 1x1 control texture (vs_vca,vs_frame_delay,vs_filter_temp,vs_s&h; table indocs/vsynth-reference/module-inventory.md), butvs_filter_temphas one coefficient, so no separate rise and fall, and nothing has hysteresis or hold. The value of a module is the bundle: one place with frame-rate-independent times, hysteresis, holds, a list mode and a display, withf_conventions. If a patch can do it with two objects and no UI, the module needs to earn its place. Worth a check against whatvs_audio2videoand the Vizzie followers inCV_TRIGGER_INVENTORY.mdalready cover. - Where does the CPU state live? A conditioner needs memory across frames, so it must run in Max (an object or
js), not in a pix. Decided (Matt, chat 2026-11-24): message-ratejs, notgen~. See "Implementation direction" below. - Display. A small trace of input and output on the module would show what the smoother is doing; same jsui question as the LFO's display.
Implementation direction (decided 2026-11-24; reasoning inferred)
Message-rate js, driven by the draw bang (or its own timer), no audio dependency. Matt chose this over a gen~ engine fed by sig~/snapshot~.
Why. vs_render.maxpat has no dac~, ezdac~, startwindow or DSP message, and its render loop is a qmetro (Max scheduler), not the audio clock (read from the file QT-revised/patchers/vs_render.maxpat, offline by Claude, 2026-11-24; the other copies under ~/Github/vsynth/ were not checked). So Vsynth video runs with DSP off, and a gen~ module would do nothing there (inferred; not tried in Max).
What follows from it:
- Time constants in ms from elapsed time per tick (
cpuclockorDate), not per-frame coefficients, which keeps item 3 true without the audio clock. Needs a guard for the first tick and for very long gaps (a paused or stalled draw). - Lists (item 16) are plain arrays in the
js; nomc.*objects. Per-element freeze is an array of flags. - Median (item 5) is easy here (short ring buffer plus sort), so it no longer has to wait.
- Lost compared with audio objects: no reuse of
slide~,schmitt~,sah~. Everything is written and tested injs, so each function needs its own check. - Open: whether to drive from
r draw(one update per frame, tied to the render) or a separateqmetro(works with no render loop running). Not decided or tried. - The "audio followers" input in the scope section still works: the audio side converts to a scalar elsewhere (
vs_envelope_follower,snapshot~) and arrives here as a float.
Suggested first slice (a recommendation, not a decision)
Items 1/2 (attack and release), 10 (range scale), 6 (threshold with hysteresis) and a list mode for item 16. That covers the analysis-conditioning case f_util_analysis.md describes. Sample and hold, quantize and derived outputs follow once that is live-checked.