home/ atoms/ fft-index-out-of-bounds

Reading a.fft[4] or higher returns undefined, causing NaN arithmetic and a frozen or black Hydra frame

Only indices 0..3 exist in a.fft. Reading a.fft[4] or any higher index returns undefined in JavaScript. Any arithmetic on undefined produces NaN, which Hydra propagates silently — the parameter becomes NaN and the frame either freezes or goes black. This is a top gotcha for L5 Hydra debugging: a sketch that was working stops rendering after a seemingly innocent change that added a fifth band reference. The fix is to always use only indices 0..3 and to check that a.setBins(n) has been called before accessing index n-1.

Examples

osc(10,0.1,()=>a.fft[4]*2).out()a.fft[4] is undefined, result is NaN, oscillator freezes. Replace with a.fft[3].

Assessment

A Hydra sketch renders correctly at first but produces a black frame after a.setBins(3) is called without changing the sketch. Diagnose the likely cause and fix it.

“Only indices **0..3** exist. Reading `a.fft[4]` (or higher) returns `undefined` → arithmetic yields `NaN` → frozen/black frame. This is a top L5-Hydra gotchas item.”
context/ · L2b-av-link/feature-contract.md · chunk 1