From 626be18da0bd3774164ef85d21268e89fd7aa682 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 13 Dec 2022 18:15:07 -0500 Subject: [PATCH] [Bug Fix] haas surround use delay_ms instead of index surround_strength this appears to be an old bug rather than using an index use delay_ms directly Change-Id: Ia4d0bf8eb8030d6ded08354abc31cc7ddefdda99 --- lib/rbcodec/dsp/surround.c | 55 ++++++++++++++++---------------------- lib/rbcodec/dsp/surround.h | 2 +- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/lib/rbcodec/dsp/surround.c b/lib/rbcodec/dsp/surround.c index 986d81ae6f..9a1f7be8b6 100644 --- a/lib/rbcodec/dsp/surround.c +++ b/lib/rbcodec/dsp/surround.c @@ -30,13 +30,16 @@ static int surround_balance = 0; static bool surround_side_only = false; static int surround_mix = 100; -static int surround_strength = 0; +static int surround_delay_ms = 0; /*1 sample ~ 11ns */ -#define DLY_5MS 454 -#define DLY_8MS 727 -#define DLY_10MS 909 -#define DLY_15MS 1363 -#define DLY_30MS 2727 +#define DLY_1US 90900 +#define DLY_5MS ((DLY_1US * 5)/1000) /*(454)*/ +/* No longer needed but kept for reference */ +/*#define DLY_8MS 727*/ +/*#define DLY_10MS 909*/ +/*#define DLY_15MS 1363*/ +#define DLY_30MS ((DLY_1US * 30)/1000) /*(2727)*/ +#define MIN_DLY DLY_5MS #define MAX_DLY DLY_30MS #define B0_DLY (MAX_DLY/8 + 1) @@ -120,48 +123,36 @@ void dsp_surround_set_cutoff(int frq_l, int frq_h) surround_update_filter(dsp_get_output_frequency(dsp)); } -static void surround_set_stepsize(int surround_strength) +static void surround_set_delay(int surround_delay_ms) { if (handle >= 0) dsp_surround_flush(); - switch(surround_strength) - { - case 1: - dly_size = DLY_5MS; - break; - case 2: - dly_size = DLY_8MS; - break; - case 3: - dly_size = DLY_10MS; - break; - case 4: - dly_size = DLY_15MS; - break; - case 5: - dly_size = DLY_30MS; - break; - } + dly_size = ((DLY_1US * surround_delay_ms) /1000); + + if (dly_size < MIN_DLY) + dly_size = MIN_DLY; + else if (dly_size > MAX_DLY) + dly_size = MAX_DLY; } -void dsp_surround_enable(int var) +void dsp_surround_enable(int delay_ms) { - if (var == surround_strength) + if (delay_ms == surround_delay_ms) return; /* No setting change */ - surround_strength = var; + surround_delay_ms = delay_ms; struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO); bool was_enabled = dsp_proc_enabled(dsp, DSP_PROC_SURROUND); - bool now_enabled = var > 0; + bool now_enabled = delay_ms > 0; + + if (now_enabled) + surround_set_delay(delay_ms); if (was_enabled == now_enabled) return; /* No change in enabled status */ - if (now_enabled) - surround_set_stepsize(var); - /* If changing status, enable or disable it; if already enabled push additional DSP_PROC_INIT messages with value = 1 to force-update the filters */ diff --git a/lib/rbcodec/dsp/surround.h b/lib/rbcodec/dsp/surround.h index 1683367865..7835f569b6 100644 --- a/lib/rbcodec/dsp/surround.h +++ b/lib/rbcodec/dsp/surround.h @@ -23,7 +23,7 @@ #include void dsp_surround_enable(int var); -void dsp_surround_set_balance(int var); +void dsp_surround_set_balance(int delay_ms); void dsp_surround_set_cutoff(int frq_l, int frq_h); void dsp_surround_side_only(bool var); void dsp_surround_mix(int var);