Luca Caprio

Lab / Lab 05

Terminal visualiser

When agents run long jobs, I spend a lot of time looking at a terminal. I wanted the pane beside them to move with the music I work to, in a way that actually reflects the track rather than just decorating it. The loop above is two bars of a 174 BPM break, rendered by the visualiser itself.

An animated terminal window full of ASCII characters forming rippling circular interference patterns in purple and cyan, pulsing with a drum and bass break.

How it works

The visualiser listens to the computer's audio, splits it into seven frequency bands, and turns each band into a wave that ripples out from its own point on the screen.

Frequency bands
7
Samples per reading
2,048
Characters in the scale
13

The audio is routed through a virtual loopback device, so it hears whatever is playing. Every 2,048 samples it measures how much energy is in each band. The bands are not evenly spaced. They are set where drum & bass actually sits: sub (20–60 Hz) is the bassline's low end, bass is the body of the kick, mid is the crack of the snare, and high and air are the hats and cymbals.

Each band drives a circular wave from a fixed position. The sub comes from the centre and moves slowly, so a long bassline shows up as a slow swell from the middle. The kick comes from the top corners, the snare from the bottom corners and the hats from the top and bottom edges, moving fastest. Where the waves overlap they interfere, and the combined value in each character cell picks a character from a scale that runs from a blank space to a solid @.

How the visualiser worksSystem audio is routed through a virtual loopback device into a fast Fourier transform, split into seven bands tuned for drum and bass. Each band drives a circular wave from its own point on the screen, sub from the centre and the highs from the edges. The waves are summed: the total picks a character from a density ramp, and whether bass or drums dominate picks purple or cyan.loopbackSystem audiowhatever is playingwhile I worknumpyFFT2,048 samplesHann windowsub20–60 Hzbass60–250low mid250–500mid500–2khigh mid2–4khigh4–8kair8–20k7 sourcesWave field7 circular wavessummed per cellinterferenceper cellCharacter" .·:;!|+=*#%@"by total energyColourpurple: basscyan: drums

Reading a break

These six frames come from two bars. Purple means the bass is louder in that spot, cyan means the drums are, and the blended colour means they're roughly equal.

For this page the unchanged visualiser was fed a generated break (kick, snare, hats and a sub at 174 BPM) instead of the computer's audio, so nothing playing on the machine was captured.

A terminal full of ASCII interference rings, mostly purple, radiating from the centre: the sub and kick on the first beat.
First beat: kick and sub
Denser, brighter rings with cyan threads through the purple: the snare adding mid and high energy.
The snare
Fine, tight cyan-blue texture across the field from the hats, over a fading purple swell.
Hats between hits
Large purple columns and rings from the corners: the syncopated kick.
The off-beat kick
A busy field of mixed purple and cyan rings as the second snare lands.
The second snare
A calmer field dominated by broad purple bands from the centre: only the sub holding between hits.
The sub on its own

Design decisions

  • Bass and drums kept apart

    The bass bands and drum bands are added up separately, and the colour of each cell comes from whichever is stronger there. That's what lets you see a rolling bassline carry on underneath a busy break.

  • Position shows frequency

    Where something happens on screen tells you which band caused it. Once you know the layout, you read the corners as much as the colours.

  • Speed follows pitch

    Low bands move slowly and high bands move quickly. It matches how the sounds feel, so the motion reads as the music rather than as noise.

  • Characters, not pixels

    Because it's text, it runs in any terminal and font and resizes as the window does. It sits in a pane beside the agents instead of taking over the screen.

  • Shape over volume

    Each frame is scaled to its own range, so a quiet intro still moves. The downside is that a breakdown and a drop look equally busy, which I'd like to change.

  • No set-up each time

    It finds the loopback device on its own. Something I glance at while working can't ask me to configure it every time I open it.

What I learnt

  1. The maths is the easy part, and the mapping is the design. A frequency analysis takes a few lines of code. Deciding that the sub comes from the centre, the snare from the corners and the hats from the edges is what makes it readable.
  2. Scaling every frame hides the dynamics. Keeping a slow measure of overall loudness alongside the shape would let a drop feel like a drop. That's the next change.
  3. Beat detection is a different product. A second, louder version added kick and snare detection with flashes and effects. The launcher I use every day runs the calmer version, because something in the corner of your eye shouldn't flash at you.