From a6b913fdfbbfb16cdfa0f6f3597bd6ca6e02ebde Mon Sep 17 00:00:00 2001 From: Peter D'Hoye Date: Sun, 26 Feb 2006 22:42:23 +0000 Subject: 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 --- firmware/pcm_record.c | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) (limited to 'firmware') 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]; static volatile bool init_done, close_done, record_done, stop_done, pause_done, resume_done, new_file_done; -static int peak_left, peak_right; +static short peak_left, peak_right; /***************************************************************************/ @@ -353,52 +353,20 @@ void audio_resume_recording(void) wake_up_thread(); } +/* return peaks as int, so convert from short first + note that peak values are always positive */ void pcm_rec_get_peaks(int *left, int *right) { if (left) - *left = peak_left; + *left = (int)peak_left; if (right) - *right = peak_right; + *right = (int)peak_right; } /***************************************************************************/ /* Functions that executes in the context of pcmrec_thread */ /***************************************************************************/ -/* Skip PEAK_STRIDE sample-pairs for each compare -#define PEAK_STRIDE 3 - -static void pcmrec_find_peaks(int chunk, int* peak_l, int* peak_r) -{ - short *ptr, value; - int j; - - if(!peak_l || ! peak_r) return; - - ptr = GET_CHUNK(chunk); - - *peak_l = 0; - *peak_r = 0; - - for (j=0; j *peak_l) - *peak_l = value; - else if (-value > *peak_l) - *peak_l = -value; - ptr++; - - if ((value = ptr[0]) > *peak_r) - *peak_r = value; - else if (-value > *peak_r) - *peak_r = -value; - ptr++; - - ptr += PEAK_STRIDE * 2; - } -} -*/ - /** * Process the chunks using read_index and write_index. * -- cgit v1.2.3