diff --git a/include/BasicFilters.h b/include/BasicFilters.h index 4cde320a638..215c32dfb49 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -144,7 +144,12 @@ template class BiQuad { public: - BiQuad() + BiQuad() : + m_a1(0.), + m_a2(0.), + m_b0(0.), + m_b1(0.), + m_b2(0.) { clearHistory(); } diff --git a/plugins/Eq/EqEffect.cpp b/plugins/Eq/EqEffect.cpp index 8a795414429..31be4d0f5b6 100644 --- a/plugins/Eq/EqEffect.cpp +++ b/plugins/Eq/EqEffect.cpp @@ -289,6 +289,9 @@ bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) float EqEffect::peakBand( float minF, float maxF, EqAnalyser *fft, int sr ) { + auto const fftEnergy = fft->getEnergy(); + if (fftEnergy == 0.) { return 0.; } + float peak = -60; float *b = fft->m_bands; float h = 0; @@ -296,7 +299,7 @@ float EqEffect::peakBand( float minF, float maxF, EqAnalyser *fft, int sr ) { if( bandToFreq( x ,sr) >= minF && bandToFreq( x,sr ) <= maxF ) { - h = 20 * ( log10( *b / fft->getEnergy() ) ); + h = 20. * log10(*b / fftEnergy); peak = h > peak ? h : peak; } } diff --git a/plugins/Eq/EqSpectrumView.cpp b/plugins/Eq/EqSpectrumView.cpp index e75248755e2..35eb90dc088 100644 --- a/plugins/Eq/EqSpectrumView.cpp +++ b/plugins/Eq/EqSpectrumView.cpp @@ -208,10 +208,10 @@ EqSpectrumView::EqSpectrumView(EqAnalyser *b, QWidget *_parent) : void EqSpectrumView::paintEvent(QPaintEvent *event) { - const float energy = m_analyser->getEnergy(); - if( energy <= 0 && m_peakSum <= 0 ) + const float energy = m_analyser->getEnergy(); + if (energy <= 0.) { - //dont draw anything + // If there is no energy in the signal we don't need to draw anything return; } @@ -238,7 +238,8 @@ void EqSpectrumView::paintEvent(QPaintEvent *event) const float fallOff = 1.07; for( int x = 0; x < MAX_BANDS; ++x, ++bands ) { - peak = ( fh * 2.0 / 3.0 * ( 20 * ( log10( *bands / energy ) ) - LOWER_Y ) / ( - LOWER_Y ) ); + peak = *bands != 0. ? (fh * 2.0 / 3.0 * (20. * log10(*bands / energy) - LOWER_Y) / (-LOWER_Y)) : 0.; + if( peak < 0 ) { peak = 0;