summaryrefslogtreecommitdiffstats
path: root/lib/rbcodec/dsp/surround.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/dsp/surround.c')
-rw-r--r--lib/rbcodec/dsp/surround.c55
1 files changed, 23 insertions, 32 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 */