summaryrefslogtreecommitdiff
path: root/apps/dsp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dsp.c')
-rw-r--r--apps/dsp.c47
1 files changed, 17 insertions, 30 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index b32b641693..496e333bc5 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -245,20 +245,6 @@ static int32_t *resample_buf;
245#define RESAMPLE_BUF_LEFT_CHANNEL 0 245#define RESAMPLE_BUF_LEFT_CHANNEL 0
246#define RESAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2 * RESAMPLE_RATIO) 246#define RESAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2 * RESAMPLE_RATIO)
247 247
248#if 0
249/* Clip sample to arbitrary limits where range > 0 and min + range = max */
250static inline long clip_sample(int32_t sample, int32_t min, int32_t range)
251{
252 if ((uint32_t)(sample - min) > (uint32_t)range)
253 {
254 int32_t c = min;
255 if (sample > min)
256 c += range;
257 sample = c;
258 }
259 return sample;
260}
261#endif
262 248
263/* Clip sample to signed 16 bit range */ 249/* Clip sample to signed 16 bit range */
264static inline int32_t clip_sample_16(int32_t sample) 250static inline int32_t clip_sample_16(int32_t sample)
@@ -282,14 +268,14 @@ void sound_set_pitch(int permille)
282 268
283void tdspeed_setup(struct dsp_config *dspc) 269void tdspeed_setup(struct dsp_config *dspc)
284{ 270{
271 dspc->tdspeed_active = false;
285 if (dspc == &AUDIO_DSP) 272 if (dspc == &AUDIO_DSP)
286 { 273 {
287 dspc->tdspeed_active = false;
288 if (!dspc->tdspeed_enabled) 274 if (!dspc->tdspeed_enabled)
289 return; 275 return;
290 if (dspc->tdspeed_percent == 0) 276 if (dspc->tdspeed_percent == 0)
291 dspc->tdspeed_percent = 100; 277 dspc->tdspeed_percent = 100;
292 if (!tdspeed_init( 278 if (!tdspeed_config(
293 dspc->codec_frequency == 0 ? NATIVE_FREQUENCY : dspc->codec_frequency, 279 dspc->codec_frequency == 0 ? NATIVE_FREQUENCY : dspc->codec_frequency,
294 dspc->stereo_mode != STEREO_MONO, 280 dspc->stereo_mode != STEREO_MONO,
295 dspc->tdspeed_percent)) 281 dspc->tdspeed_percent))
@@ -1277,19 +1263,7 @@ int dsp_process(struct dsp_config *dsp, char *dst, const char *src[], int count)
1277/* dsp_input_size MUST be called afterwards */ 1263/* dsp_input_size MUST be called afterwards */
1278int dsp_output_count(struct dsp_config *dsp, int count) 1264int dsp_output_count(struct dsp_config *dsp, int count)
1279{ 1265{
1280 if(!dsp->tdspeed_active) 1266 if (dsp->tdspeed_active)
1281 {
1282 sample_buf = small_sample_buf;
1283 resample_buf = small_resample_buf;
1284 sample_buf_count = SMALL_SAMPLE_BUF_COUNT;
1285 }
1286 else
1287 {
1288 sample_buf = big_sample_buf;
1289 sample_buf_count = big_sample_buf_count;
1290 resample_buf = big_resample_buf;
1291 }
1292 if(dsp->tdspeed_active)
1293 count = tdspeed_est_output_size(); 1267 count = tdspeed_est_output_size();
1294 if (dsp->resample) 1268 if (dsp->resample)
1295 { 1269 {
@@ -1324,7 +1298,7 @@ int dsp_input_count(struct dsp_config *dsp, int count)
1324 dsp->data.resample_data.delta) >> 16); 1298 dsp->data.resample_data.delta) >> 16);
1325 } 1299 }
1326 1300
1327 if(dsp->tdspeed_active) 1301 if (dsp->tdspeed_active)
1328 count = tdspeed_est_input_size(count); 1302 count = tdspeed_est_input_size(count);
1329 1303
1330 return count; 1304 return count;
@@ -1464,6 +1438,19 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
1464 return 0; 1438 return 0;
1465 } 1439 }
1466 1440
1441 if (!dsp->tdspeed_active)
1442 {
1443 sample_buf = small_sample_buf;
1444 resample_buf = small_resample_buf;
1445 sample_buf_count = SMALL_SAMPLE_BUF_COUNT;
1446 }
1447 else
1448 {
1449 sample_buf = big_sample_buf;
1450 sample_buf_count = big_sample_buf_count;
1451 resample_buf = big_resample_buf;
1452 }
1453
1467 return 1; 1454 return 1;
1468} 1455}
1469 1456