summaryrefslogtreecommitdiff
path: root/apps/dsp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dsp.c')
-rw-r--r--apps/dsp.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index 7292328212..33a54008e2 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -216,7 +216,9 @@ static int treble; /* A/V */
216#endif 216#endif
217 217
218/* Settings applicable to audio codec only */ 218/* Settings applicable to audio codec only */
219#ifdef HAVE_PITCHSCREEN
219static int32_t pitch_ratio = PITCH_SPEED_100; 220static int32_t pitch_ratio = PITCH_SPEED_100;
221#endif
220static int channels_mode; 222static int channels_mode;
221 long dsp_sw_gain; 223 long dsp_sw_gain;
222 long dsp_sw_cross; 224 long dsp_sw_cross;
@@ -240,12 +242,14 @@ static bool crossfeed_enabled;
240 242
241#define RESAMPLE_RATIO 4 /* Enough for 11,025 Hz -> 44,100 Hz */ 243#define RESAMPLE_RATIO 4 /* Enough for 11,025 Hz -> 44,100 Hz */
242 244
245#ifdef HAVE_PITCHSCREEN
243static int32_t small_sample_buf[SMALL_SAMPLE_BUF_COUNT] IBSS_ATTR; 246static int32_t small_sample_buf[SMALL_SAMPLE_BUF_COUNT] IBSS_ATTR;
244static int32_t small_resample_buf[SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO] IBSS_ATTR; 247static int32_t small_resample_buf[SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO] IBSS_ATTR;
245 248
246static int32_t *big_sample_buf = NULL; 249static int32_t *big_sample_buf = NULL;
247static int32_t *big_resample_buf = NULL; 250static int32_t *big_resample_buf = NULL;
248static int big_sample_buf_count = -1; /* -1=unknown, 0=not available */ 251static int big_sample_buf_count = -1; /* -1=unknown, 0=not available */
252#endif
249 253
250static int sample_buf_count; 254static int sample_buf_count;
251static int32_t *sample_buf; 255static int32_t *sample_buf;
@@ -274,6 +278,7 @@ static inline int32_t clip_sample_16(int32_t sample)
274 return sample; 278 return sample;
275} 279}
276 280
281#ifdef HAVE_PITCHSCREEN
277int32_t sound_get_pitch(void) 282int32_t sound_get_pitch(void)
278{ 283{
279 return pitch_ratio; 284 return pitch_ratio;
@@ -347,6 +352,7 @@ bool dsp_timestretch_available()
347{ 352{
348 return (global_settings.timestretch_enabled && big_sample_buf_count > 0); 353 return (global_settings.timestretch_enabled && big_sample_buf_count > 0);
349} 354}
355#endif
350 356
351/* Convert count samples to the internal format, if needed. Updates src 357/* Convert count samples to the internal format, if needed. Updates src
352 * to point past the samples "consumed" and dst is set to point to the 358 * to point past the samples "consumed" and dst is set to point to the
@@ -1225,8 +1231,10 @@ int dsp_process(struct dsp_config *dsp, char *dst, const char *src[], int count)
1225 1231
1226 dsp->input_samples(samples, src, tmp); 1232 dsp->input_samples(samples, src, tmp);
1227 1233
1234#ifdef HAVE_PITCHSCREEN
1228 if (dsp->tdspeed_active) 1235 if (dsp->tdspeed_active)
1229 samples = tdspeed_doit(tmp, samples); 1236 samples = tdspeed_doit(tmp, samples);
1237#endif
1230 1238
1231 int chunk_offset = 0; 1239 int chunk_offset = 0;
1232 while (samples > 0) 1240 while (samples > 0)
@@ -1294,8 +1302,10 @@ int dsp_process(struct dsp_config *dsp, char *dst, const char *src[], int count)
1294/* dsp_input_size MUST be called afterwards */ 1302/* dsp_input_size MUST be called afterwards */
1295int dsp_output_count(struct dsp_config *dsp, int count) 1303int dsp_output_count(struct dsp_config *dsp, int count)
1296{ 1304{
1305#ifdef HAVE_PITCHSCREEN
1297 if (dsp->tdspeed_active) 1306 if (dsp->tdspeed_active)
1298 count = tdspeed_est_output_size(); 1307 count = tdspeed_est_output_size();
1308#endif
1299 if (dsp->resample) 1309 if (dsp->resample)
1300 { 1310 {
1301 count = (int)(((unsigned long)count * NATIVE_FREQUENCY 1311 count = (int)(((unsigned long)count * NATIVE_FREQUENCY
@@ -1329,8 +1339,10 @@ int dsp_input_count(struct dsp_config *dsp, int count)
1329 dsp->data.resample_data.delta) >> 16); 1339 dsp->data.resample_data.delta) >> 16);
1330 } 1340 }
1331 1341
1342#ifdef HAVE_PITCHSCREEN
1332 if (dsp->tdspeed_active) 1343 if (dsp->tdspeed_active)
1333 count = tdspeed_est_input_size(count); 1344 count = tdspeed_est_input_size(count);
1345#endif
1334 1346
1335 return count; 1347 return count;
1336} 1348}
@@ -1373,13 +1385,17 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
1373 if we're called from the main audio thread. Voice UI thread should 1385 if we're called from the main audio thread. Voice UI thread should
1374 not need this feature. 1386 not need this feature.
1375 */ 1387 */
1388#ifdef HAVE_PITCHSCREEN
1376 if (dsp == &AUDIO_DSP) 1389 if (dsp == &AUDIO_DSP)
1377 dsp->frequency = pitch_ratio * dsp->codec_frequency / PITCH_SPEED_100; 1390 dsp->frequency = pitch_ratio * dsp->codec_frequency / PITCH_SPEED_100;
1378 else 1391 else
1392#endif
1379 dsp->frequency = dsp->codec_frequency; 1393 dsp->frequency = dsp->codec_frequency;
1380 1394
1381 resampler_new_delta(dsp); 1395 resampler_new_delta(dsp);
1396#ifdef HAVE_PITCHSCREEN
1382 tdspeed_setup(dsp); 1397 tdspeed_setup(dsp);
1398#endif
1383 break; 1399 break;
1384 1400
1385 case DSP_SET_SAMPLE_DEPTH: 1401 case DSP_SET_SAMPLE_DEPTH:
@@ -1409,7 +1425,9 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
1409 dsp->stereo_mode = value; 1425 dsp->stereo_mode = value;
1410 dsp->data.num_channels = value == STEREO_MONO ? 1 : 2; 1426 dsp->data.num_channels = value == STEREO_MONO ? 1 : 2;
1411 dsp_update_functions(dsp); 1427 dsp_update_functions(dsp);
1428#ifdef HAVE_PITCHSCREEN
1412 tdspeed_setup(dsp); 1429 tdspeed_setup(dsp);
1430#endif
1413 break; 1431 break;
1414 1432
1415 case DSP_RESET: 1433 case DSP_RESET:
@@ -1434,7 +1452,9 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
1434 1452
1435 dsp_update_functions(dsp); 1453 dsp_update_functions(dsp);
1436 resampler_new_delta(dsp); 1454 resampler_new_delta(dsp);
1455#ifdef HAVE_PITCHSCREEN
1437 tdspeed_setup(dsp); 1456 tdspeed_setup(dsp);
1457#endif
1438 if (dsp == &AUDIO_DSP) 1458 if (dsp == &AUDIO_DSP)
1439 release_gain = UNITY; 1459 release_gain = UNITY;
1440 break; 1460 break;
@@ -1444,7 +1464,9 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
1444 sizeof (dsp->data.resample_data)); 1464 sizeof (dsp->data.resample_data));
1445 resampler_new_delta(dsp); 1465 resampler_new_delta(dsp);
1446 dither_init(dsp); 1466 dither_init(dsp);
1467#ifdef HAVE_PITCHSCREEN
1447 tdspeed_setup(dsp); 1468 tdspeed_setup(dsp);
1469#endif
1448 if (dsp == &AUDIO_DSP) 1470 if (dsp == &AUDIO_DSP)
1449 release_gain = UNITY; 1471 release_gain = UNITY;
1450 break; 1472 break;