Narlblog Nothing here, promised

Anchoring to the Groove: Phase vs. Delta-Time

May 20, 2026 · 2 min read
audio engineaudio analysis

Anchoring to the Groove: Phase vs. Delta-Time

A common mistake in procedural visualizers is relying entirely on Euler integration for continuous movement (like a rotating camera or a spinning object).

The "Drift" Problem

When you want an object to spin based on the music's energy, the naive approach is to map audio energy to angular velocity ω\omega:

θt=θt1+(ωbase+γEt)Δt\theta_t = \theta_{t-1} + (\omega_{base} + \gamma \cdot E_t) \cdot \Delta t

The problem: Because Δt\Delta t (frame time) and EtE_t (energy) are decoupled from the track's actual BPM, the rotation will eventually drift entirely out of phase with the track's groove. It becomes background noise.

The Solution: Predictive Phase-Locking

Modern audio engines calculate a predictive Inter-Onset Interval (IOI) and expose a beat_phase (ϕ\phi)—a normalized sawtooth wave that ramps from 0.00.0 to 1.01.0 exactly between predicted beats.

Instead of integrating velocity over time, we define positions as a function of this phase.

ϕt=tcurrenttlast_beatIOImod1\phi_t = \frac{t_{current} - t_{last\_beat}}{\text{IOI}} \mod 1

Now, we can lock visual events mathematically to the groove:

A. The Rhythmic Snap: Trigger a camera tilt only when the phase rolls over. If ϕt<ϵ,then TiltTilt+Δ\text{If } \phi_t < \epsilon, \text{then } \text{Tilt} \leftarrow \text{Tilt} + \Delta

B. The Anticipation Easing: Drive continuous parameters using shaped easing functions on ϕt\phi_t, so the visualizer "winds up" before the beat drops. Scalet=1.0+A(1.0ϕt)3\text{Scale}_t = 1.0 + A \cdot (1.0 - \phi_t)^3

By anchoring to ϕt\phi_t instead of Δt\Delta t, the visuals are mathematically guaranteed to lock to the grid of the music, perfectly syncing with syncopations and swing.