>_ sekerace
sekerace --log · bach-soundtrack

Race soundtrack: Bach in equal temperament

November 2, 2026

Background audio plays on race start when terrain=circuit and car=openwheel. Track: J.S. Bach, Well-Tempered Clavier Book 1 — Prelude & Fugue No. 2 in C minor, BWV 847. The prelude is a perpetual-motion figure, which suits a loop; the pair runs ~3:43 and the playlist is the race clock — laps keep counting until the music ends, then the flag falls. R restarts both.

Signal chain

audio element → GainNode (0.25) → AnalyserNode (fftSize 8192) → destination

Routing the element through WebAudio bypasses its volume/muted state, so the GainNode is the only output path — 0.25 is a hard cap, not a default. M toggles the gain between 0 and 0.25. Playback begins inside the click-to-start gesture, which is what autoplay policy requires.

Visualizer

Each frame the FFT spectrum is bucketed into pitch classes:

pc = (round(12 · log2(f / 440)) + 9) mod 12   // C = 0

i.e. the equal-temperament relation f = 440 · 2^(n/12) inverted. Bins are limited to the piano range (27–4300 Hz). The result drives a one-octave key strip in the HUD panel opposite the minimap; energy per pitch class sets the fill alpha.

Euler's consonance math

n = Π pᵢ^eᵢ  ⇒  s(n) = 1 + Σ (pᵢ − 1)·eᵢ

Unison scores 1, octave 2, fifth 4 — smaller prime factors, sweeter interval. Euler also wrote on comma division across temperaments (the same problem 2^(1/12) settles) and on vibrating-string acoustics.

Credits