home/ atoms/ hydra-parameters-are-functions

Any Hydra number parameter can be a function evaluated each frame, enabling gestural and data-driven control

Anywhere Hydra expects a number, you can instead pass a function that returns a number, re-evaluated every frame, so a parameter becomes time-varying. Built-in sources for such functions include the mouse (mouse.x, mouse.y, normalised 0 to 1). This gives real-time gestural control without external hardware: mouse movement can drive a shape’s size, an oscillator’s frequency, a rotation angle. The same mechanism unifies audio reactivity (an FFT bin) and any other time-varying source, the common idea being that parameters are functions, not fixed literals.

Examples

shape(4, () => mouse.x).out() makes a square whose size follows horizontal mouse position; osc(() => mouse.y * 20).out() maps vertical mouse position to oscillator frequency.

Assessment

Write a Hydra patch where a source’s size is controlled by horizontal mouse position, and explain, via the ‘parameters are functions’ principle, why the same trick also enables audio-reactive control.

“I'm going to say the x position in a horizontal position of the mouse is gonna affect the size of it so now instead of it being one number it's a different number depending on at a given moment w”
corpus · live-coding-visuals-with-hydra-olivia-jack-no-bounds-eulerro · chunk 3