[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
This commit is contained in:
William Wilgus 2022-12-13 18:15:07 -05:00 committed by William Wilgus
parent 5903cd4bc8
commit 626be18da0
2 changed files with 24 additions and 33 deletions

View file

@ -30,13 +30,16 @@
static int surround_balance = 0; static int surround_balance = 0;
static bool surround_side_only = false; static bool surround_side_only = false;
static int surround_mix = 100; static int surround_mix = 100;
static int surround_strength = 0; static int surround_delay_ms = 0;
/*1 sample ~ 11ns */ /*1 sample ~ 11ns */
#define DLY_5MS 454 #define DLY_1US 90900
#define DLY_8MS 727 #define DLY_5MS ((DLY_1US * 5)/1000) /*(454)*/
#define DLY_10MS 909 /* No longer needed but kept for reference */
#define DLY_15MS 1363 /*#define DLY_8MS 727*/
#define DLY_30MS 2727 /*#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 MAX_DLY DLY_30MS
#define B0_DLY (MAX_DLY/8 + 1) #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)); 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) if (handle >= 0)
dsp_surround_flush(); dsp_surround_flush();
switch(surround_strength) dly_size = ((DLY_1US * surround_delay_ms) /1000);
{
case 1: if (dly_size < MIN_DLY)
dly_size = DLY_5MS; dly_size = MIN_DLY;
break; else if (dly_size > MAX_DLY)
case 2: dly_size = MAX_DLY;
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;
}
} }
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 */ return; /* No setting change */
surround_strength = var; surround_delay_ms = delay_ms;
struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO); struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO);
bool was_enabled = dsp_proc_enabled(dsp, DSP_PROC_SURROUND); 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) if (was_enabled == now_enabled)
return; /* No change in enabled status */ return; /* No change in enabled status */
if (now_enabled)
surround_set_stepsize(var);
/* If changing status, enable or disable it; if already enabled push /* If changing status, enable or disable it; if already enabled push
additional DSP_PROC_INIT messages with value = 1 to force-update the additional DSP_PROC_INIT messages with value = 1 to force-update the
filters */ filters */

View file

@ -23,7 +23,7 @@
#include <stdbool.h> #include <stdbool.h>
void dsp_surround_enable(int var); 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_set_cutoff(int frq_l, int frq_h);
void dsp_surround_side_only(bool var); void dsp_surround_side_only(bool var);
void dsp_surround_mix(int var); void dsp_surround_mix(int var);