DEV Community

Cover image for Field: write a short kernel and let the node decide where it runs
naman
naman

Posted on Originally published at infinitedevices.org

Field: write a short kernel and let the node decide where it runs

Most nodes do one fixed thing. A Blur node blurs and a Delay node delays. Creative work often needs something in between, so Infinite includes Field, a kernel language for shaders, geometry and audio: a small language for writing what a node does.

One idea: a kernel run once per element

A Field node runs your kernel once for every element of its domain, forever. The domain is chosen by the node, not by you:

col = vec3(uv.x, uv.y, 0.5)              // once per pixel, on the GPU: a shader
P.y += sin(P.x * 4.0 + t) * 0.2          // once per point in a mesh: a geometry deformer
out = in * gain                          // once per audio sample: a DSP effect
Enter fullscreen mode Exit fullscreen mode

You never declare a backend. The same way of thinking covers pictures, shapes and sound.

The Field nodes

Node Domain What it does
Field Pixel pixel Per-pixel kernel compiled to GLSL, with state cells for feedback
Field Modifier element Per-vertex kernel over existing geometry
Field Primitive element Generates point geometry such as spirals, lattices and torus knots
Field Effect sample Per-sample audio effect with in, out, state and param
Field Synth sample A polyphonic synth voice driven by freq and gate
Field Notes sample Sends notes with note(pitch, vel, len) and reads the transport
Field Graph graph Runs at edit time and builds real nodes and cables

Knobs that become pins

A kernel can declare parameters in its own code, and each one becomes a real input on the node:

param float cutoff = 0.25 [0.01, 0.99]
state float z = 0
z += (in - z) * cutoff
out = z
Enter fullscreen mode Exit fullscreen mode

That is a one-pole low-pass filter. The cutoff pin can be wired to an LFO, a MIDI knob or the output of an Audio Analyze node like any other control, and it survives save and load.

Why a language, not another plugin format

A kernel is short enough to read in one go and to share as a text file. The Library has a growing set of free Field devices to start from, and the language reference is available as a PDF manual.

To see where a kernel's numbers can come from, read how sound and pictures share one graph. Infinite is free and open source for macOS, Windows and Linux.


Originally published at https://infinitedevices.org/blog/field-language-write-what-a-node-does.html. Infinite is a free, open-source DAW for visuals, music and code: infinitedevices.org.

Top comments (0)