The sound

How a swarm becomes music

In Confluon, there is no backing track and no animation reacting to a separate song. The Rust engine produces one evolving state. WebGPU reads it as light; WebAudio reads it as harmony, texture, position, and event. What you see and what you hear are two interpretations of the same field.

One state, two senses

A tempting sonification strategy is to give every particle an oscillator. It is direct, but with two thousand particles it becomes more diagram than composition: thousands of tiny voices obscure the larger changes that make the field interesting.

Confluon instead reduces the swarm into a compact musical state. Seven collective metrics describe its energy, coherence, activity, density, formation count, transitions, and cross-population encounters. Up to eight formation summaries add position, size, and species. The same values reach the renderer and the sound engine on every display frame.

Rust swarm particles · metrics · formations One state one frame WebGPU field becomes light WebAudio field becomes music
There is no audio-reactive visual layer. Both outputs consume the same simulation snapshot.

The sustained harmonic field

The continuous bed begins with six oscillators at the frequency ratios 1, 1.25, 1.5, 2, 2.5, and 3. They form a bright overtone lattice: root, major third, fifth, octave, upper third, and upper fifth. Lower voices are stronger; upper voices contribute colour. Tiny independent detune oscillators stop the chord freezing into a static organ tone.

fi = froot × [1, 5/4, 3/2, 2, 5/2, 3] Formation count chooses a root step; mean energy bends it slightly within that centre.

More coherent movement raises the sustained partials and the sub foundation. Density opens their low-pass filter. Activity spreads them wider in stereo while taking a little weight out of the bed. Encounter pressure increases detuning, so populations pressing into one another can be heard as a gentle widening of the tuning.

Every change is smoothed on the audio clock with AudioParam.setTargetAtTime. The frame rate can wobble without turning a control signal into zipper noise.

Formations have places and voices

The most literal bridge between picture and sound is the formation choir. The simulation reports up to eight large connected structures. The audio layer tracks them from frame to frame by species and toroidal distance, then gives each a paired oscillator voice.

Horizontal position
Becomes stereo pan, so the voice sits where its formation appears.
Vertical position
Colours the voice filter: formations higher in the field sound slightly more open.
Population
Selects a register offset, separating cyan, ember, and violet in pitch.
Size share
Controls level; larger formations occupy more of the choir.
Birth
A newly visible formation rings a soft, spatially placed emergence bell.
Dissolution
The tracked voice releases slowly instead of stopping at the detection boundary.

Sparse field tones also borrow the position of a currently visible formation. The ear is repeatedly drawn toward the same places the eye finds organised matter.

What each collective reading does

The mappings overlap deliberately. A metric does not own one obvious knob; it leaves a fingerprint across the whole sound.

Energy
Slightly bends the root, raises pad resonance, colours the noise, and tunes resonant strikes.
Coherence
Focuses the pad, strengthens the sub and formation choir, adds shimmer, shortens delay, and opens the reverb return.
Activity
Widens the field, brightens the master, raises noise and feedback, and reduces the space between tones.
Density
Adds sub weight, opens pad and noise filters, and gives the sparse-note walk more possible degrees.
Formations
Move the harmonic root through a six-step cycle and provide the spatial choir itself.
Transition
Crossing a change threshold excites one bounded resonant strike.
Encounter
Widens tuning, brightens the field, adds air and delay feedback, and shortens the note interval.
The compositional rule

A value should be audible without becoming a meter demonstration. The mappings are intentionally slow, overlapping, and bounded: collective change alters the character of the music rather than announcing a number.

Events give the field punctuation

Continuous mappings provide atmosphere; discrete events provide form. A rapid change in energy or activity raises the transition measure. When it crosses a threshold, the app excites a short filtered resonator whose brightness follows current energy.

The performer produces related events. A strong drag, a released settle, a new seed, or a rebuilt field can strike the same musical material. Pointer gestures carry their horizontal position into stereo. The sound therefore distinguishes “the system changed” from “the system changed here.”

Longer tones arrive on a seeded, metric-driven scheduler. Activity, density, and encounter pressure make the interval shorter, but it never becomes a metronomic grid. Each tone has a soft attack and a long release, leaving room for the field to be heard.

One slow breath across the mix

A 0.1 Hz oscillator—a ten-second cycle, or roughly six cycles a minute—moves three parts of the graph together: pad brightness, sub level, and master brightness. It is deliberately subtle. Rather than adding an audible low-frequency wobble, it makes the whole instrument inhale and exhale as one body.

This is a compositional pacing device, not a therapeutic claim. Its job is to prevent the continuous bed becoming mechanically fixed and to give very slow change a shared contour beneath the faster life of the swarm.

Space is synthesized too

There are no samples anywhere in the signal path. The air bed is four seconds of seeded, gently correlated noise. The hall impulse is generated in code from twelve early reflections and a diffuse noise tail whose low-pass closes as it decays.

The shared pad also feeds an octave waveshaper. The curve y = 2x² − 1 turns a sine into its octave; a band-pass extracts the upper glow and sends it only into the reverb. Coherence raises this shimmer, letting organised motion appear as light above the main sound without simply making everything louder.

Six-part pad partial lattice Formation choir up to eight voices Sub · air · tones events + texture Dry field shared bus Delay · reverb filtered wet returns Shimmer octave into hall Master HP · warmth · tone Dynamics · output compress · limit · meter
Synth sources share dry, delay, and procedural hall paths before a conservative mastered output.

Seeded sound, living timing

The simulation seed also seeds the musical random walk. Rebuilding the same field recreates note choices, detune offsets, and spatial decisions in the same order when the same inputs are replayed. The noise bed and hall use fixed seeds, so their texture is stable rather than changing with every page load.

WebAudio itself runs on its own high-resolution clock. Long tones are scheduled on that clock, not with frame timers, and continuously mapped parameters are smoothed toward new targets. This preserves musical continuity when rendering work is briefly expensive.

What reproduction requires

An untouched take needs the same engine revision, seed, fixed timestep, and settings. A performed take also needs the gesture stream and timing. A shared URL records the starting score; a finished render manifest records the production conditions.

Recording the same master you hear

The live Record control taps the graph after the safety limiter with an AudioWorklet. It collects stereo 32-bit floating-point blocks and writes a lossless WAV named with the seed and duration. The recorder is a silent tap: it does not sit in series with playback and cannot colour the live mix.

Video production uses another post-limiter tap as a MediaStreamAudioDestinationNode. That mastered stream and the WebGPU canvas stream enter one MediaRecorder, so picture and sound share the browser clock. The local production tool can then deliver H.264/AAC MP4, VP9/Opus WebM, landscape, square, portrait, story, or custom formats from the same seed.

What comes from data, and what comes from taste

The state-to-sound coupling is literal: formation position really is pan, size really is voice level, and encounter pressure really does enter the detune and spectral mappings. But a mapping is still a compositional decision. The simulation does not contain a natural major third, a seven-and-a-half-second hall, or a preferred amount of shimmer.

Those choices are taste, tuned by listening. The discipline is to keep that taste downstream of real state: the sound may interpret the field, but it should not invent a dramatic arc that the field did not produce.

Sources and further reading

  1. W3C Web Audio Working Group. Web Audio API 1.1. The audio-routing graph, synthesis nodes, parameter automation, convolution, and worklet model used by the instrument.
  2. Mordvintsev, A., Niklasson, E. & Randazzo, E. (2022). “Particle Lenia — Giving particles voice.” The reference experiment maps per-particle energy to frequency and speed to volume; Confluon instead maps collective state and formations.
  3. Confluon source documentation. Architecture and audio graph.