diff options
-rw-r--r-- | firmware/pcm_record.c | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c index 511b95e180..7eadfb0436 100644 --- a/firmware/pcm_record.c +++ b/firmware/pcm_record.c | |||
@@ -67,7 +67,7 @@ static char recording_filename[MAX_PATH]; | |||
67 | 67 | ||
68 | static volatile bool init_done, close_done, record_done, stop_done, pause_done, resume_done, new_file_done; | 68 | static volatile bool init_done, close_done, record_done, stop_done, pause_done, resume_done, new_file_done; |
69 | 69 | ||
70 | static int peak_left, peak_right; | 70 | static short peak_left, peak_right; |
71 | 71 | ||
72 | /***************************************************************************/ | 72 | /***************************************************************************/ |
73 | 73 | ||
@@ -353,52 +353,20 @@ void audio_resume_recording(void) | |||
353 | wake_up_thread(); | 353 | wake_up_thread(); |
354 | } | 354 | } |
355 | 355 | ||
356 | /* return peaks as int, so convert from short first | ||
357 | note that peak values are always positive */ | ||
356 | void pcm_rec_get_peaks(int *left, int *right) | 358 | void pcm_rec_get_peaks(int *left, int *right) |
357 | { | 359 | { |
358 | if (left) | 360 | if (left) |
359 | *left = peak_left; | 361 | *left = (int)peak_left; |
360 | if (right) | 362 | if (right) |
361 | *right = peak_right; | 363 | *right = (int)peak_right; |
362 | } | 364 | } |
363 | 365 | ||
364 | /***************************************************************************/ | 366 | /***************************************************************************/ |
365 | /* Functions that executes in the context of pcmrec_thread */ | 367 | /* Functions that executes in the context of pcmrec_thread */ |
366 | /***************************************************************************/ | 368 | /***************************************************************************/ |
367 | 369 | ||
368 | /* Skip PEAK_STRIDE sample-pairs for each compare | ||
369 | #define PEAK_STRIDE 3 | ||
370 | |||
371 | static void pcmrec_find_peaks(int chunk, int* peak_l, int* peak_r) | ||
372 | { | ||
373 | short *ptr, value; | ||
374 | int j; | ||
375 | |||
376 | if(!peak_l || ! peak_r) return; | ||
377 | |||
378 | ptr = GET_CHUNK(chunk); | ||
379 | |||
380 | *peak_l = 0; | ||
381 | *peak_r = 0; | ||
382 | |||
383 | for (j=0; j<CHUNK_SIZE/4; j+=PEAK_STRIDE+1) | ||
384 | { | ||
385 | if ((value = ptr[0]) > *peak_l) | ||
386 | *peak_l = value; | ||
387 | else if (-value > *peak_l) | ||
388 | *peak_l = -value; | ||
389 | ptr++; | ||
390 | |||
391 | if ((value = ptr[0]) > *peak_r) | ||
392 | *peak_r = value; | ||
393 | else if (-value > *peak_r) | ||
394 | *peak_r = -value; | ||
395 | ptr++; | ||
396 | |||
397 | ptr += PEAK_STRIDE * 2; | ||
398 | } | ||
399 | } | ||
400 | */ | ||
401 | |||
402 | /** | 370 | /** |
403 | * Process the chunks using read_index and write_index. | 371 | * Process the chunks using read_index and write_index. |
404 | * | 372 | * |