@@ -127,21 +127,20 @@ impl AudioAnalyzer {
127127 }
128128 }
129129
130- // Per-band gain for a pleasing visual curve
131- // Creates a natural "smile curve" - moderate lows, full mids, moderate highs
130+ // Per-band gain for visualization - boosted highs to compensate for low energy
132131 const BAND_GAINS : [ f32 ; NUM_BANDS ] = [
133- 0.5 , // Sub - reduce sub rumble
134- 0.65 , // Bass - visible but not overwhelming
135- 0.8 , // Low - building up
136- 0.9 , // LMid - almost full
137- 1.0 , // Mid - peak visibility (voice frequencies)
138- 1.0 , // UMid - peak visibility
139- 0.95 , // High - slightly reduce
140- 0.85 , // HiMid - gentle rolloff
141- 0.75 , // Pres - continuing rolloff
142- 0.65 , // Bril - less harsh highs
143- 0.55 , // Air - subtle
144- 0.45 , // Ultra - very subtle
132+ 0.7 , // Sub - reduce sub rumble
133+ 0.8 , // Bass - visible but not overwhelming
134+ 0.9 , // Low - building up
135+ 1.0 , // LMid - full
136+ 1.0 , // Mid - peak visibility (voice frequencies)
137+ 1.0 , // UMid - peak visibility
138+ 1.1 , // High - boost slightly
139+ 1.2 , // HiMd - boost more
140+ 1.3 , // Pres - boost more
141+ 1.4 , // Bril - boost more
142+ 1.6 , // Air - significant boost
143+ 2.0 , // Ultra - major boost ( very little energy here)
145144 ] ;
146145
147146 // Normalize and apply pleasing visual curve
@@ -160,11 +159,18 @@ impl AudioAnalyzer {
160159 for i in 0 ..NUM_BANDS {
161160 self . spectrum . bands [ i] =
162161 self . spectrum . bands [ i] * SMOOTHING + new_bands[ i] * ( 1.0 - SMOOTHING ) ;
162+ // Noise gate: treat very low values as zero
163+ if self . spectrum . bands [ i] < 0.005 {
164+ self . spectrum . bands [ i] = 0.0 ;
165+ }
163166 }
164167
165- // Update peak with smoothing
168+ // Update peak with smoothing and noise gate
166169 let current_peak = new_bands. iter ( ) . cloned ( ) . fold ( 0.0f32 , f32:: max) ;
167170 self . spectrum . peak = self . spectrum . peak * SMOOTHING + current_peak * ( 1.0 - SMOOTHING ) ;
171+ if self . spectrum . peak < 0.005 {
172+ self . spectrum . peak = 0.0 ;
173+ }
168174 }
169175}
170176
0 commit comments