Narlblog Nothing here, promised

The Physics of the Punch: Impulses vs. Envelopes

May 20, 2026 · 2 min read
audio engineaudio analysis

The Physics of the Punch: Impulses vs. Envelopes

If your audio visualizer feels like it's "breathing" underwater rather than dancing to the music, you are likely driving your math with envelopes instead of impulses.

The Mathematical Trap of the EMA

Most standard audio analysis outputs a smoothed envelope using an Exponential Moving Average (EMA) to prevent visual flickering. The math looks like this:

Et=Et1+α(MtEt1)E_t = E_{t-1} + \alpha(M_t - E_{t-1})

Where:

  • EtE_t is the envelope at time tt
  • MtM_t is the raw magnitude of the frequency band
  • α\alpha is the smoothing coefficient (attack/release)

The problem: By the time EtE_t reaches its peak, the actual drum hit in the audio has already passed. If you map EtE_t directly to the scale of an object, the object will swell and deflate sluggishly.

The Solution: Spring-Damper with Transient Injection

To make geometry feel kinetic, we separate the resting state from the kinetic energy. We use the envelope (EtE_t) to define the resting state, but we inject raw, unsmoothed transients (OtO_t, or spectral flux) directly into the velocity of a simulated spring.

A standard damped spring-mass system is defined as:

at=k(Txt)dvt1a_t = k(T - x_t) - d \cdot v_{t-1} vt=vt1+atΔtv_t = v_{t-1} + a_t \cdot \Delta t xt=xt+vtΔtx_t = x_t + v_t \cdot \Delta t

The Reactive Hack: Instead of just setting the target T=EtT = E_t, we forcefully inject energy into the velocity vv whenever a transient crosses a threshold.

If Ot>threshold,then vt=vt+(βOt)\text{If } O_t > \text{threshold}, \text{then } v_t = v_t + (\beta \cdot O_t)

This causes the geometry to snap outward instantly on a snare or kick, and then gracefully ring out using the spring physics, settling back to the slow-moving baseline of the EMA.