aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-08-13 19:21:18 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-08-13 19:21:18 +0000
commitae294cd46897a0b88b62823641a2e1b31cdd542b (patch)
tree593066b1365c7f22cb303cd9169fb658b1507cb8 /src
parentdc3192ca31794e2b7e172ed0b5b987893cd86824 (diff)
downloadqmmp-ae294cd46897a0b88b62823641a2e1b31cdd542b.tar.gz
qmmp-ae294cd46897a0b88b62823641a2e1b31cdd542b.tar.bz2
qmmp-ae294cd46897a0b88b62823641a2e1b31cdd542b.zip
equalizer refactoring
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9040 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/qmmp/equ/iir.c15
-rw-r--r--src/qmmp/equ/iir.h23
-rw-r--r--src/qmmp/equ/iir_fpu.c8
-rw-r--r--src/qmmp/outputwriter.cpp12
4 files changed, 34 insertions, 24 deletions
diff --git a/src/qmmp/equ/iir.c b/src/qmmp/equ/iir.c
index 97abdf0f0..05d1f0689 100644
--- a/src/qmmp/equ/iir.c
+++ b/src/qmmp/equ/iir.c
@@ -51,20 +51,23 @@ unsigned int blength = 0;
*/
unsigned int rate = 0;
int band_count = 0;
-int two_passes = 0;
+unsigned int eq_options = 0;
-void set_preamp(int chn, float val)
+void eq_set_preamp(int chn, float val)
{
preamp[chn] = val;
}
-void set_two_passes(int enabled)
+void eq_set_option(eq_option_t option, int enabled)
{
- two_passes = enabled;
+ if(enabled)
+ eq_options |= option;
+ else
+ eq_options &= ~option;
}
/* Init the filters */
-void init_iir(unsigned int srate, int band_num)
+void eq_init_iir(unsigned int srate, int band_num)
{
calc_coeffs();
#if 0
@@ -78,7 +81,7 @@ void init_iir(unsigned int srate, int band_num)
rate = srate;
iir_cf = get_coeffs(&band_count, rate);
- clean_history();
+ eq_clean_history();
}
#ifdef ARCH_X86
diff --git a/src/qmmp/equ/iir.h b/src/qmmp/equ/iir.h
index 1a1d9207e..9d6afe336 100644
--- a/src/qmmp/equ/iir.h
+++ b/src/qmmp/equ/iir.h
@@ -58,16 +58,23 @@
#endif
/*
- * Function prototypes
+ * Equalizer options
*/
-void init_iir(unsigned int srate, int band_num);
-void clean_history();
-void set_gain(int index, int chn, float val);
-void set_preamp(int chn, float val);
-void set_two_passes(int enabled);
+typedef enum {
+ EQ_TWO_PASSES = 0x01,
+ EQ_LIMITER = 0x02
+} eq_option_t;
-int iir(float * d, int samples, int nch);
+/*
+ * Function prototypes
+ */
+void eq_init_iir(unsigned int srate, int band_num);
+void eq_clean_history();
+void eq_set_gain(int index, int chn, float val);
+void eq_set_preamp(int chn, float val);
+void eq_set_option(eq_option_t option, int enabled);
+int eq_iir(float * d, int samples, int nch);
#ifdef ARCH_X86
__inline__ int round_trick(float floatvalue_to_round);
@@ -82,7 +89,7 @@ __inline__ int round_ppc(float x);
extern float preamp[EQ_CHANNELS];
extern sIIRCoefficients *iir_cf;
extern int band_count;
-extern int two_passes;
+extern unsigned int eq_options;
#ifdef BENCHMARK
extern double timex;
diff --git a/src/qmmp/equ/iir_fpu.c b/src/qmmp/equ/iir_fpu.c
index f1416be63..5c2caf157 100644
--- a/src/qmmp/equ/iir_fpu.c
+++ b/src/qmmp/equ/iir_fpu.c
@@ -37,12 +37,12 @@ static sXYData data_history[EQ_CHANNELS][EQ_MAX_BANDS] __attribute__((aligned));
static sXYData data_history2[EQ_CHANNELS][EQ_MAX_BANDS] __attribute__((aligned));
float gain[EQ_CHANNELS][EQ_MAX_BANDS] __attribute__((aligned));
-void set_gain(int index, int chn, float val)
+void eq_set_gain(int index, int chn, float val)
{
gain[chn][index] = val;
}
-void clean_history()
+void eq_clean_history()
{
//int n;
/* Zero the history arrays */
@@ -50,7 +50,7 @@ void clean_history()
memset(data_history2, 0, sizeof(sXYData) * EQ_MAX_BANDS * EQ_CHANNELS);
}
-__inline__ int iir(float *d, int samples, int nch)
+__inline__ int eq_iir(float *d, int samples, int nch)
{
// FTZ_ON;
float *data = (float *) d;
@@ -117,7 +117,7 @@ __inline__ int iir(float *d, int samples, int nch)
out[channel] += data_history[channel][band].y[i]*gain[channel][band]; // * 2.0;
} /* For each band */
- if (two_passes)
+ if (eq_options & EQ_TWO_PASSES)
{
/* Filter the sample again */
for (band = 0; band < band_count; band++)
diff --git a/src/qmmp/outputwriter.cpp b/src/qmmp/outputwriter.cpp
index 524585790..289bdeb41 100644
--- a/src/qmmp/outputwriter.cpp
+++ b/src/qmmp/outputwriter.cpp
@@ -92,7 +92,7 @@ bool OutputWriter::initialize(quint32 freq, ChannelMap map)
m_bytesPerMillisecond = m_frequency * m_channels * AudioParameters::sampleSize(m_format) / 1000;
m_recycler.configure(m_in_params.sampleRate(), m_in_params.channels()); //calculate output buffer size
updateEqSettings();
- clean_history();
+ eq_clean_history();
return true;
}
@@ -284,7 +284,7 @@ void OutputWriter::run()
m_mutex.lock();
if (m_useEq)
{
- iir(b->data, b->samples, m_channels);
+ eq_iir(b->data, b->samples, m_channels);
}
m_mutex.unlock();
dispatchVisual(b);
@@ -380,17 +380,17 @@ void OutputWriter::updateEqSettings()
double preamp = m_settings->eqSettings().preamp();
int bands = m_settings->eqSettings().bands();
- init_iir(m_frequency, bands);
- set_two_passes(m_settings->eqSettings().twoPasses());
+ eq_init_iir(m_frequency, bands);
+ eq_set_option(EQ_TWO_PASSES, m_settings->eqSettings().twoPasses());
for(int ch = 0; ch < m_channels; ++ch)
{
- set_preamp(ch, 1.0 + 0.0932471 *preamp + 0.00279033 * preamp * preamp);
+ eq_set_preamp(ch, 1.0 + 0.0932471 *preamp + 0.00279033 * preamp * preamp);
for(int i = 0; i < bands; ++i)
{
double value = m_settings->eqSettings().gain(i);
- set_gain(i, ch, 0.03 * value + 0.000999999 * value * value);
+ eq_set_gain(i, ch, 0.03 * value + 0.000999999 * value * value);
}
}
}