home/ modules/ building-audio-reactive-visuals-in-hydra

Building Audio-Reactive Visuals in Hydra

  • learner can route audio into Hydra and read per-bin FFT amplitudes
  • learner can shape reactivity with scale, cutoff and smoothing to avoid strobe and dead zones
  • learner can replace any numeric Hydra parameter with an audio/MIDI-driven function and trigger events on the beat

In Hydra, build a live-coded visual whose motion, colour and one discrete flash are all driven by microphone/loopback audio — using FFT bins with tuned scale/cutoff/smoothing for continuous motion and an onBeat callback for the flash — and perform a 60-second reactive sketch.

This module builds toward the bread-and-butter task of the AV live-coder: a Hydra sketch that visibly listens. In a club or algorave set, visuals that pulse with the kick and shift colour with the mix read as intentional; visuals on a fixed clock read as a screensaver. The rig here is a laptop running Hydra in the browser, fed either by the room microphone or — more commonly — a loopback device carrying your DAW or TidalCycles output, which is why knowing that Hydra only hears the default microphone (and how to route around that) gates everything else.

The arc starts supported: get signal in, call up the FFT bin array, and wire a single bin to one oscillator parameter using the “any number can be a function” idiom. The first result will almost certainly strobe or sit dead — which motivates the calibration pass: set the cutoff floor and scale ceiling for your room, then dial in smoothing until motion is fluid rather than flickery. From there the learner layers a second, independent mapping (bass bin to motion, high bin to colour), and finally adds the discrete layer: an onBeat callback that fires a flash when volume crosses threshold.

Every required atom is load-bearing for the capstone — routing, bins, calibration, smoothing and beat callbacks are each named or exercised directly in the 60-second performance. The supporting atoms enrich: raw and previous-frame bins (a.bins/a.prevBins) show how delta-based onset detection works beyond the calibrated 0–1 signal, and the generic amplitude-threshold beat-detection atom explains why Hydra’s volume-based trigger misfires on sustained sounds and how hysteresis or band-limited detection would harden it — useful context but not needed to perform the sketch.

Runnable examples

Generated from the context/ instrument corpus by concept (redistributable idioms only). Do not edit — regenerate with gen-module-examples.mjs.

audio-reactive-map

updateAudio(); scale(1 + amp * 0.01)

p5live-0044 · CC0-1.0

voronoi(() => 4 + a.fft[0] * 10).out()

hydra-0035 · CC0-1.0

modulation-warp

osc(4).modulate(src(o0), 0.6).out(o0)

hydra-0022 · CC0-1.0

s0.initP5(); src(s0).modulate(noize(), 0.3).out()

p5live-0038 · CC0-1.0

feedback-trail

osc(4).modulate(src(o0), 0.6).out(o0)

hydra-0022 · CC0-1.0

function draw(){ fill(0, 20); rect(0, 0, width, height); circle(mouseX, mouseY, 40) }

p5live-0003 · CC0-1.0

scale-pulse

uv *= 1.0 + 0.3 * sin(u_time * 2.0);

glsl-0030 · public-domain

updateAudio(); scale(1 + amp * 0.01)

p5live-0044 · CC0-1.0

grain-glitch

col += (h21(st + fract(u_time)) - 0.5) * 0.15;

glsl-0026 · public-domain

flow-field

let ang = noise(x*0.01, y*0.01) * TWO_PI

p5live-0008 · CC0-1.0

chromatic-aberration

col = vec3(texture2D(u_tex0,st+vec2(.005,0)).r, texture2D(u_tex0,st).g, texture2D(u_tex0,st-vec2(.005,0)).b);

glsl-0036 · public-domain

Atoms in this module

Required — these gate the capstone

Hydra's a.fft array holds per-bin amplitude values produced by FFT analysis of the microphone input
Concept L2 First instrument JH
Hydra reads only the browser's default microphone input, not desktop audio; DAW output requires virtual audio routing
Fact L2 First instrument JH
a.setScale() and a.setCutoff() map FFT bin values to 0–1 via a noise gate and a ceiling threshold
Concept L2 First instrument JH
a.setSmooth() prevents strobe artifacts by exponentially averaging consecutive FFT frames in Hydra
Concept L2 First instrument JH
Hydra's a.onBeat() callback fires whenever a.vol crosses a configurable threshold
Concept L2 First instrument JH
Any numeric parameter in Hydra can be replaced with a function, enabling audio or MIDI to modulate visual parameters
Concept L3 Craft JH

Supporting — enrichment, not gating

a.bins gives Hydra's un-normalised FFT values and a.prevBins gives the previous frame's, enabling delta-based reactivity
Concept L2 First instrument JH
Beat detection via amplitude threshold fires a visual event when RMS crosses a set level
Procedure L2 First instrument JH
Tempo-locked visual changes are not achievable in this rig because the bridge exposes only FFT energy with no beat-phase or onset
Fact L2 First instrument JH
Mapping the highs band to glitch intensity makes corruption spike with hats and transients — the closest proxy to onset-triggered glitching
Principle L2 First instrument JH
Mapping bass to feedback-trail zoom or symmetry scale makes the tunnel pulse with the low end
Principle L2 First instrument JH
Map the low-mid band to organic warp/flow depth so the field swells and eddies with the music's body
Principle L2 First instrument JH