Chromesthesia is a high-performance command-line tool written in Rust that converts audio files into visual spectrograms. It maps audio frequencies to colors and loudness to brightness, creating a unique visual representation of your music.
- Format Support: Decodes MP3 and WAV files.
- Parallel Processing: Uses
rayonto process audio frames in parallel for fast rendering. - Customizable Output: Adjust the image width, time resolution, and FFT window size.
- Visual Mapping:
- Hue: Represents Pitch/Frequency (Low frequencies are Purple, High frequencies are Red).
- Brightness/Saturation: Represents Loudness/Magnitude (dB).
Ensure you have Rust installed.
git clone https://github.com/yourusername/chromesthesia.git
cd chromesthesia
cargo build --releaseRun the program using cargo run or the compiled binary.
cargo run --release -- --input song.mp3 --output visualization.png| Argument | Short | Default | Description |
|---|---|---|---|
--input |
-i |
Required | Input music file path (mp3, wav). |
--output |
-o |
Required | Output PNG file path. |
--width |
256 |
Width of the output image in pixels. | |
--duration |
-d |
0.001 |
Duration of audio represented by one pixel height (in seconds). |
--window-size |
1024 |
Window size for FFT (must be a power of 2, e.g., 512, 1024, 2048, 4096). |
Generate a wider image with higher frequency resolution:
cargo run --release -- \
--input input.wav \
--output output.png \
--width 1024 \
--window-size 4096 \
--duration 0.002You can find an example visualization in the examples folder:
- Hostility Restrained by Shiro Sagisu (from Evangelion) YouTube
- Decoding: The audio is decoded into mono floating-point samples.
- FFT Analysis: The audio is sliced into frames based on the
--durationand analyzed using Fast Fourier Transform (FFT). - Processing: For each frame, the dominant frequency is identified.
- A "Noise Gate" filters out silence (-40dB from peak).
- Frequencies are clamped between ~40Hz and ~5000Hz.
- Rendering: The data is mapped to HSV color space and saved as a PNG.
