summaryrefslogtreecommitdiff
path: root/apps/dsp.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-02-04 23:15:15 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-02-04 23:15:15 +0000
commit621bcc22940aed0242ed1795491a400521d2394d (patch)
tree4e2436a360db85c5b2cbe82b71a525e682b37738 /apps/dsp.c
parent2fcd1b09d4514856153dee14f55ba5bbd10d43a8 (diff)
downloadrockbox-621bcc22940aed0242ed1795491a400521d2394d.tar.gz
rockbox-621bcc22940aed0242ed1795491a400521d2394d.zip
The simulator should use the keypad period key, not the regular one
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8568 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/dsp.c')
-rw-r--r--apps/dsp.c58
1 files changed, 56 insertions, 2 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 789cf72b20..f403674ba2 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -145,6 +145,7 @@ struct dsp_config
145 bool dither_enabled; 145 bool dither_enabled;
146 bool new_gain; 146 bool new_gain;
147 bool crossfeed_enabled; 147 bool crossfeed_enabled;
148 bool eq_enabled;
148}; 149};
149 150
150struct resample_data 151struct resample_data
@@ -618,6 +619,52 @@ static void apply_crossfeed(long* src[], int count)
618} 619}
619#endif 620#endif
620 621
622#define EQ_CUTOFF_USER2REAL(x) (0xffffffff / dsp->frequency * (x))
623#define EQ_Q_USER2REAL(x) (((x) << 16) / 10)
624#define EQ_GAIN_USER2REAL(x) (((x) << 16) / 10)
625
626/* Synchronize the EQ filters with the global settings */
627static void eq_update_data()
628{
629 int i;
630 int *setting;
631 int gain, cutoff, q, maxgain;
632
633 /* Don't do anything if we're not playing */
634 if (dsp->frequency == 0)
635 return;
636
637 setting = &global_settings.eq_band0_cutoff;
638 maxgain = 0;
639
640 /* Iterate over each band and update the appropriate filter */
641 for(i = 0; i < 5; i++) {
642 cutoff = *setting++;
643 q = *setting++;
644 gain = *setting++;
645
646 /* Keep track of maxgain for the pre-amp */
647 if (gain > maxgain)
648 maxgain = gain;
649
650 if (gain == 0) {
651 eq_data.enabled[i] = 0;
652 } else {
653 if (i == 0)
654 eq_ls_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
655 EQ_GAIN_USER2REAL(gain), eq_data.filters[0].coefs);
656 else if (i == 4)
657 eq_hs_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
658 EQ_GAIN_USER2REAL(gain), eq_data.filters[4].coefs);
659 else
660 eq_pk_coefs(EQ_CUTOFF_USER2REAL(cutoff), EQ_Q_USER2REAL(q),
661 EQ_GAIN_USER2REAL(gain), eq_data.filters[i].coefs);
662
663 eq_data.enabled[i] = 1;
664 }
665 }
666}
667
621/* Apply EQ filters to those bands that have got it switched on. */ 668/* Apply EQ filters to those bands that have got it switched on. */
622static void eq_process(long **x, unsigned num) 669static void eq_process(long **x, unsigned num)
623{ 670{
@@ -737,6 +784,9 @@ long dsp_process(char* dst, char* src[], long size)
737 size /= dsp->sample_bytes * factor; 784 size /= dsp->sample_bytes * factor;
738 dsp_set_replaygain(false); 785 dsp_set_replaygain(false);
739 786
787 if (dsp->eq_enabled)
788 eq_update_data();
789
740 while (size > 0) 790 while (size > 0)
741 { 791 {
742 samples = convert_to_internal(src, size, tmp); 792 samples = convert_to_internal(src, size, tmp);
@@ -745,8 +795,7 @@ long dsp_process(char* dst, char* src[], long size)
745 samples = resample(tmp, samples); 795 samples = resample(tmp, samples);
746 if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO) 796 if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO)
747 apply_crossfeed(tmp, samples); 797 apply_crossfeed(tmp, samples);
748 /* TODO: Might want to wrap this with a generic eq_enabled when the 798 if (dsp->eq_enabled)
749 settings are in place */
750 eq_process(tmp, samples); 799 eq_process(tmp, samples);
751 write_samples((short*) dst, tmp, samples); 800 write_samples((short*) dst, tmp, samples);
752 written += samples; 801 written += samples;
@@ -943,6 +992,11 @@ bool dsp_configure(int setting, void *value)
943 return 1; 992 return 1;
944} 993}
945 994
995void dsp_set_eq(bool enable)
996{
997 dsp->eq_enabled = enable;
998}
999
946void dsp_set_crossfeed(bool enable) 1000void dsp_set_crossfeed(bool enable)
947{ 1001{
948 if (enable) 1002 if (enable)