Skip to content

Feat: Adding real-time audio visualisation#943

Open
Narqulie wants to merge 2 commits intoaome510:masterfrom
Narqulie:feature/audio-visualization
Open

Feat: Adding real-time audio visualisation#943
Narqulie wants to merge 2 commits intoaome510:masterfrom
Narqulie:feature/audio-visualization

Conversation

@Narqulie
Copy link

@Narqulie Narqulie commented Mar 6, 2026

No description provided.

Narqulie added 2 commits March 6, 2026 18:00
   Adds an opt-in frequency bar chart to the playback window powered
   by a sliding-window FFT (rustfft) on the librespot audio stream.

   - 64 log-scale frequency bands (bass → treble)
   - Overlapping windows (HOP_SIZE=256) for smooth ~5.8ms update rate
   - Per-frame decay so bars fade out gracefully (configurable)
   - Gated behind the existing `streaming` feature
   - Enabled via `enable_audio_visualization = true` in app.toml

   Closes aome510#689
@Narqulie Narqulie changed the title Missed Cargo.lock Adding real-time audio visualisation Mar 6, 2026
@Narqulie Narqulie changed the title Adding real-time audio visualisation Feat: Adding real-time audio visualisation Mar 6, 2026
@Narqulie
Copy link
Author

Narqulie commented Mar 6, 2026

Screen Recording 2026-03-06 at 17 56 33

Implements the frequency visualization requested in #689.

What this does

Adds an opt-in bar chart to the playback window showing real-time frequency content of the music being played — 64 log-scale bands from bass (left) to treble (right), with a smooth decay so bars fade out gradually rather
than snapping to silence.

How it works

Rather than using the deprecated Spotify Audio Analysis API, this taps directly into the librespot audio stream. A VisualizationSink wraps the real audio backend, intercepts decoded PCM samples, and runs an FFT using rustfft
(https://crates.io/crates/rustfft). Results are written to a shared buffer that the UI reads each render frame.

Key details:

  • Sliding window FFT (FFT_SIZE=1024, HOP_SIZE=256) gives ~5.8ms update rate — well ahead of the ~32ms UI refresh
  • Hann windowing to reduce spectral leakage
  • Bars rise instantly on loud transients, decay slowly with a configurable factor
  • Only active with the streaming feature; no-op and zero overhead otherwise
  • Disabled by default — opt in via enable_audio_visualization = true in app.toml

To try it

Add to your ~/.config/spotify-player/app.toml:

enable_audio_visualization = true

Then build with the streaming feature enabled (the default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant