Array modifiers
unreviewed draftfast, smooth, ease, offset and fit — methods that control how an array argument steps through its values over time.
[ … ].fast( speed = 1 )Array modifier[ … ].smooth( smooth = 1 )Array modifier[ … ].ease( ease = 'linear' )Array modifier[ … ].offset( offset = 0.5 )Array modifier[ … ].fit( low = 0, high = 1 )Array modifier
What it does
Section titled “What it does”Any numeric argument can be an array; hydra then plays its values in sequence. The modifiers are methods hydra adds to every JavaScript array. Each frame, the position in the array is
and without smoothing the value is arr[floor(i % length)]. With bpm = 30 (the default) and fast(1),
each value lasts 2 seconds.
With smooth(s), the glide from one value to the next starts steps before the boundary and ends
after it; ease reshapes that glide.
fast source in array-utils.js (hydra-synth 1.4.0) ↗
Examples
Section titled “Examples”shape(4, [0.2, 0.4, 0.3]).out()osc(20, 0.1, [0, 1.5, 3].fast(2).smooth(1)).out()shape(3).rotate([0, 1.5708, 3.1416, 4.7124].ease('easeInOutCubic')).out()osc([1, 2, 3, 4].fit(10, 60)).out()Half-step smoothing holds, then glides across each boundary:
Parameters
Section titled “Parameters”Sets how quickly the array advances through its values.
| Parameter | Default | Useful range | Units | No-op at |
|---|---|---|---|---|
speed | 1 | 0.1 … 8 | steps per beat (steps/second = speed × bpm / 60) | 1 |
speed= 1
Steps per beat. At the default bpm of 30, fast(1) holds each value for 2 seconds.
- Useful range
- 0.1 … 8
- Units
- steps per beat (steps/second = speed × bpm / 60)
- No-op at
1- Negative values
- without
smooth, the value becomesundefined(renders as 0); withsmooth, steps backwards - Accepts
- number · array · function
fast(0) does not freeze the array: 0 is falsy and is treated as 1. To hold a value, pass a plain number.
speed: [0, 1, 0.5, 0.25].fast({speed})smooth
Section titled “smooth”Interpolates between neighbouring values instead of jumping.
| Parameter | Default | Useful range | Units | No-op at |
|---|---|---|---|---|
smooth | 1 | 0 … 1 | fraction of a step | 0 (hard steps) |
smooth= 1
Fraction of each step spent gliding to the next value; the glide is centered on the step boundary.
- Useful range
- 0 … 1
- Units
- fraction of a step
- No-op at
0(hard steps)- Accepts
- number · array · function
smooth(1) glides the whole time (a continuous ramp); smooth(0.5) holds for half a step and
glides for half. Values above 1 never finish a glide, so the value jumps at every step boundary.
smooth: [0, 1, 0.5, 0.25].smooth({smooth})Chooses the shape of the glide between values, and turns smoothing on.
| Parameter | Default | Useful range | Units | No-op at |
|---|---|---|---|---|
ease | 'linear' | — | — | none: calling ease always turns smoothing on ('linear' is the same as smooth(1)) |
ease= 'linear'
Name of an easing curve, or your own function mapping to .
- Useful range
- —
- No-op at
- none: calling
easealways turns smoothing on ('linear'is the same assmooth(1)) - Values
'linear''easeInQuad''easeOutQuad''easeInOutQuad''easeInCubic''easeOutCubic''easeInOutCubic''easeInQuart''easeOutQuart''easeInOutQuart''easeInQuint''easeOutQuint''easeInOutQuint''sin'- Accepts
- string · function
Calling ease sets smooth to 1. Call .smooth(s) after .ease() for a partial glide.
An unknown name is silently ignored (no smoothing, no warning).
ease: [0, 1, 0.5, 0.25].ease({ease})offset
Section titled “offset”Shifts where in the array playback starts, by a fraction of one step.
| Parameter | Default | Useful range | Units | No-op at |
|---|---|---|---|---|
offset | 0.5 | 0 … 1 | steps (0.5 = half a step = 1 s at fast(1), bpm 30) | 0 (or any whole number) |
offset= 0.5
Phase shift in steps; only the fractional part is kept.
- Useful range
- 0 … 1
- Units
- steps (0.5 = half a step = 1 s at fast(1), bpm 30)
- No-op at
0(or any whole number)- Negative values
- kept negative (
-0.25stays-0.25); withoutsmooththis givesundefined(renders 0) at the start - Periodic
- every 1 — stored as
offset % 1, sooffset(2)is0andoffset(1.5)is0.5 - Accepts
- number · array · function
offset: [0, 1, 0.5, 0.25].offset({offset})Returns a new array linearly rescaled so its minimum is low and maximum is high.
| Parameter | Default | Useful range | Units | No-op at |
|---|---|---|---|---|
low | 0 | -2 … 2 | — | the array's current minimum (with high = its maximum) |
high | 1 | -2 … 2 | — | the array's current maximum |
low= 0
Value the array's smallest element maps to.
- Useful range
- -2 … 2
- No-op at
- the array's current minimum (with
high= its maximum) - Accepts
- number · array · function
low: [0, 1, 0.5, 0.25].fit({low}, 1)high= 1
Value the array's largest element maps to.
- Useful range
- -2 … 2
- No-op at
- the array's current maximum
- Accepts
- number · array · function
low > high flips the array. If every element is equal, all results are NaN (renders 0).
high: [0, 1, 0.5, 0.25].fit(0, {high})Gotchas
Section titled “Gotchas”offsetkeeps only the fractional part, so it can shift by less than one step but never skip whole values; rotate the array literal instead.- An unknown
easename is ignored silently (probe:_smoothand_easestay undefined). fiton an array whose values are all equal divides by zero: every element isNaN, rendered as 0.- Arrays are sampled with the global clock: changing
speedorbpmchanges every array’s pace.
Related
Section titled “Related”- Arguments & time:
time,bpm, and functions as arguments. - rotate, color: common targets for sequenced values.
Documents hydra-synth 1.4.0 (AGPL-3.0; this site runs it unmodified). Annotations drafted by Claude (Anthropic) from the hydra-synth source and checked against rendered output — see about. Site code AGPL-3.0, prose CC BY 4.0,source.