aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/qmmp/equ/iir.c10
-rw-r--r--src/qmmp/equ/iir.h1
-rw-r--r--src/qmmp/output.cpp6
3 files changed, 10 insertions, 7 deletions
diff --git a/src/qmmp/equ/iir.c b/src/qmmp/equ/iir.c
index 3f946065a..8568ec9e2 100644
--- a/src/qmmp/equ/iir.c
+++ b/src/qmmp/equ/iir.c
@@ -40,10 +40,10 @@ unsigned int blength = 0;
#endif
/*
- * Global vars
+ * Equalizer settings
*/
-unsigned int rate;
-int band_count;
+unsigned int rate = 0;
+int band_count = 0;
void set_preamp(int chn, float val)
{
@@ -58,8 +58,10 @@ void init_iir(unsigned int srate, int band_num)
band_count = cfg.band_num;
#endif
- band_count = band_num;
+ if(srate == rate && band_num == band_count)
+ return;
+ band_count = band_num;
rate = srate;
iir_cf = get_coeffs(&band_count, rate);
diff --git a/src/qmmp/equ/iir.h b/src/qmmp/equ/iir.h
index 544f4c2bf..a85dfc0bf 100644
--- a/src/qmmp/equ/iir.h
+++ b/src/qmmp/equ/iir.h
@@ -71,7 +71,6 @@ __inline__ int round_ppc(float x);
extern float preamp[EQ_CHANNELS];
extern sIIRCoefficients *iir_cf;
-extern unsigned int rate;
extern int band_count;
#ifdef BENCHMARK
diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp
index 80074e4f3..84f51610b 100644
--- a/src/qmmp/output.cpp
+++ b/src/qmmp/output.cpp
@@ -88,7 +88,10 @@ void Output::configure(quint32 freq, int chan, Qmmp::AudioFormat format)
m_visBuffer = new unsigned char [m_visBufferSize];
m_useEq = m_eqEnabled && m_frequency && m_format == Qmmp::PCM_S16LE;
if(m_frequency)
+ {
init_iir(m_frequency, m_settings->eqSettings().bands());
+ clean_history();
+ }
}
void Output::pause()
@@ -380,8 +383,7 @@ void Output::updateEqSettings()
double preamp = m_settings->eqSettings().preamp();
int bands = m_settings->eqSettings().bands();
- if(band_count != bands)
- init_iir(m_frequency, bands);
+ init_iir(m_frequency, bands);
set_preamp(0, 1.0 + 0.0932471 *preamp + 0.00279033 * preamp * preamp);
set_preamp(1, 1.0 + 0.0932471 *preamp + 0.00279033 * preamp * preamp);