summaryrefslogtreecommitdiff
path: root/apps/dsp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dsp.c')
-rw-r--r--apps/dsp.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 19cb669a06..b2fc0ce7a2 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -19,6 +19,7 @@
19#include <inttypes.h> 19#include <inttypes.h>
20#include <string.h> 20#include <string.h>
21#include "dsp.h" 21#include "dsp.h"
22#include "eq.h"
22#include "kernel.h" 23#include "kernel.h"
23#include "playback.h" 24#include "playback.h"
24#include "system.h" 25#include "system.h"
@@ -166,10 +167,21 @@ struct crossfeed_data
166 int index; 167 int index;
167}; 168};
168 169
170/* Current setup is one lowshelf filters, three peaking filters and one
171 highshelf filter. Varying the number of shelving filters make no sense,
172 but adding peaking filters are possible. */
173struct eq_state {
174 char enabled[5]; /* Flags for active filters */
175 struct eqfilter ls;
176 struct eqfilter pk[3];
177 struct eqfilter hs;
178};
179
169static struct dsp_config dsp_conf[2] IBSS_ATTR; 180static struct dsp_config dsp_conf[2] IBSS_ATTR;
170static struct dither_data dither_data[2] IBSS_ATTR; 181static struct dither_data dither_data[2] IBSS_ATTR;
171static struct resample_data resample_data[2] IBSS_ATTR; 182static struct resample_data resample_data[2] IBSS_ATTR;
172struct crossfeed_data crossfeed_data IBSS_ATTR; 183struct crossfeed_data crossfeed_data IBSS_ATTR;
184static struct eq_state eq_data;
173 185
174static int pitch_ratio = 1000; 186static int pitch_ratio = 1000;
175 187
@@ -608,6 +620,25 @@ static void apply_crossfeed(long* src[], int count)
608} 620}
609#endif 621#endif
610 622
623/* Apply EQ filters to those bands that have got it switched on. */
624void eq_process(long **x, unsigned num)
625{
626 int i;
627 unsigned int channels = dsp->stereo_mode != STEREO_MONO ? 2 : 1;
628
629 /* filter configuration currently is 1 low shelf filter, 3 band peaking
630 filters and 1 high shelf filter, in that order.
631 */
632 if (eq_data.enabled[0])
633 eq_filter(x, &eq_data.ls, num, channels, EQ_SHELF_SHIFT);
634 for (i = 0; i < 3; i++) {
635 if (eq_data.enabled[1 + i])
636 eq_filter(x, &eq_data.pk[i], num, channels, EQ_PEAK_SHIFT);
637 }
638 if (eq_data.enabled[4])
639 eq_filter(x, &eq_data.hs, num, channels, EQ_SHELF_SHIFT);
640}
641
611/* Apply a constant gain to the samples (e.g., for ReplayGain). May update 642/* Apply a constant gain to the samples (e.g., for ReplayGain). May update
612 * the src array if gain was applied. 643 * the src array if gain was applied.
613 * Note that this must be called before the resampler. 644 * Note that this must be called before the resampler.
@@ -713,6 +744,9 @@ long dsp_process(char* dst, char* src[], long size)
713 samples = resample(tmp, samples); 744 samples = resample(tmp, samples);
714 if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO) 745 if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO)
715 apply_crossfeed(tmp, samples); 746 apply_crossfeed(tmp, samples);
747 /* TODO: Might want to wrap this with a generic eq_enabled when the
748 settings are in place */
749 eq_process(tmp, samples);
716 write_samples((short*) dst, tmp, samples); 750 write_samples((short*) dst, tmp, samples);
717 written += samples; 751 written += samples;
718 dst += samples * sizeof(short) * 2; 752 dst += samples * sizeof(short) * 2;