$ show openclaw/songsee
songsee is a single-binary Go CLI tool that turns audio files into spectral visualization images. It decodes audio natively (WAV, MP3) or via ffmpeg, computes an FFT specrogram, and renders nine visualiation modes (spectrogram, mel, chroma, HPSS, self-similarity, loudness, tempogram, MFCC, spectral flux) as a grid of heatmaps in PNG or JPEG format. The architecture is a monlith: the `cmd/songsee/main.go` entry point parsers flags using Kong, delegates to `internal/audio` for decoding, `internal/dsp` for signal processing (STFT, mel filtering, chroma, median filters, etc.), and `internal/render` for image generation. It produces deterministic output – same input flags yield identical bytes. The codebase is well-structured with comprehensive tests, CI/CD, and a clean separation of concerns. It demonstrates high craftsmanship in DSP optimization (e.g., bit-exact HPSS with median networks, tiling) and safe WAV parsing.
The LLM identified 3 files worth highlighting for reuse:
Implements harmonic-percussive source separation (HPSS) using 2D median filters on spectrogram magnitudes. The code is highly optimized: it reuses scratch buffers, processes frames in tiles to reduce strided memory access, and uses a hand-crafted 19-comparator median network for 9-element windows that avoids sorting. It produces bit-exact output compared to the naive sorting implementation. This is a reusable, self-contained audio separation primitive that could be extracted for use in other Go audio analysis projects.
A pure-Go WAV decoder that supports PCM (8/16/24/32 bit), IEEE float (32/64 bit), and WAVE_FORMAT_EXTENSIBLE. It carefully validates chunk sizes against the RIFF file bounds, rejects truncated headers and incomplete sample frames, and skips unknown RIFF chunks by seeking without allocating payload. The decoder is safe against forged large chunk sizes (avoids OOM) and handles both mono and multichannel input with correct padding. This is a high-quality, reusable WAV parser that could serve as a standalone library for any Go audio tooling.
Defines color palettes with linear gradient interpolation from configurable color stops. Supports six built-in palettes (classic, magma, inferno, viridis, gray, claw) plus aliases. The gradient function lazily interpolates between stops and clamps out-of-range values. It's a small, self-contained module that could be reused anywhere a Go program needs to map normalized floats to RGBA colors – not just for audio visualization but for any heatmap or data visualization task.