summaryrefslogtreecommitdiff
path: root/apps/recorder/peakmeter.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2007-08-25 15:53:54 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2007-08-25 15:53:54 +0000
commit583f186ce488ed52eb0c663a8263f4052e19063d (patch)
treed5f11cf489202737c93dafd52f9f65fb09f6a2b8 /apps/recorder/peakmeter.c
parentcdfb22f9dfdbae2fdc6902f895fd89060abaa38b (diff)
downloadrockbox-583f186ce488ed52eb0c663a8263f4052e19063d.tar.gz
rockbox-583f186ce488ed52eb0c663a8263f4052e19063d.zip
Implement FS #2976: Clip Counter for recording screen. If enabled in peak meter settings, it shows the number of times clipping occurred (clip indicator going on). Count is reset on recording start and only counts during actual recording. Stays on screen when stopping or pauzing. Also fix a drawing bug when peakmeters start at a non-zero x offset.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14455 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/peakmeter.c')
-rw-r--r--apps/recorder/peakmeter.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index 7d97bd3b02..f3f5d67c9c 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -16,6 +16,9 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#ifdef SIMULATOR
20#include <stdlib.h> /* sim uses rand for peakmeter simulation */
21#endif
19#include "config.h" 22#include "config.h"
20#include "mas.h" 23#include "mas.h"
21#include "thread.h" 24#include "thread.h"
@@ -47,7 +50,6 @@
47#endif 50#endif
48 51
49static bool pm_playback = true; /* selects between playback and recording peaks */ 52static bool pm_playback = true; /* selects between playback and recording peaks */
50
51#endif 53#endif
52 54
53static struct meter_scales scales[NB_SCREENS]; 55static struct meter_scales scales[NB_SCREENS];
@@ -74,6 +76,10 @@ static bool pm_clip_right = false;
74static long pm_clip_timeout_l; /* clip hold timeouts */ 76static long pm_clip_timeout_l; /* clip hold timeouts */
75static long pm_clip_timeout_r; 77static long pm_clip_timeout_r;
76 78
79/* clipping counter (only used for recording) */
80static unsigned int pm_clipcount = 0; /* clipping count */
81static bool pm_clipcount_active = false; /* counting or not */
82
77/* Temporarily en- / disables peak meter. This is especially for external 83/* Temporarily en- / disables peak meter. This is especially for external
78 applications to detect if the peak_meter is in use and needs drawing at all */ 84 applications to detect if the peak_meter is in use and needs drawing at all */
79bool peak_meter_enabled = true; 85bool peak_meter_enabled = true;
@@ -491,6 +497,30 @@ void peak_meter_init_times(int release, int hold, int clip_hold)
491} 497}
492 498
493/** 499/**
500 * Enable/disable clip counting
501 */
502void pm_activate_clipcount(bool active)
503{
504 pm_clipcount_active = active;
505}
506
507/**
508 * Get clipping counter value
509 */
510int pm_get_clipcount(void)
511{
512 return pm_clipcount;
513}
514
515/**
516 * Set clipping counter to zero (typically at start of recording or playback)
517 */
518void pm_reset_clipcount(void)
519{
520 pm_clipcount = 0;
521}
522
523/**
494 * Set the source of the peak meter to playback or to 524 * Set the source of the peak meter to playback or to
495 * record. 525 * record.
496 * @param: bool playback - If true playback peak meter is used. 526 * @param: bool playback - If true playback peak meter is used.
@@ -523,6 +553,7 @@ static void set_trig_status(int new_state)
523 } 553 }
524 } 554 }
525} 555}
556
526#endif 557#endif
527 558
528/** 559/**
@@ -535,6 +566,7 @@ static void set_trig_status(int new_state)
535void peak_meter_peek(void) 566void peak_meter_peek(void)
536{ 567{
537 int left, right; 568 int left, right;
569 bool was_clipping = pm_clip_left || pm_clip_right;
538 /* read current values */ 570 /* read current values */
539#if CONFIG_CODEC == SWCODEC 571#if CONFIG_CODEC == SWCODEC
540 if (pm_playback) 572 if (pm_playback)
@@ -585,6 +617,12 @@ void peak_meter_peek(void)
585 current_tick + clip_time_out[pm_clip_hold]; 617 current_tick + clip_time_out[pm_clip_hold];
586 } 618 }
587 619
620 if(!was_clipping && (pm_clip_left || pm_clip_right))
621 {
622 if(pm_clipcount_active)
623 pm_clipcount++;
624 }
625
588 /* peaks are searched -> we have to find the maximum. When 626 /* peaks are searched -> we have to find the maximum. When
589 many calls of peak_meter_peek the maximum value will be 627 many calls of peak_meter_peek the maximum value will be
590 stored in pm_max_xxx. This maximum is reset by the 628 stored in pm_max_xxx. This maximum is reset by the
@@ -757,6 +795,12 @@ static int peak_meter_read_l(void)
757 /* reset pm_max_left so that subsequent calls of peak_meter_peek don't 795 /* reset pm_max_left so that subsequent calls of peak_meter_peek don't
758 get fooled by an old maximum value */ 796 get fooled by an old maximum value */
759 pm_max_left = pm_cur_left; 797 pm_max_left = pm_cur_left;
798
799#ifdef SIMULATOR
800 srand(current_tick);
801 retval = rand()%MAX_PEAK;
802#endif
803
760 return retval; 804 return retval;
761} 805}
762 806
@@ -782,6 +826,12 @@ static int peak_meter_read_r(void)
782 /* reset pm_max_right so that subsequent calls of peak_meter_peek don't 826 /* reset pm_max_right so that subsequent calls of peak_meter_peek don't
783 get fooled by an old maximum value */ 827 get fooled by an old maximum value */
784 pm_max_right = pm_cur_right; 828 pm_max_right = pm_cur_right;
829
830#ifdef SIMULATOR
831 srand(current_tick);
832 retval = rand()%MAX_PEAK;
833#endif
834
785 return retval; 835 return retval;
786} 836}
787 837
@@ -860,7 +910,7 @@ unsigned short peak_meter_scale_value(unsigned short val, int meterwidth)
860void peak_meter_screen(struct screen *display, int x, int y, int height) 910void peak_meter_screen(struct screen *display, int x, int y, int height)
861{ 911{
862 peak_meter_draw(display, &scales[display->screen_type], x, y, 912 peak_meter_draw(display, &scales[display->screen_type], x, y,
863 display->width, height); 913 display->width - x, height);
864} 914}
865/** 915/**
866 * Draws a peak meter in the specified size at the specified position. 916 * Draws a peak meter in the specified size at the specified position.
@@ -1282,7 +1332,7 @@ int peak_meter_draw_get_btn(int x, int y[], int height, int nb_screens)
1282 for(i = 0; i < nb_screens; i++) 1332 for(i = 0; i < nb_screens; i++)
1283 { 1333 {
1284 peak_meter_screen(&screens[i], x, y[i], height); 1334 peak_meter_screen(&screens[i], x, y[i], height);
1285 screens[i].update_rect(x, y[i], screens[i].width, height); 1335 screens[i].update_rect(x, y[i], screens[i].width - x, height);
1286 } 1336 }
1287 next_refresh += HZ / PEAK_METER_FPS; 1337 next_refresh += HZ / PEAK_METER_FPS;
1288 dopeek = true; 1338 dopeek = true;