Chromatone Spectrogram is a real-time, colorized visual map of audio that runs directly in your browser. It translates the invisible physics of sound into a beautiful, readable landscape of color and light, allowing you to literally see the music.
How to use it:
- Open the app and allow microphone access.
- Play an instrument, sing, or play a song.
- Watch the center line: new sounds appear instantly.
- Notice the colors: each musical note has its own distinct color (A is red, B is bright yellow, F is deep blue).
- Look at the edges: older sounds compress into deep "sediment" layers, revealing the overall structure and chord progressions of the song.
- Use the camera and video buttons to capture your visualizations.
Moving beyond simple waveforms and standard mathematical spectrograms, this project treats music as a physical, geological phenomenon.
The Chromatone System We map the 12 notes of the chromatic scale to the 360 degrees of the color wheel. We intentionally use the HSL color space rather than perceptually uniform spaces (like OKLab) because the inherent "weight" and brightness of HSL colors carry emotional and pedagogical gravity. Yellow naturally radiates; blue recedes. This non-uniformity makes learning the "colors" of notes deeply intuitive and connects sound directly to human emotion.
The Cochleagram Standard spectrograms use linear or logarithmic math. We use a hybrid model that bridges musical theory (12-TET constant-Q) and human biology (cochlear Equivalent Rectangular Bandwidth). It visualizes sound not just as it exists in the air, but as it is perceived by the human ear.
Sedimentary Time Music is architecture experienced over time. By applying exponential time compression, we allow recent sounds to remain crisp and detailed, while older sounds compress into the background. This turns a fleeting audio stream into a readable "geological" record, where you can see the macro-structure, harmonic spread, and whistle tones of an entire song at a single glance.
- Deep Sediment Vision & Time Compression: Exponential scrolling that compresses deep history. Fast transients (snares, hi-hats) gracefully fade into the background over time, while sustained harmonic architecture remains vividly visible.
- Chromatone Frequency Mapping: Continuous 12-TET mapping where every A is red, cycling through the spectrum. Lower octaves are darker, higher octaves are lighter.
- Sub-Pixel Parabolic Peak Recovery: Recovers energy that falls between discrete FFT bins, making low notes tighter and high harmonics razor-sharp.
- Spectral Envelope Contrast: Removes cloudy "formant haze" and room resonances, leaving only the crisp, distinct harmonic partials.
- Transient / Sustained Separation: A dual-channel GPU architecture that independently tracks fast percussive attacks and slow harmonic sustains for perfect deep-time rendering.
- 2D Ridge-Aware Sharpening: Anisotropic Laplacian filtering in the shader that sharpens both horizontal harmonic ridges and diagonal pitch-bends without temporal ringing.
- Cochlear/Musical Hybrid Bands: Blends Constant-Q musical bands with ERB auditory filters from A0 to C9.
- Perceptual dB Pipeline: True logarithmic processing with A-weighting and pre-emphasis.
- Lateral Inhibition: On-center/off-surround spectral sharpening mimicking basilar membrane hair cells.
- Display P3 & High-Res Capture: Wide-gamut color support and high-quality video/screenshot recording.
- Zero-dependency PWA: Pure Web Audio API and WebGL2, installable and works offline.
The rendering pipeline is divided into a highly optimized CPU-side Digital Signal Processing (DSP) stage and a branchless, single-pass GPU fragment shader.
To compress time without distorting the present, we map screen distance
At high compression values (e.g., fwidth), and performs a multi-tap interval integration.
The history ring buffer stores two channels:
- Red (Total Energy): The full perceptual loudness.
- Green (Transient Detail): The fast-attack, high-frequency percussive energy.
In the deep-time shader pass, the transient channel is mathematically faded based on the time-density ($1 / (1 + 0.1 \cdot \text{taps})$). This allows sustained chords and whistle tones to persist as "sediment" while percussive noise dissolves into the background.
Standard FFTs smear energy across bins. We apply parabolic interpolation to find the true mathematical peak of a frequency: $$ y_{true} = y_0 - \frac{1}{4}(y_{-1} - y_{1})\delta $$ This collapses "ropes" of sound into 1-pixel laser lines. Furthermore, we estimate a broad local-maximum spectral envelope and subtract it in the dB domain, acting as an "anti-cloud" filter that removes formant humps and room resonances.
Instead of a harsh noise gate, we use a soft-threshold function in the shader to crush low-level FFT noise to absolute black: $$ f(x) = \frac{\max(x - \lambda, 0)}{1 - \lambda} $$ This preserves the upper dynamic range and gives the sedimentary layers clean, glass-like edges.
All temporal smoothing (cochlear integration, sustain/transient splitting) uses true time constants (performance.now(). The smoothing factor
- Vue 3 — Reactive UI framework
- Vite — Build tool and dev server
- UnoCSS — Utility-first CSS
- Web Audio API — Native browser audio processing (no external audio libraries)
- WebGL2 — GPU-accelerated rendering and custom fragment shaders
# Clone the repository
git clone https://github.com/chromatone/spectrogram.git
cd spectrogram
# Install dependencies
pnpm install
# Run development server
pnpm dev
# Build for production
pnpm build- FFT Size —
12-15(4096-32768) — Higher values improve low-frequency resolution. - Speed —
0.1-4— Scrolling speed of the spectrogram. Fractional values stretch time; high speeds use temporal interpolation. - Time Compression —
0.0-3.1— Exponential time mapping.0.0is linear. Higher values compress deep history into the edges, revealing song architecture. - Midpoint —
0-1— Sigmoid threshold for signal visibility. - Steep —
3-40— Sigmoid steepness for noise floor control. - Offset —
0-1— Position of the "present moment" origin line. - Dynamic Range —
40-100dB — The perceptual window of loudness.
(Hidden advanced constants in the code include LATERAL_INHIBITION, ENVELOPE_CONTRAST, SOFT_THRESHOLD, and RIDGE_SHARPEN for fine-tuning the clarity pipeline).
- A0 — 27.5 Hz (lowest piano key)
- C9 — 15,870 Hz (highest piano key + 1 octave)
The spectrogram covers the full piano range plus one octave above, suitable for most musical, vocal, and acoustic analysis.
MIT
