Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chromesthesia

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.

Features

  • Format Support: Decodes MP3 and WAV files.
  • Parallel Processing: Uses rayon to 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).

Installation

Ensure you have Rust installed.

git clone https://github.com/yourusername/chromesthesia.git
cd chromesthesia
cargo build --release

Usage

Run the program using cargo run or the compiled binary.

Basic Example

cargo run --release -- --input song.mp3 --output visualization.png

Command Line Arguments

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).

Advanced Example

Generate a wider image with higher frequency resolution:

cargo run --release -- \
  --input input.wav \
  --output output.png \
  --width 1024 \
  --window-size 4096 \
  --duration 0.002

Examples

You can find an example visualization in the examples folder:

  • Hostility Restrained by Shiro Sagisu (from Evangelion) YouTube

Hostility Restrained

How it Works

  1. Decoding: The audio is decoded into mono floating-point samples.
  2. FFT Analysis: The audio is sliced into frames based on the --duration and analyzed using Fast Fourier Transform (FFT).
  3. 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.
  4. Rendering: The data is mapped to HSV color space and saved as a PNG.

About

Converts audio files into visual spectrograms

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages