diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dsp.c | 9 | ||||
-rw-r--r-- | apps/tdspeed.c | 23 |
2 files changed, 18 insertions, 14 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index 496e333bc5..a68b8615f8 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -161,7 +161,6 @@ struct dsp_config | |||
161 | int sample_depth; | 161 | int sample_depth; |
162 | int sample_bytes; | 162 | int sample_bytes; |
163 | int stereo_mode; | 163 | int stereo_mode; |
164 | bool tdspeed_enabled; /* User has enabled timestretch */ | ||
165 | int tdspeed_percent; /* Speed % */ | 164 | int tdspeed_percent; /* Speed % */ |
166 | bool tdspeed_active; /* Timestretch is in use */ | 165 | bool tdspeed_active; /* Timestretch is in use */ |
167 | int frac_bits; | 166 | int frac_bits; |
@@ -266,12 +265,12 @@ void sound_set_pitch(int permille) | |||
266 | AUDIO_DSP.codec_frequency); | 265 | AUDIO_DSP.codec_frequency); |
267 | } | 266 | } |
268 | 267 | ||
269 | void tdspeed_setup(struct dsp_config *dspc) | 268 | static void tdspeed_setup(struct dsp_config *dspc) |
270 | { | 269 | { |
271 | dspc->tdspeed_active = false; | 270 | dspc->tdspeed_active = false; |
272 | if (dspc == &AUDIO_DSP) | 271 | if (dspc == &AUDIO_DSP) |
273 | { | 272 | { |
274 | if (!dspc->tdspeed_enabled) | 273 | if(!dsp_timestretch_enabled()) |
275 | return; | 274 | return; |
276 | if (dspc->tdspeed_percent == 0) | 275 | if (dspc->tdspeed_percent == 0) |
277 | dspc->tdspeed_percent = 100; | 276 | dspc->tdspeed_percent = 100; |
@@ -304,7 +303,7 @@ void dsp_timestretch_enable(bool enable) | |||
304 | if (big_sample_buf_count < 0) | 303 | if (big_sample_buf_count < 0) |
305 | big_sample_buf_count = 0; | 304 | big_sample_buf_count = 0; |
306 | } | 305 | } |
307 | AUDIO_DSP.tdspeed_enabled = enable; | 306 | global_settings.timestretch_enabled = enable; |
308 | tdspeed_setup(&AUDIO_DSP); | 307 | tdspeed_setup(&AUDIO_DSP); |
309 | } | 308 | } |
310 | 309 | ||
@@ -321,7 +320,7 @@ int dsp_get_timestretch() | |||
321 | 320 | ||
322 | bool dsp_timestretch_enabled() | 321 | bool dsp_timestretch_enabled() |
323 | { | 322 | { |
324 | return (AUDIO_DSP.tdspeed_enabled && big_sample_buf_count > 0); | 323 | return (global_settings.timestretch_enabled && big_sample_buf_count > 0); |
325 | } | 324 | } |
326 | 325 | ||
327 | /* Convert count samples to the internal format, if needed. Updates src | 326 | /* Convert count samples to the internal format, if needed. Updates src |
diff --git a/apps/tdspeed.c b/apps/tdspeed.c index f365e95e03..501c1d8aa9 100644 --- a/apps/tdspeed.c +++ b/apps/tdspeed.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "debug.h" | 28 | #include "debug.h" |
29 | #include "system.h" | 29 | #include "system.h" |
30 | #include "tdspeed.h" | 30 | #include "tdspeed.h" |
31 | #include "settings.h" | ||
31 | 32 | ||
32 | #define assert(cond) | 33 | #define assert(cond) |
33 | 34 | ||
@@ -56,15 +57,18 @@ static int32_t *outbuf[2] = { NULL, NULL }; | |||
56 | 57 | ||
57 | void tdspeed_init() | 58 | void tdspeed_init() |
58 | { | 59 | { |
59 | /* Allocate buffers */ | 60 | if (global_settings.timestretch_enabled) |
60 | if (overlap_buffer[0] == NULL) | 61 | { |
61 | overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); | 62 | /* Allocate buffers */ |
62 | if (overlap_buffer[1] == NULL) | 63 | if (overlap_buffer[0] == NULL) |
63 | overlap_buffer[1] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); | 64 | overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); |
64 | if (outbuf[0] == NULL) | 65 | if (overlap_buffer[1] == NULL) |
65 | outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); | 66 | overlap_buffer[1] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); |
66 | if (outbuf[1] == NULL) | 67 | if (outbuf[0] == NULL) |
67 | outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); | 68 | outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); |
69 | if (outbuf[1] == NULL) | ||
70 | outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); | ||
71 | } | ||
68 | } | 72 | } |
69 | 73 | ||
70 | 74 | ||
@@ -327,3 +331,4 @@ int tdspeed_doit(int32_t *src[], int count) | |||
327 | src[1] = outbuf[1]; | 331 | src[1] = outbuf[1]; |
328 | return count; | 332 | return count; |
329 | } | 333 | } |
334 | |||