2.1 System structure
The instrument is the Processing sketch Swarm_Synth_V/ (18 tabs). The flocking logic knows nothing about drawing or sound; sound and visuals only read the swarm's state. No external Processing library is needed: the sketch has its own synthesizer and reads MIDI through Java's own javax.sound.midi.
| File | Role |
|---|---|
Swarm_Synth_V.pde |
Main: modes (free play, score preview, render, atlas), the step loop, keys P / V / F / Shift+A / Shift+B |
Boid.pde, Flock.pde |
Pure flocking logic, 8 parameters, resolution scaling, torus distance |
SwarmMetrics.pde |
Whole-swarm measures, flock detection and flock identity over time |
SwarmEvents.pde |
Encounters between individual boids; flocks crossing the beat grid |
SoundEngine.pde |
Decides what to play in Classic: flock voices (macro), encounter notes (micro), pings, beat hits, relations between flocks |
Club.pde |
Pulse and Blue modes: one clock, what plays on it, and their own voices (1.3) |
Synth.pde |
Makes the samples: 4 drone slots × 4 partials, one-shot notes, sine hits for the beat, Pulse mode's voices, limiter |
AudioOut.pde |
Speakers in real time; WAV writer for renders |
Score.pde |
Reads and plays a score (any .txt in data/) |
ScoreRecorder.pde |
Writes free play down as a simplified score (Shift+R) |
VideoRecorder.pde |
Offline render to mp4 via ffmpeg |
Atlas.pde |
Sound atlas: measures pattern, sound and feeling over 64 settings |
VisualEngine.pde |
Draws into the stage image (boids, sliders, overlay, HUD) |
BeatAtlas.pde |
Beat atlas: measures the beat over speed, max force and grid |
ClubAtlas.pde |
The atlases' flights heard again in Pulse mode |
InputManager.pde |
Keyboard and mouse control |
Midi.pde |
MIDI controllers: a mapping file per device, button lights, the controller map on screen |
Every simulation step lasts exactly 1/60 s and produces exactly one audio block of 800 samples (48 kHz) and one picture:

In the code:
score.apply(t) // score cues move the parameters
flock.update() // the swarm moves
metrics.compute() // whole swarm + flocks + identity
events.compute() // encounters
events.computeBeats() // flocks crossing the beat grid
sound.update() // flock voices, notes, pings, beat hits -> synth
club.update() // Pulse and Blue modes: what plays on the clock
synth.renderBlock() // 800 samples
In real time the sound card paces this loop (the sketch waits until the audio buffer needs the next block). In a render, nothing is real time: steps run as fast as the computer can, and the result is identical every time.