@@ -101,7 +101,7 @@ static constexpr AudioInputParams kParamsMesmerizer{
101101 0 .90f , // energyEnvDecay
102102 0 .000001f , // energyMinEnv
103103 0 .25f , // bandCompLow
104- 6 . 5f , // bandCompHigh
104+ 10 . 0f , // bandCompHigh
105105 0 .00f , // frameSilenceGate
106106 0 .00f , // normNoiseGate
107107 3 .0f , // envFloorFromNoise (cap auto-gain at ~1/4 of pure-noise)
@@ -310,7 +310,7 @@ class SoundAnalyzer : public ISoundAnalyzer
310310 // I'm old enough I can only hear up to about 12000Hz, but feel free to adjust. Remember from
311311 // school that you need to sample at double the frequency you want to process, so 24000 samples is 12000Hz
312312
313- static constexpr size_t SAMPLING_FREQUENCY = 24000 ;
313+ static constexpr size_t SAMPLING_FREQUENCY = 20000 ;
314314 static constexpr size_t LOWEST_FREQ = 100 ;
315315 static constexpr size_t HIGHEST_FREQ = SAMPLING_FREQUENCY / 2 ;
316316
@@ -449,8 +449,8 @@ class SoundAnalyzer : public ISoundAnalyzer
449449
450450 void ComputeBandLayout ()
451451 {
452- const float fMin = 50 . 0f ;
453- const float fMax = std::min<float >(12000 . 0f , SAMPLING_FREQUENCY / 2 .0f );
452+ const float fMin = LOWEST_FREQ ;
453+ const float fMax = std::min<float >(HIGHEST_FREQ , SAMPLING_FREQUENCY / 2 .0f );
454454 const float binWidth = (float )SAMPLING_FREQUENCY / (MAX_SAMPLES / 2 .0f );
455455 int prevBin = 2 ;
456456#if SPECTRUM_BAND_SCALE_MEL
@@ -614,6 +614,32 @@ class SoundAnalyzer : public ISoundAnalyzer
614614 _Peaks._Level [b] = v;
615615 sumNorm += v;
616616 }
617+
618+ #if ENABLE_AUDIO_SMOOTHING
619+ // Spatially smooth live spectrum peaks by blending with neighbors.
620+ // This affects displayed bars (and VU after we recompute below).
621+ {
622+ float tmp[NUM_BANDS ];
623+ for (int b = 0 ; b < NUM_BANDS ; ++b)
624+ {
625+ float v = _Peaks._Level [b];
626+ float l = (b > 0 ) ? _Peaks._Level [b - 1 ] : v;
627+ float r = (b < NUM_BANDS - 1 ) ? _Peaks._Level [b + 1 ] : v;
628+ tmp[b] = (v * 2 .0f + l + r) * 0 .25f ; // (2*center + left + right) / 4
629+ }
630+ for (int b = 0 ; b < NUM_BANDS ; ++b)
631+ {
632+ float v = tmp[b];
633+ if (v > 1 .0f ) v = 1 .0f ;
634+ _vPeaks[b] = v;
635+ _Peaks._Level [b] = v;
636+ }
637+ // Recompute VU from smoothed values
638+ sumNorm = 0 .0f ;
639+ for (int b = 0 ; b < NUM_BANDS ; ++b)
640+ sumNorm += _Peaks._Level [b];
641+ }
642+ #endif
617643 UpdateVU ((float )(sumNorm / NUM_BANDS ));
618644 return _Peaks;
619645 }
@@ -912,15 +938,7 @@ class SoundAnalyzer : public ISoundAnalyzer
912938 _peak2Decay[iBand] -= min (decayAmount2, _peak2Decay[iBand]);
913939 }
914940
915- // Manual smoothing if desired
916-
917- #if ENABLE_AUDIO_SMOOTHING
918- for (int iBand = 1 ; iBand < NUM_BANDS - 1 ; iBand += 2 )
919- {
920- _peak1Decay[iBand] = (_peak1Decay[iBand] * 2 + _peak1Decay[iBand - 1 ] + _peak1Decay[iBand + 1 ]) / 4 ;
921- _peak2Decay[iBand] = (_peak2Decay[iBand] * 2 + _peak2Decay[iBand - 1 ] + _peak2Decay[iBand + 1 ]) / 4 ;
922- }
923- #endif
941+ // Removed old smoothing of decay overlays; smoothing now applies to live peaks in ProcessPeaksEnergy()
924942 }
925943
926944 // Update the per-band decay overlays from the latest peaks.
0 commit comments