home/ atoms/ hydra-audio-reactivity-fft

Hydra's `a` object exposes real-time FFT bins so any parameter can be driven by an audio frequency band

Hydra performs real-time FFT (Fourier transform) analysis of the incoming audio through the global audio object a (powered by the Meyda library). a.fft[i] (also a.bins[i]) returns a normalized 0-1 value for frequency bin i, where low indices are low frequencies — a.fft[0] is the bass band. Because any Hydra parameter can accept a function returning a number, an FFT bin wires directly to a parameter: passing () => a.fft[0] * scale makes that parameter track bass energy. Supporting controls: a.setBins(n) sets the number of frequency bands; a.show() displays the spectrum on screen for monitoring; a.setCutoff() and a.setScale() calibrate the range; and a.setSmooth(x) applies temporal smoothing (a lowpass on the values, 0 = no smoothing/most responsive, near 1 = heavily smoothed/frozen). Multiplying a bin value scales sensitivity; smoothing trades responsiveness for stability — it tames jittery, twitchy reactions at the cost of added latency on transients.

Examples

a.show()
a.setBins(6)
osc(10, 0, () => a.fft[0]*4).out()   // color offset tracks bass
shape(4, () => a.fft[0]).out()        // square pulses with bass
osc(16, .15, .5).rotate(Math.PI/3)
  .pixelate(() => a.fft[0] * 10, 20).out()
a.setSmooth(.95); a.setBins(2)        // pixelation reacts to bass, smoothed to avoid jitter

Assessment

Configure the FFT bins, verify with a.show(), then map bin 0 to an oscillator’s frequency and another bin to rotation speed. Given a sketch jittering wildly to audio, name the a method (and a value) that reduces jitter, and explain what smoothing does and how to make the response less twitchy without killing reactivity.

“FFT functionality is available via an audio object accessed via "a". The editor uses https://github.com/meyda/meyda for audio analysis.”
corpus · hydra-livecoding-networked-visuals-source-repo · chunk 3
“here I have these the Fourier transform of the which is kind of giving showing levels of loving the sound at different frequencies and so the left side is low frequency”
corpus · live-coding-visuals-with-hydra-olivia-jack-no-bounds-eulerro · chunk 4
“We can access the “bins” of our FFT analysis via array access, e.g. `a.bins[0]`. The number of bins in the analysis can be set using a call to `a.setBins()`.”
corpus · workshop-notes-audiovisual-programming-wac-2019-charlie-robe · chunk 2