Piano of Life

A top-down piano video seeds a shaded Game of Life. The GoL's column density becomes a live spectral filter on the piano's own audio. how it works ↓

github ↗ · MIT · No dependencies — vanilla JS, Canvas 2D, Web Audio.

Drop a piano video here

Top-down camera on the piano action (hammers visible below keys) works best. MP4/WebM/MOV. Any length. Local file — nothing uploaded.

or

Or (Joseph's upright, 20 s, ~5 MB).

How it works

The pipeline is four stages, each one line of thinking:

  1. Detection. Pick a thin horizontal band across the video where a resting hammer's felt tip sits. Split the band into N uniform columns. Each frame, compute per-column mean luminance. Frame-over-frame signed change tells you which columns just darkened (felt moved up out of the band → strike) and which just brightened (felt returned → return). Threshold + a per-column cooldown gives you clean discrete hits.
  2. Piano roll. Each hit spawns a bar at that column and falls into the Game of Life zone below.
  3. Shaded Game of Life. When a bar arrives at the GoL zone, it seeds a small cluster there. Standard Conway rules on the grid. Every cell also carries an alpha value: newly-alive cells snap to full alpha, cells alive for a while hold near 1, dying cells fade by ×0.55 per tick. This gives the grid a warm, continuous texture rather than binary on/off.
  4. PMF → spectral filter. Sum shaded-alpha per column, then bin into 32 log-spaced bandpass filters between A2 (110 Hz) and C7 (2093 Hz). Each band's gain smoothly tracks its PMF value. The piano video's own audio track is routed through the bank via MediaElementAudioSource. When the Game of Life develops structure in a particular column region, the corresponding frequency band opens up on the audio — you hear those partials of the piano bloom.

The loop closes: piano strike → detection → substrate → filter over that same strike's decay → back to your ears. Stable GoL attractors give the piano a fixed color; chaotic GoL states morph its timbre in flight.

Try it with your own video

Drop a top-down piano video at the top. If the detection is off, adjust:

For non-piano sources — anything with a well-defined bright-vs-dark interface that moves — this same detector will probably work: keys typed on a keyboard, hands over a xylophone, drumsticks on a snare, feet on a treadmill. The Game of Life and the filter bank don't care about the source.