Optimize visualizer: 16 bins mirrored, Material You colors

- Reduce FFT to 30fps with 16 bins (mirrored to 32 visual bars)
- Use 1024 FFT size for faster processing
- Extract dominant colors from album artwork
- Center artwork with track info and quality badge
- Bars render from edges inward with color gradient
This commit is contained in:
vicrodh committed 2026-02-01 18:44:52 -06:00
1 parent 4b74e1c490
commit bb4fcfd6b8
4 files changed
+219 -119

No files matched your search

+4 -3
View File
@@ -175,7 +175,7 @@ mod tests {
#[test]
fn test_log_frequency_distribution() {
// Verify that frequency bars are logarithmically distributed
let num_bars = 64;
let num_bars = NUM_BARS; // Use the actual constant
let min_log = 20.0_f32.ln();
let max_log = 20000.0_f32.ln();
@@ -189,8 +189,9 @@ mod tests {
// First bar should be around 20Hz
assert!(freqs[0] > 19.0 && freqs[0] < 25.0);
// Middle bar (~32) should be around 630Hz (geometric mean of 20 and 20000)
assert!(freqs[32] > 500.0 && freqs[32] < 800.0);
// Middle bar (~16 for 32 bars) should be around 630Hz (geometric mean of 20 and 20000)
let mid = num_bars / 2;
assert!(freqs[mid] > 500.0 && freqs[mid] < 800.0);
// Last bar should approach 20000Hz
assert!(freqs[num_bars - 1] > 15000.0);
+5 -4
View File
@@ -17,14 +17,15 @@ use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use tauri::AppHandle;
/// Number of frequency bins to send to frontend
pub const NUM_BARS: usize = 64;
/// 16 bins, mirrored on frontend for symmetric look
pub const NUM_BARS: usize = 16;
/// FFT size (must be power of 2)
/// 2048 gives good frequency resolution at ~21Hz per bin at 44.1kHz
pub const FFT_SIZE: usize = 2048;
/// 1024 is faster than 2048 and still gives ~43Hz resolution at 44.1kHz
pub const FFT_SIZE: usize = 1024;
/// Target frames per second for visualization updates
pub const TARGET_FPS: u64 = 60;
pub const TARGET_FPS: u64 = 30;
/// Shared state for visualization that can be passed to the audio thread
#[derive(Clone)]