diff options
-rw-r--r-- | lib/rbcodec/dsp/surround.c | 55 | ||||
-rw-r--r-- | 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 @@ | |||
30 | static int surround_balance = 0; | 30 | static int surround_balance = 0; |
31 | static bool surround_side_only = false; | 31 | static bool surround_side_only = false; |
32 | static int surround_mix = 100; | 32 | static int surround_mix = 100; |
33 | static int surround_strength = 0; | 33 | static int surround_delay_ms = 0; |
34 | /*1 sample ~ 11ns */ | 34 | /*1 sample ~ 11ns */ |
35 | #define DLY_5MS 454 | 35 | #define DLY_1US 90900 |
36 | #define DLY_8MS 727 | 36 | #define DLY_5MS ((DLY_1US * 5)/1000) /*(454)*/ |
37 | #define DLY_10MS 909 | 37 | /* No longer needed but kept for reference */ |
38 | #define DLY_15MS 1363 | 38 | /*#define DLY_8MS 727*/ |
39 | #define DLY_30MS 2727 | 39 | /*#define DLY_10MS 909*/ |
40 | /*#define DLY_15MS 1363*/ | ||
41 | #define DLY_30MS ((DLY_1US * 30)/1000) /*(2727)*/ | ||
42 | #define MIN_DLY DLY_5MS | ||
40 | #define MAX_DLY DLY_30MS | 43 | #define MAX_DLY DLY_30MS |
41 | 44 | ||
42 | #define B0_DLY (MAX_DLY/8 + 1) | 45 | #define B0_DLY (MAX_DLY/8 + 1) |
@@ -120,48 +123,36 @@ void dsp_surround_set_cutoff(int frq_l, int frq_h) | |||
120 | surround_update_filter(dsp_get_output_frequency(dsp)); | 123 | surround_update_filter(dsp_get_output_frequency(dsp)); |
121 | } | 124 | } |
122 | 125 | ||
123 | static void surround_set_stepsize(int surround_strength) | 126 | static void surround_set_delay(int surround_delay_ms) |
124 | { | 127 | { |
125 | if (handle >= 0) | 128 | if (handle >= 0) |
126 | dsp_surround_flush(); | 129 | dsp_surround_flush(); |
127 | 130 | ||
128 | switch(surround_strength) | 131 | dly_size = ((DLY_1US * surround_delay_ms) /1000); |
129 | { | 132 | |
130 | case 1: | 133 | if (dly_size < MIN_DLY) |
131 | dly_size = DLY_5MS; | 134 | dly_size = MIN_DLY; |
132 | break; | 135 | else if (dly_size > MAX_DLY) |
133 | case 2: | 136 | dly_size = MAX_DLY; |
134 | dly_size = DLY_8MS; | ||
135 | break; | ||
136 | case 3: | ||
137 | dly_size = DLY_10MS; | ||
138 | break; | ||
139 | case 4: | ||
140 | dly_size = DLY_15MS; | ||
141 | break; | ||
142 | case 5: | ||
143 | dly_size = DLY_30MS; | ||
144 | break; | ||
145 | } | ||
146 | } | 137 | } |
147 | 138 | ||
148 | void dsp_surround_enable(int var) | 139 | void dsp_surround_enable(int delay_ms) |
149 | { | 140 | { |
150 | if (var == surround_strength) | 141 | if (delay_ms == surround_delay_ms) |
151 | return; /* No setting change */ | 142 | return; /* No setting change */ |
152 | 143 | ||
153 | surround_strength = var; | 144 | surround_delay_ms = delay_ms; |
154 | 145 | ||
155 | struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO); | 146 | struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO); |
156 | bool was_enabled = dsp_proc_enabled(dsp, DSP_PROC_SURROUND); | 147 | bool was_enabled = dsp_proc_enabled(dsp, DSP_PROC_SURROUND); |
157 | bool now_enabled = var > 0; | 148 | bool now_enabled = delay_ms > 0; |
149 | |||
150 | if (now_enabled) | ||
151 | surround_set_delay(delay_ms); | ||
158 | 152 | ||
159 | if (was_enabled == now_enabled) | 153 | if (was_enabled == now_enabled) |
160 | return; /* No change in enabled status */ | 154 | return; /* No change in enabled status */ |
161 | 155 | ||
162 | if (now_enabled) | ||
163 | surround_set_stepsize(var); | ||
164 | |||
165 | /* If changing status, enable or disable it; if already enabled push | 156 | /* If changing status, enable or disable it; if already enabled push |
166 | additional DSP_PROC_INIT messages with value = 1 to force-update the | 157 | additional DSP_PROC_INIT messages with value = 1 to force-update the |
167 | filters */ | 158 | 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 @@ | |||
23 | 23 | ||
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | void dsp_surround_enable(int var); | 25 | void dsp_surround_enable(int var); |
26 | void dsp_surround_set_balance(int var); | 26 | void dsp_surround_set_balance(int delay_ms); |
27 | void dsp_surround_set_cutoff(int frq_l, int frq_h); | 27 | void dsp_surround_set_cutoff(int frq_l, int frq_h); |
28 | void dsp_surround_side_only(bool var); | 28 | void dsp_surround_side_only(bool var); |
29 | void dsp_surround_mix(int var); | 29 | void dsp_surround_mix(int var); |