home/ atoms/ fft-bands-glsl-uniform

Audio FFT data can be passed to shaders as a 4-band uniform for audio-reactive visuals

In The Force (a browser GLSL live-coding environment), enabling the microphone exposes a 4-element uniform array bands[] where bands[0] is low-frequency energy and bands[3] is high-frequency energy. These values are computed via FFT analysis on the CPU from the microphone input and are transferred to the GPU as uniforms each frame. Shader parameters (gain, thickness, position offsets, etc.) can be driven by these band values to make visuals react to audio. This is the lowest-overhead path for audio-reactive GLSL: no additional library is needed beyond what The Force provides.

Examples

Replace a static gain value with bands[0] to make visual amplitude react to bass energy: inside a loop that accumulates sine waves, write gain = bands[0]; and the visual will pulse with the kick drum.

Assessment

Given a GLSL shader with a fixed float gain = 1.;, describe the two changes needed to make gain react to bass frequencies using The Force’s FFT uniform. Then explain what bands[3] would control and how it differs from bands[0].

“the FFT data will then be available in a four-item uniform named `bands`, where `bands[0]` is the low-frequency content and `bands[3]` is the high frequency content.”
corpus · workshop-notes-audiovisual-programming-wac-2019-charlie-robe · chunk 1