summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2006-02-26 22:42:23 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2006-02-26 22:42:23 +0000
commita6b913fdfbbfb16cdfa0f6f3597bd6ca6e02ebde (patch)
tree25b125f2572840c5f6b8b23fe715b504b7d40951
parent62f55b82098098be98f24a2da0c2bd117f814720 (diff)
downloadrockbox-a6b913fdfbbfb16cdfa0f6f3597bd6ca6e02ebde.tar.gz
rockbox-a6b913fdfbbfb16cdfa0f6f3597bd6ca6e02ebde.zip
Store recorded peak values in short; this should fix an issue where clipping wasn't always detected. Also removed an obsolete function.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8852 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/pcm_record.c42
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
68static volatile bool init_done, close_done, record_done, stop_done, pause_done, resume_done, new_file_done; 68static volatile bool init_done, close_done, record_done, stop_done, pause_done, resume_done, new_file_done;
69 69
70static int peak_left, peak_right; 70static 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 */
356void pcm_rec_get_peaks(int *left, int *right) 358void 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
371static 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 *