diff options
author | Dan Everton <dan@iocaine.org> | 2006-03-27 21:20:35 +0000 |
---|---|---|
committer | Dan Everton <dan@iocaine.org> | 2006-03-27 21:20:35 +0000 |
commit | 91db36884525ee6c2822ff8ccbb7ac9df04d2890 (patch) | |
tree | be0d204626e9d7659df9b19ba0ee6e9c26d3726c /apps/dsp.c | |
parent | 7eb4d6c3b88e41c4ab9716be493697b244856cbb (diff) | |
download | rockbox-91db36884525ee6c2822ff8ccbb7ac9df04d2890.tar.gz rockbox-91db36884525ee6c2822ff8ccbb7ac9df04d2890.zip |
Add precut setting for the equalizer and add some more comments to the eq menu code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9298 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/dsp.c')
-rw-r--r-- | apps/dsp.c | 93 |
1 files changed, 61 insertions, 32 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index e5696bc7cd..b199d4e693 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -192,6 +192,7 @@ struct dsp_config | |||
192 | bool new_gain; | 192 | bool new_gain; |
193 | bool crossfeed_enabled; | 193 | bool crossfeed_enabled; |
194 | bool eq_enabled; | 194 | bool eq_enabled; |
195 | long eq_precut; /* Note that this is in S8.23 format. */ | ||
195 | }; | 196 | }; |
196 | 197 | ||
197 | struct resample_data | 198 | struct resample_data |
@@ -589,15 +590,31 @@ static void apply_crossfeed(int32_t* src[], int count) | |||
589 | } | 590 | } |
590 | #endif | 591 | #endif |
591 | 592 | ||
592 | /* Synchronize the EQ filters with the global settings */ | 593 | /** |
593 | void dsp_eq_update_data(bool enabled, int band) | 594 | * Use to enable the equalizer and set any pregain. |
595 | * | ||
596 | * @param enable true to enable the equalizer | ||
597 | * @param precut to apply in decibels (multiplied by 10) | ||
598 | */ | ||
599 | void dsp_eq_set(bool enable, unsigned int precut) | ||
600 | { | ||
601 | dsp->eq_enabled = enable; | ||
602 | |||
603 | /* Needs to be in s8.23 format amplitude for apply_gain() */ | ||
604 | dsp->eq_precut = get_replaygain_int(precut * -10) >> 1; | ||
605 | } | ||
606 | |||
607 | /** | ||
608 | * Synchronize the equalizer filter coefficients with the global settings. | ||
609 | * | ||
610 | * @param band the equalizer band to synchronize | ||
611 | */ | ||
612 | void dsp_eq_update_filter_coefs(int band) | ||
594 | { | 613 | { |
595 | const int *setting; | 614 | const int *setting; |
596 | long gain; | 615 | long gain; |
597 | unsigned long cutoff, q; | 616 | unsigned long cutoff, q; |
598 | 617 | ||
599 | dsp->eq_enabled = enabled; | ||
600 | |||
601 | /* Adjust setting pointer to the band we actually want to change */ | 618 | /* Adjust setting pointer to the band we actually want to change */ |
602 | setting = &global_settings.eq_band0_cutoff + (band * 3); | 619 | setting = &global_settings.eq_band0_cutoff + (band * 3); |
603 | 620 | ||
@@ -640,7 +657,7 @@ static void eq_process(int32_t **x, unsigned num) | |||
640 | int i; | 657 | int i; |
641 | unsigned int channels = dsp->stereo_mode != STEREO_MONO ? 2 : 1; | 658 | unsigned int channels = dsp->stereo_mode != STEREO_MONO ? 2 : 1; |
642 | unsigned shift; | 659 | unsigned shift; |
643 | 660 | ||
644 | /* filter configuration currently is 1 low shelf filter, 3 band peaking | 661 | /* filter configuration currently is 1 low shelf filter, 3 band peaking |
645 | filters and 1 high shelf filter, in that order. we need to know this | 662 | filters and 1 high shelf filter, in that order. we need to know this |
646 | so we can choose the correct shift factor. | 663 | so we can choose the correct shift factor. |
@@ -662,39 +679,51 @@ static void eq_process(int32_t **x, unsigned num) | |||
662 | */ | 679 | */ |
663 | static void apply_gain(int32_t* _src[], int _count) | 680 | static void apply_gain(int32_t* _src[], int _count) |
664 | { | 681 | { |
665 | struct dsp_config *my_dsp = dsp; | 682 | int32_t** src = _src; |
666 | if (my_dsp->replaygain) | 683 | int count = _count; |
684 | int32_t* s0 = src[0]; | ||
685 | int32_t* s1 = src[1]; | ||
686 | long gain = 0; | ||
687 | int32_t s; | ||
688 | int i; | ||
689 | int32_t *d; | ||
690 | |||
691 | if (dsp->replaygain) | ||
667 | { | 692 | { |
668 | int32_t** src = _src; | 693 | gain = dsp->replaygain; |
669 | int count = _count; | 694 | } |
670 | int32_t* s0 = src[0]; | ||
671 | int32_t* s1 = src[1]; | ||
672 | long gain = my_dsp->replaygain; | ||
673 | int32_t s; | ||
674 | int i; | ||
675 | int32_t *d; | ||
676 | 695 | ||
677 | if (s0 != s1) | 696 | if (dsp->eq_enabled) |
678 | { | 697 | { |
679 | d = &sample_buf[SAMPLE_BUF_SIZE / 2]; | 698 | gain += dsp->eq_precut; /* FIXME: This isn't that easy right? */ |
680 | src[1] = d; | 699 | } |
681 | s = *s1++; | ||
682 | 700 | ||
683 | for (i = 0; i < count; i++) | 701 | /* Don't bother if the gain is zero */ |
684 | FRACMUL_8_LOOP(s, gain, s1, d); | 702 | if (gain == 0) |
685 | } | 703 | { |
686 | else | 704 | return; |
687 | { | 705 | } |
688 | src[1] = &sample_buf[0]; | ||
689 | } | ||
690 | 706 | ||
691 | d = &sample_buf[0]; | 707 | if (s0 != s1) |
692 | src[0] = d; | 708 | { |
693 | s = *s0++; | 709 | d = &sample_buf[SAMPLE_BUF_SIZE / 2]; |
710 | src[1] = d; | ||
711 | s = *s1++; | ||
694 | 712 | ||
695 | for (i = 0; i < count; i++) | 713 | for (i = 0; i < count; i++) |
696 | FRACMUL_8_LOOP(s, gain, s0, d); | 714 | FRACMUL_8_LOOP(s, gain, s1, d); |
697 | } | 715 | } |
716 | else | ||
717 | { | ||
718 | src[1] = &sample_buf[0]; | ||
719 | } | ||
720 | |||
721 | d = &sample_buf[0]; | ||
722 | src[0] = d; | ||
723 | s = *s0++; | ||
724 | |||
725 | for (i = 0; i < count; i++) | ||
726 | FRACMUL_8_LOOP(s, gain, s0, d); | ||
698 | } | 727 | } |
699 | 728 | ||
700 | void channels_set(int value) | 729 | void channels_set(int value) |
@@ -815,7 +844,7 @@ long dsp_process(char* dst, const char* src[], long size) | |||
815 | unsigned long old_macsr = coldfire_get_macsr(); | 844 | unsigned long old_macsr = coldfire_get_macsr(); |
816 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); | 845 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); |
817 | #endif | 846 | #endif |
818 | 847 | ||
819 | dsp = &dsp_conf[current_codec]; | 848 | dsp = &dsp_conf[current_codec]; |
820 | 849 | ||
821 | factor = (dsp->stereo_mode != STEREO_MONO) ? 2 : 1; | 850 | factor = (dsp->stereo_mode != STEREO_MONO) ? 2 : 1; |