ttune: Terminal Equalizer Graphics
FFmpeg audio pipelines and discrete Fourier transform rendering in Python Curses.
Rendering smooth, colored graphics in a text terminal requires bypassing conventional print statements in favor of raw terminal buffer control. In ttune, the audio playback pipeline runs parallel to an asynchronous frequency analyzer that updates the terminal display at 30 updates per second.
Asynchronous Audio Pipe
FFmpeg runs as a background subprocess decoding any incoming media container into a raw 16-bit 44.1kHz stereo PCM byte stream piped directly into Python standard input. This sidesteps the need for proprietary codec wrappers.
Fast Fourier Transform (FFT) Binning
As raw audio chunks stream through, NumPy computes discrete Fast Fourier Transforms to extract spectral amplitude across human audible frequencies (20Hz to 20kHz). Frequency bands are logarithmically mapped to terminal columns to mirror human ear frequency sensitivity.
Curses Color Gradient Mapping
Vertical equalizer bars are drawn using Unicode block characters ( ▂▃▄▅▆▇█). Each vertical level maps to a specific color pair, providing responsive visual feedback synchronized with audio playback.