Sequencing & interactivity

Sequencing and Interactivity #

If you’re coding in Hydra, you’re constantly trying many values to input to the sources and transforms, and it’s just a matter of time until you like how more than one looks, and you want to somehow switch between them. We’ll be referring to this idea of arguments whose value change over time as dynamic arguments. And there are two main ways to achieve this in Hydra: Arrays and functions.

Sequencing using Arrays #

Sequence your inputs #

When you send an Array as an input (indicated in javascript by []), Hydra will automatically switch and jump from each element from the Array to the next one. When there are no more elements, it wraps all the way back to the beginning. Let’s see it in action:

changing the speed #

The arrays in hydra have a default bpm(beats-per-minute) of 30. You can change the speed of a specific array by adding .fast() at the end of the array. For example .fast(4) will make the above array run four times faster.

The speed of all arrays in a sketch can be changed using the bpm parameter of hydra synth.

bpm = 60

smooth() interpolation #

You can also interpolate between values instead of jumping from one to the other. That is, smoothly transition between values. For this you can use the .smooth method. It may take a Number argument (defaulted to 1) which controls the smoothness.

Custom Functions #

Each numerical parameter in hydra can be defined as a function rather than a static variable. For example,

osc(function(){return 100 * Math.sin(time * 0.1)}).out()

modifies the oscillator frequency as a function of time. (Time is a global variable that represents the milliseconds that have passed since loading the page).

The above example can be written more concisely using es6 syntax:

osc(() => 100 * Math.sin(time * 0.1)).out()

Custom functions are especially useful for controlling hydra parameters using external inputs, such as the microphone, mouse, or midi control.


by geikha