home/ atoms/ hydra-fft-bins

Hydra's a.fft array holds per-bin amplitude values produced by FFT analysis of the microphone input

Hydra wraps the Meyda audio-analysis library in a pre-defined object a. The Fast Fourier Transform (FFT) decomposes the incoming audio signal into frequency bands. a.setBins(n) sets how many bands to analyse; a.fft is a JavaScript array of n values each mapped to the range 0–1, where 0 is silence and 1 is at or above the configured scale ceiling. Index 0 is the lowest frequency band, index n-1 the highest. A practical consequence: a bass drum will raise a.fft[0] while a hi-hat raises a.fft[n-1]. Each bin value drives any Hydra parameter via an arrow function: () => a.fft[i]. Using too many bins (large n) increases CPU load.

Examples

a.setBins(5)
osc(20,.1,2)
  .saturate(()=>1-a.fft[4])
  .rotate(()=>a.fft[0])
  .kaleid()
  .out()

Deep ‘O’ sound → bass bin (index 0) rises → strong rotation. High ‘S’ sound → high bin (index 4) rises → saturation drops.

Assessment

Set a.setBins(4). Speak a deep vowel and a sibilant consonant into the mic. Predict which a.fft index will be highest in each case. Then map a.fft[0] to an oscillator frequency and verify the bass response by ear.

“We can decide into how many parts we want to separate the audio spectrum using the function `a.setBins()`. As you might've already guessed, a bin is just a part of the audio spectrum.”
corpus · hydra-audio-reactivity-guide-a-fft-a-setbins-a-show · chunk 1