f_lfo
A CPU low-frequency oscillator for control work. Its main job is to stream a float that drives other parameters; the same value also leaves a second outlet as a 1x1 float32 texture, so it can stand in for vs_lfo on a modulation inlet. The value is computed in a Max js object, so there is no GPU read-back and the module keeps state between frames (the random shapes).
Written from package/javascript/f_lfo.js, package/javascript/f_lfo_display.js, the builder src/f_lfo/build_lfo_patcher.py and .specify/f_lfo/{spec,plan,tasks}.md, offline, 2026-11-23 (Claude). Status: the math passes an offline Node check; the patcher, the texture outlet, the display and the feel have been looked at in Max only in part (see "Status").
Inputs and outputs
- Inlet 0: control messages (below). A
tickmessage advances the oscillator; the patcher sends one on everyr draw. - Outlet 0: texture, 1x1 float32, RGB all equal to the value, alpha 1 (the matrix cell is written alpha first,
1. v v v, because Jitter matrices are ARGB; the first version had the order wrong and showed blue where the value was 0, Matt live 2026-11-23; the corrected version shows white and black, Matt live 2026-11-23). - Outlet 1: float, the same value. (Same order as
vs_lfo: texture, then data.)
The float is sent first, then the texture is made from it, so the texture is at most one frame behind.
Messages
The five vs_lfo messages keep their names and argument meanings (waveform indices differ, below), so a patch can switch over by renaming the object and renumbering waveform.
| Message | Range / default | Effect |
|---|---|---|
bypass | 0 / 1, default 0 | the library's bypass pill (top right of the panel): 1 holds the module, the same as enable 0 |
enable | 0 / 1, default 1 | vs_lfo's message; off: no output, the last value stays; on: resumes from where it stopped, no jump |
waveform | 0-4, default 0 | 0 Sine, 1 Triangle, 2 Pulse, 3 Wobble, 4 Drunk. Wobble is random points glided between with a cosine; Drunk is the same glide over a bounded random walk (each point a step of up to 0.35 of the range from the last, reflected at 0 and 1). The timing is irregular too: each segment between points is 0.5 to 1.5 times the nominal length (1 / (freq x cycles)), a fresh random length per segment, so the mean is the nominal period; phase and pw do nothing on them. vs_lfo's Triangle, Sawtooth, Ramp and S&H are gone, and so is a separate Stepped (the Triangle with steps is it) (Matt, 2026-11-23): the Triangle at pw 100 is a saw, at 0 a ramp, at 50 a symmetric triangle that starts a quarter cycle off vs_lfo's (phase can match it); so the indices differ from vs_lfo's and a swapped-in patch must renumber waveform |
freq | Hz, default 1 | rate; clamped to the active range |
freq_range | 0 / 1, default 0 | 0: 0-1 Hz, 1: 0-10 Hz (on the panel a compact range menu right of the freq label above the dial, as the library's range_tiers: tiers 1.0 and 10.0, not a toggle) |
pw | 0-100 percent, default 50 | a skew, the rising share of the cycle: the Triangle's rise; the Pulse's duty; the Sine's rise (cosine-eased trough to peak over pw percent of the cycle, the fall over the rest; it still starts at the midline falling, and 50 is exactly vs_lfo's sine, so a patch at the default is unchanged); unused on Wobble and Drunk |
cycles | 1-64, default 1 | how many times the shape repeats within one period; freq sets the period, so the output rate is freq * cycles. for Wobble and Drunk it sets the nominal segment length |
steps | 0-64, default 0 | steps per cycle, on any shape: the cycle is cut into that many equal slots; the shape's value at each slot start is a flat plateau held over the middle half of the slot, and the move to the next plateau is a rounded cosine glide centered on the slot edge (the other half), so a stepped sine keeps its curve where it is not flat and a stepped Triangle steps up and then down; 0 is off (smooth); applied before curve. On a Pulse the edge lands on the slot grid; on Wobble and Drunk it steps the glide. The rounded half is fixed (not a control) |
depth, offset | 0-1, defaults 1 and 0.5 | the window: offset + depth * (v - 0.5), clamped to 0-1. Offset is the window's center |
phase | 0-1, default 0 | start offset in shape cycles; changing it while running moves the output with no restart, and shifts the displayed curve left or right |
bipolar | 0 / 1, default 0 | 2v - 1 of the windowed value, on both outlets |
curve | -1 to 1, default 0 | v ^ (4 ^ curve) on the 0..1 shape: 0 is the identity, the endpoints stay fixed |
shape | -1 to 1, default 0 | symmetric bend about 0.5 after curve: x = 2v-1, v = 0.5 + 0.5 * sign(x) * abs(x) ^ (4 ^ -shape); positive pulls values toward 0 and 1, negative toward the middle; ends and the middle crossing stay |
ripple | 0-1, default 0 | a sine added before the window: 0.25 * ripple * sin(2 pi rp), not clamped there (so depth and offset scale it; only the window's final clamp to 0..1 cuts it); on both outlets and the marker; drawn in the display as the next period from the marker (the curve is redrawn every tick while ripple > 0) |
ripple_rate | 0.05-20 Hz, default 4 | the ripple's own free-running clock rp, independent of the period; restart zeroes it. Ripple and freq are additive clocks: if ripple_rate / freq is a whole number (the default 4 Hz on 1 Hz is exactly 4) every cycle starts at the same ripple phase and the ripple looks reseeded; a fractional ratio (3.7) drifts. Matt live 2026-11-24; the cause is inferred from the code, his workaround accepted |
restart | phase back to phase; the Wobble and Drunk points keep going | |
refresh | resend the display's state |
Order of operations
phase and cycles (the shape phase is period phase * cycles + phase), then shape (0..1) in steps rounded steps, then curve, then the window (depth, offset), then bipolar.
Rate
Frame-rate independent: each tick measures the elapsed time (clamped to 250 ms, so a stall does not jump) and adds dt * freq to a wrapped phase, so the period holds at any draw rate. Rate is Hz only (the Vsynth convention); note values and BPM were removed 2026-11-24.
Panel widgets
The widgets follow the library's own (build/build_patcher.py): menus are live.menu, the bipolar switch is a live.text two-state button (Uni / Bi), bypass is the bypass_toggle.js pill at the top right (18 x 12, red when bypassed). The number boxes are live.numbox (44 x 15 here, wider than the builder's 34 so values like 5000 fit; float for phase, pw, curve, rise, fall, bpm and jitter, integer for steps, cycles and seed). An enable message from outside does not move the pill. The pill is kept by an autopattr, not by a pattr chain; its setvalueof is silent, so after a preset recall the pill may show bypass while the engine runs (inferred, not looked at).
Display
The jsui draws one whole period of the output window (so cycles repeats show), shifted left or right by phase, and a marker at the current position in the period (the marker sits on the curve). The display holds no math: the engine sends range, curve (128 points), marker and active.
Settings and presets
Every setting has a plain pattr f_lfo_<name>, so the host pattrstorage (the Vsynth presets module) saves it with a preset and a recall moves the control. Values do not survive a plain save and reopen of an unembedded patch (the f_util_vary finding).
Notes and caveats
- Bipolar and texture consumers. With
bipolaron, the texture carries -1..1. A consumer that reads the texture as 0..1 will clip. Turn it on only for consumers that expect -1..1. - No S&H.
vs_lfo's S&H is gone (Matt, 2026-11-23); Wobble and Drunk are the random shapes, full floats. - Pulse edge.
vs_lfo's pulse has a smoothstep edge about 0.001 of a cycle wide; this one is a hard step. - Freq dial. The dial shows 0-10; with the range menu on 0-1 Hz the engine clamps to 1 Hz.
- For Wobble and Drunk the display draws the current glide across the whole width (not the period), and the marker is the position in the segment;
cyclesandphasedo not change that picture. trig_res(the family's global reset) is ignored; onlyrestartrestarts it.- Removed on request (Matt, 2026-11-23): rise / fall smoothing, jitter and seed. The Wobble and Drunk stream is seeded from the clock when the module loads, so each instance wanders differently and nothing repeats.
- Not built: multi-value outputs, one-shot or ADSR behavior, a texture inlet for FM or PM.
Status
- Offline, by Claude:
tests/modules/f_lfo/test_lfo_engine.py(the engine, with a fake clock),tests/build/test_drift.py. - Live, by Matt, 2026-11-23: the display fills its box (after a sizing fix).
- Live, by the bench (Claude, Matt's go, 2026-11-23,
tests/modules/f_lfo/bench_lfo_module.py3/3): the texture and float outlets agree and carry exact values including a negative; a held module holds; no Max errors. - Not yet looked at: the outlets against
vs_lfo, preset recall, two copies in one patch, restart, rounding the steps, the pill's click, the ms cost.
References
Designed in development; no outside code. Sine, Triangle and Pulse start from the shapes read from Vsynth's own vs_lfo gens (a behavioral reference, not copied). Steps, shape, ripple, cycles, Wobble and Drunk are original, from Matt's descriptions.