summaryrefslogtreecommitdiff
path: root/apps/dsp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dsp.c')
-rw-r--r--apps/dsp.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index ca494e553f..9e410f879a 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -787,13 +787,27 @@ void dsp_set_crossfeed_direct_gain(int gain)
787 crossfeed_data.gain = 0x7fffffff; 787 crossfeed_data.gain = 0x7fffffff;
788} 788}
789 789
790/* Both gains should be below 0 dB (when inverted) */
790void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain, long cutoff) 791void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain, long cutoff)
791{ 792{
792 long g1 = get_replaygain_int(lf_gain * -10) << 3; 793 int32_t *c = crossfeed_data.coefs;
793 long g2 = get_replaygain_int(hf_gain * -10) << 3; 794 long scaler = get_replaygain_int(lf_gain * -10) << 7;
794 795
795 filter_shelf_coefs(0xffffffff/NATIVE_FREQUENCY*cutoff, g1, g2, 796 cutoff = 0xffffffff/NATIVE_FREQUENCY*cutoff;
796 crossfeed_data.coefs); 797 hf_gain -= lf_gain;
798 /* Divide cutoff by sqrt(10^(-hf_gain/20)) to place cutoff at the -3 dB
799 * point instead of shelf midpoint. This is for compatibility with the old
800 * crossfeed shelf filter and should be removed if crossfeed settings are
801 * ever made incompatible for any other good reason.
802 */
803 cutoff = DIV64(cutoff, get_replaygain_int(-hf_gain*5), 24);
804 filter_shelf_coefs(cutoff, -hf_gain, false, c);
805 /* Scale coefs by LF gain and shift them to s0.31 format. We have no gains
806 * over 1 and can do this safely
807 */
808 c[0] = FRACMUL_SHL(c[0], scaler, 4);
809 c[1] = FRACMUL_SHL(c[1], scaler, 4);
810 c[2] <<= 4;
797} 811}
798 812
799/* Combine all gains to a global gain. */ 813/* Combine all gains to a global gain. */