hydra_block
Write a named Hydra code block and run it while other blocks keep playing. Dry-run validation prevents broken shaders from touching the live canvas.
Instructions
Write one named block of Hydra code and run it, leaving every other block playing.
name: letters, digits, _ and -, starting with a letter (e.g. "base", "feedback").
Writing an existing name replaces that block — a hard cut; hydra_crossfade fades.
code is ordinary Hydra JavaScript.
DRY RUN FIRST. With validate=true (the default) the code runs in a hidden second
Hydra instance before it touches the live canvas. A misspelled function comes back as
a ReferenceError; a broken shader comes back as the GPU's own compile log. Both are
refused with live_untouched: true. Fix and call again — don't disable validation to
get past an error. validate=false exists for code that loads extensions.
Human-written blocks are refused (error human_block) unless take=true, which you pass
only when the person playing asked you to take that block over.
Things that trip people up:
Each output shows one chain:
.out()means.out(o0). Four outputs, o0–o3;render(o1)shows one,render()shows all four.Plain numbers are baked into the shader. For motion, pass a function —
() => Math.sin(time)— or an array:[1, 2, 4].fast(0.5).Feedback is reading an output back into itself:
src(o0).sum()does not compile in hydra-synth 1.4.0. Useadd.
Examples: osc(20, 0.1, 0.8).kaleid(4).out() noise(3).modulate(osc(10), 0.2).color(0.9, 0.3, 1).out(o1) src(o0).scale(1.01).rotate(0.01).blend(osc(8), 0.1).out(o0) shape(4, () => 0.3 + a.fft[0] * 0.4).out(o2)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| name | Yes | ||
| take | No | ||
| validate | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |