LFO_Square
The on/off switch for your float inputs
- FLOAT
Most LFOs ease you between values. LFO_Square doesn't. It bounces hard between two fixed levels, high and low, with nothing in between - the "digital" member of the Comfy-LFO family. If you want a value to alternate between "on" and "off", this is the node.
In practice that means things like ControlNet strength toggling between strong and nearly-nonexistent every N steps, or a denoise that alternates between two levels instead of sweeping. It's the least musical waveform in synthesis, and in ComfyUI that's a feature: sometimes you genuinely want a binary switch, not a ramp.
How it works
The pack's lfonodes.py implements it exactly like a synthesizer would - a comparator on the phase:
phase = (position * frequency) - int(position * frequency)
return offset + amplitude * (1 if phase < 0.5 else -1)
The phase is the fractional part of position * frequency, wrapping 1→0 each cycle. As long as the phase is in the first half of the cycle the output is offset + amplitude (high); in the second half it's offset - amplitude (low). Frequency 1, amplitude 1, offset 0 gives you a value snapping between +1 and -1 once per unit of position.
Note the fixed 50% duty cycle: it spends exactly half the cycle high and half low, no adjustment. If you want a switch that stays high for 30% and low for 70%, that's literally what the pack's other square-ish node, LFO_Pulse with its pulse_width input, exists for. Square is the "I just want a clean 50/50 toggle" version.
And the pack-wide rule applies here hardest: this node is a pure function of position, with no internal clock. The output switches only when position changes. Drive it from a frame counter or batch index if you want it to alternate across a run; leave position alone and it sits in one state forever.
The inputs
The standard five float inputs:
- position - the driver. Move this and the switch flips.
- frequency - how many full on/off cycles per unit of position. Default 1.
- amplitude - the distance of each level from center. Default 1.
- offset - the midpoint between the two levels. Default 0.
- phase_offset - where in the cycle you start, default 0.5, so you can begin on the high or low half.
Output is one FLOAT, which wires into any float input - KSampler denoise, ControlNet strength, IPAdapter weight, AnimateDiff motion scale, CFG. It's the deterministic cousin of the audio-weight tricks in audio-reactive AnimateDiff workflows, just controlled by numbers instead of a music file.
Install and troubleshooting
Identical to the rest of the pack: no dependencies, no model downloads, one tiny file. From your ComfyUI folder:
cd custom_nodes
git clone https://github.com/richinsley/Comfy-LFO.git
Restart ComfyUI and the LFO nodes appear under the LFO menu (ComfyUI Manager can install the pack by searching "Comfy-LFO").
Frozen output = position isn't advancing. Missing node = didn't restart. And if you find yourself wishing the square stayed high longer than it stays low, you're not broken - you just want LFO_Pulse, the adjustable-duty sibling. Square is the no-frills 50/50 switch, and for that narrow job it's exactly right.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| position | FLOAT | 0.000 | — |
| phase_offset | FLOAT | 0.500 | — |
| frequency | FLOAT | 1.000 | — |
| amplitude | FLOAT | 1.000 | — |
| offset | FLOAT | 0.000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | — |