From 82f4c60db4f16642c1ee9f461d7eb060c11a49d8 Mon Sep 17 00:00:00 2001 From: Peter D'Hoye Date: Sun, 5 Jun 2011 12:36:27 +0000 Subject: [PATCH] Make the histogram code usable for playback as well. Move the recording histogram code to peakmeter, rename it to remove the recording reference, and rename anything referring to it as well. Change the drawing code so there are more options to position them. This may change your histogram settings, so check after upgrading. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29969 a1c6a512-1295-4272-9138-f99709370657 --- apps/features.txt | 4 +- apps/lang/catala.lang | 8 +- apps/lang/czech.lang | 8 +- apps/lang/dansk.lang | 8 +- apps/lang/deutsch.lang | 8 +- apps/lang/english.lang | 8 +- apps/lang/espanol.lang | 8 +- apps/lang/francais.lang | 8 +- apps/lang/hebrew.lang | 8 +- apps/lang/hrvatski.lang | 8 +- apps/lang/italiano.lang | 8 +- apps/lang/japanese.lang | 8 +- apps/lang/nederlands.lang | 8 +- apps/lang/polski.lang | 8 +- apps/lang/portugues-brasileiro.lang | 8 +- apps/lang/portugues.lang | 8 +- apps/lang/russian.lang | 8 +- apps/lang/slovak.lang | 8 +- apps/lang/slovenscina.lang | 8 +- apps/lang/srpski.lang | 8 +- apps/lang/svenska.lang | 8 +- apps/lang/tagalog.lang | 8 +- apps/lang/thai.lang | 8 +- apps/menus/display_menu.c | 27 ++++++ apps/menus/recording_menu.c | 23 ----- apps/recorder/peakmeter.c | 121 ++++++++++++++++++++++++- apps/recorder/peakmeter.h | 6 ++ apps/recorder/recording.c | 132 ++++------------------------ apps/settings.h | 4 +- apps/settings_list.c | 10 +-- firmware/export/config/iriverh100.h | 2 +- firmware/export/config/iriverh120.h | 2 +- firmware/export/config/iriverh300.h | 2 +- 33 files changed, 266 insertions(+), 243 deletions(-) diff --git a/apps/features.txt b/apps/features.txt index 54e6afddf3..93b81ff4a5 100644 --- a/apps/features.txt +++ b/apps/features.txt @@ -129,8 +129,8 @@ recording_mic #endif #endif -#if defined(HAVE_RECORDING_HISTOGRAM) -recording_histogram +#if defined(HAVE_HISTOGRAM) +histogram #endif #if defined(HAVE_REMOTE_LCD) diff --git a/apps/lang/catala.lang b/apps/lang/catala.lang index f133e3dd9e..ec79dd7d89 100644 --- a/apps/lang/catala.lang +++ b/apps/lang/catala.lang @@ -12078,20 +12078,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Intèrval d'histograma" + histogram: "Intèrval d'histograma" *: none - recording_histogram: "Intèrval d'histograma" + histogram: "Intèrval d'histograma" diff --git a/apps/lang/czech.lang b/apps/lang/czech.lang index 5d99107296..43bf034071 100644 --- a/apps/lang/czech.lang +++ b/apps/lang/czech.lang @@ -12086,20 +12086,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Rozsah histogramu" + histogram: "Rozsah histogramu" *: none - recording_histogram: "Rozsah histogramu" + histogram: "Rozsah histogramu" diff --git a/apps/lang/dansk.lang b/apps/lang/dansk.lang index 3d4557ac4f..20ebb5e58b 100644 --- a/apps/lang/dansk.lang +++ b/apps/lang/dansk.lang @@ -12566,20 +12566,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" diff --git a/apps/lang/deutsch.lang b/apps/lang/deutsch.lang index ccaa140b37..75004b44db 100644 --- a/apps/lang/deutsch.lang +++ b/apps/lang/deutsch.lang @@ -12440,20 +12440,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogrammintervall" + histogram: "Histogrammintervall" *: none - recording_histogram: "Histogrammintervall" + histogram: "Histogrammintervall" diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 128d5c5fad..de2384214d 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -12169,20 +12169,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" diff --git a/apps/lang/espanol.lang b/apps/lang/espanol.lang index cf4266c062..f689bd6999 100644 --- a/apps/lang/espanol.lang +++ b/apps/lang/espanol.lang @@ -12372,20 +12372,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Intervalo del histograma" + histogram: "Intervalo del histograma" *: none - recording_histogram: "Intervalo del histograma" + histogram: "Intervalo del histograma" diff --git a/apps/lang/francais.lang b/apps/lang/francais.lang index a1a7566647..2adf811d54 100644 --- a/apps/lang/francais.lang +++ b/apps/lang/francais.lang @@ -12110,20 +12110,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Intervalle de l'histogramme" + histogram: "Intervalle de l'histogramme" *: none - recording_histogram: "Intervalle de l'histogramme" + histogram: "Intervalle de l'histogramme" diff --git a/apps/lang/hebrew.lang b/apps/lang/hebrew.lang index 2400b0bb53..b6937db808 100644 --- a/apps/lang/hebrew.lang +++ b/apps/lang/hebrew.lang @@ -12548,20 +12548,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" diff --git a/apps/lang/hrvatski.lang b/apps/lang/hrvatski.lang index d681a0ed6c..1def22085f 100644 --- a/apps/lang/hrvatski.lang +++ b/apps/lang/hrvatski.lang @@ -12087,20 +12087,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Interval histograma" + histogram: "Interval histograma" *: none - recording_histogram: "Interval histograma" + histogram: "Interval histograma" diff --git a/apps/lang/italiano.lang b/apps/lang/italiano.lang index 677b242e3d..fa95de5086 100644 --- a/apps/lang/italiano.lang +++ b/apps/lang/italiano.lang @@ -12089,20 +12089,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Intervallo Istogramma" + histogram: "Intervallo Istogramma" *: none - recording_histogram: "Intervallo Istogramma" + histogram: "Intervallo Istogramma" diff --git a/apps/lang/japanese.lang b/apps/lang/japanese.lang index f1c45c9187..d0b0ae8434 100644 --- a/apps/lang/japanese.lang +++ b/apps/lang/japanese.lang @@ -12093,20 +12093,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "ヒストグラムの間隔" + histogram: "ヒストグラムの間隔" *: none - recording_histogram: "ヒストグラムの間隔" + histogram: "ヒストグラムの間隔" diff --git a/apps/lang/nederlands.lang b/apps/lang/nederlands.lang index db552d52c6..08bf3dfa81 100644 --- a/apps/lang/nederlands.lang +++ b/apps/lang/nederlands.lang @@ -12092,20 +12092,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" diff --git a/apps/lang/polski.lang b/apps/lang/polski.lang index d54afde4e9..00e1ddeaf8 100644 --- a/apps/lang/polski.lang +++ b/apps/lang/polski.lang @@ -12382,20 +12382,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Przedziały histogramu" + histogram: "Przedziały histogramu" *: none - recording_histogram: "Przedziały histogramu" + histogram: "Przedziały histogramu" diff --git a/apps/lang/portugues-brasileiro.lang b/apps/lang/portugues-brasileiro.lang index 0bc6618887..3036a79151 100644 --- a/apps/lang/portugues-brasileiro.lang +++ b/apps/lang/portugues-brasileiro.lang @@ -12085,20 +12085,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Intervalo do Histograma" + histogram: "Intervalo do Histograma" *: none - recording_histogram: "Intervalo do Histograma" + histogram: "Intervalo do Histograma" diff --git a/apps/lang/portugues.lang b/apps/lang/portugues.lang index 3917140b35..f2ce99bb73 100644 --- a/apps/lang/portugues.lang +++ b/apps/lang/portugues.lang @@ -12537,20 +12537,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Intervalo do Histograma" + histogram: "Intervalo do Histograma" *: none - recording_histogram: "Intervalo do Histograma" + histogram: "Intervalo do Histograma" diff --git a/apps/lang/russian.lang b/apps/lang/russian.lang index dd43c4e735..cbe432d873 100644 --- a/apps/lang/russian.lang +++ b/apps/lang/russian.lang @@ -12520,20 +12520,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Интервал гистограммы" + histogram: "Интервал гистограммы" *: none - recording_histogram: "Интервал гистограммы" + histogram: "Интервал гистограммы" diff --git a/apps/lang/slovak.lang b/apps/lang/slovak.lang index d4fc98567c..94a175eb15 100644 --- a/apps/lang/slovak.lang +++ b/apps/lang/slovak.lang @@ -12085,20 +12085,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Interval Histogramu" + histogram: "Interval Histogramu" *: none - recording_histogram: "Interval histogramu" + histogram: "Interval histogramu" diff --git a/apps/lang/slovenscina.lang b/apps/lang/slovenscina.lang index 9f1bda76c7..14ef2c98eb 100644 --- a/apps/lang/slovenscina.lang +++ b/apps/lang/slovenscina.lang @@ -12011,20 +12011,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" diff --git a/apps/lang/srpski.lang b/apps/lang/srpski.lang index 7cd4d94263..179e696363 100644 --- a/apps/lang/srpski.lang +++ b/apps/lang/srpski.lang @@ -12499,20 +12499,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Интервал хистограма" + histogram: "Интервал хистограма" *: none - recording_histogram: "Интервал хистограма" + histogram: "Интервал хистограма" diff --git a/apps/lang/svenska.lang b/apps/lang/svenska.lang index 6d94e52dfb..ec25e0071d 100644 --- a/apps/lang/svenska.lang +++ b/apps/lang/svenska.lang @@ -12091,20 +12091,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogramintervall" + histogram: "Histogramintervall" *: none - recording_histogram: "Histogramintervall" + histogram: "Histogramintervall" diff --git a/apps/lang/tagalog.lang b/apps/lang/tagalog.lang index f4bbc32bc7..816c039222 100644 --- a/apps/lang/tagalog.lang +++ b/apps/lang/tagalog.lang @@ -12559,20 +12559,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" diff --git a/apps/lang/thai.lang b/apps/lang/thai.lang index d01fde0689..0fceae4ca4 100644 --- a/apps/lang/thai.lang +++ b/apps/lang/thai.lang @@ -12511,20 +12511,20 @@ - id: LANG_RECORDING_HISTOGRAM_INTERVAL + id: LANG_HISTOGRAM_INTERVAL desc: in record settings menu user: core *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" *: none - recording_histogram: "ช่วงเวลาฮิสโตแกรม" + histogram: "ช่วงเวลาฮิสโตแกรม" *: none - recording_histogram: "Histogram interval" + histogram: "Histogram interval" diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c index 4badf960ba..7e7b5a6903 100644 --- a/apps/menus/display_menu.c +++ b/apps/menus/display_menu.c @@ -443,6 +443,30 @@ static int peak_meter_max(void) { settings_apply_pm_range(); return retval; } + +#if defined(HAVE_HISTOGRAM) +static bool history_interval(void) +{ + static const struct opt_items names[] = { + { "0s", TALK_ID(0, UNIT_SEC) }, + { "1s", TALK_ID(1, UNIT_SEC) }, + { "2s", TALK_ID(2, UNIT_SEC) }, + { "4s", TALK_ID(4, UNIT_SEC) } + }; + + /* reconfigure histogram settings here */ + + return set_option(str(LANG_HISTOGRAM_INTERVAL), + &global_settings.histogram_interval, + INT, names, 4, NULL ); +} + +MENUITEM_FUNCTION(histogram, 0, + ID2P(LANG_HISTOGRAM_INTERVAL), + history_interval, NULL, NULL, Icon_Menu_setting); + +#endif + MENUITEM_FUNCTION(peak_meter_scale_item, 0, ID2P(LANG_PM_SCALE), peak_meter_scale, NULL, NULL, Icon_NOICON); MENUITEM_FUNCTION(peak_meter_min_item, 0, ID2P(LANG_PM_MIN), @@ -454,6 +478,9 @@ MAKE_MENU(peak_meter_menu, ID2P(LANG_PM_MENU), NULL, Icon_NOICON, &peak_meter_clip_hold, #ifdef HAVE_RECORDING &peak_meter_clipcounter, +#endif +#ifdef HAVE_HISTOGRAM + &histogram, #endif &peak_meter_scale_item, &peak_meter_min_item, &peak_meter_max_item); #endif /* HAVE_LCD_BITMAP */ diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c index 8eaeab699c..ae237b1b4a 100644 --- a/apps/menus/recording_menu.c +++ b/apps/menus/recording_menu.c @@ -392,26 +392,6 @@ MENUITEM_FUNCTION(agc_cliptime, 0, ID2P(LANG_RECORDING_AGC_CLIPTIME), agc_cliptime_func, NULL, NULL, Icon_Menu_setting); #endif /* HAVE_AGC */ -#if defined(HAVE_RECORDING_HISTOGRAM) -static bool history_interval(void) -{ - static const struct opt_items names[] = { - { "0s", TALK_ID(0, UNIT_SEC) }, - { "1s", TALK_ID(1, UNIT_SEC) }, - { "2s", TALK_ID(2, UNIT_SEC) }, - { "4s", TALK_ID(4, UNIT_SEC) } - }; - return set_option(str(LANG_RECORDING_HISTOGRAM_INTERVAL), - &global_settings.rec_histogram_interval, - INT, names, 4, NULL ); -} - -MENUITEM_FUNCTION(recording_histogram, 0, - ID2P(LANG_RECORDING_HISTOGRAM_INTERVAL), - history_interval, NULL, NULL, Icon_Menu_setting); - -#endif - /** Rec trigger **/ enum trigger_menu_option { @@ -666,9 +646,6 @@ MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS), #ifdef HAVE_AGC &agc_preset, &agc_cliptime, #endif -#if defined(HAVE_RECORDING_HISTOGRAM) - &recording_histogram, -#endif #ifdef HAVE_LCD_BITMAP &peak_meter_menu, #endif diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c index ca1b8c8750..c13c4c9539 100644 --- a/apps/recorder/peakmeter.c +++ b/apps/recorder/peakmeter.c @@ -28,6 +28,7 @@ #include "storage.h" #include "lcd.h" #include "scrollbar.h" +#include "string.h" #include "button.h" #include "system.h" #include "font.h" @@ -64,9 +65,10 @@ static int pm_cur_left; /* current values (last peak_meter_peek) */ static int pm_cur_right; static int pm_max_left; /* maximum values between peak meter draws */ static int pm_max_right; -#if defined(HAVE_AGC) || defined(HAVE_RECORDING_HISTOGRAM) +#if defined(HAVE_AGC) || defined(HAVE_HISTOGRAM) static int pm_peakhold_left; /* max. peak values between peakhold calls */ static int pm_peakhold_right; /* used for AGC and histogram display */ +static long next_histogram_update; #endif /* Clip hold */ @@ -134,6 +136,38 @@ static unsigned int peeks_per_redraw[PEEKS_PER_DRAW_SIZE]; static unsigned int ticks_per_redraw[TICKS_PER_DRAW_SIZE]; #endif +#if defined(HAVE_HISTOGRAM) +#define HIST_BUF_SIZE (LCD_WIDTH / 2) +static int hist_l = 0; +static int hist_r = 0; +static unsigned char history_l[HIST_BUF_SIZE]; +static unsigned char history_r[HIST_BUF_SIZE]; +static const char hist_level_marks[6] = { 29, 26, 23, 17, 9, 2}; +static int history_pos = 0; +#define HIST_W (LCD_WIDTH / 2) +#if LCD_DEPTH > 1 +#ifdef HAVE_LCD_COLOR +#define LCD_BAL_L LCD_RGBPACK(0, 0, 255) +#define LCD_BAL_R LCD_RGBPACK(204, 0, 0) +#define LCD_HIST_OVER LCD_RGBPACK(204, 0, 0) +#define LCD_HIST_HI LCD_RGBPACK(255, 204, 0) +#define LCD_HIST_OK LCD_RGBPACK(51, 153, 0) +#else /* HAVE_LCD_COLOR */ +#define LCD_BATT_OK LCD_BLACK +#define LCD_BATT_LO LCD_DARKGRAY +#define LCD_DISK_OK LCD_BLACK +#define LCD_DISK_LO LCD_DARKGRAY +#define LCD_HIST_OVER LCD_BLACK +#define LCD_HIST_OK LCD_DARKGRAY +#define LCD_BAL LCD_DARKGRAY +#endif /* HAVE_LCD_COLOR */ +#else /* LCD_DEPTH > 1 */ +#define LCD_HIST_OVER LCD_DEFAULT_FG +#define LCD_HIST_OK LCD_DEFAULT_FG +#define LCD_BAL LCD_DEFAULT_FG +#endif /* LCD_DEPTH > 1 */ +#endif /* HAVE_HISTOGRAM */ + static void peak_meter_draw(struct screen *display, struct meter_scales *meter_scales, int x, int y, int width, int height); @@ -810,7 +844,7 @@ static int peak_meter_read_l(void) retval = pm_max_left; -#if defined(HAVE_RECORDING_HISTOGRAM) || defined(HAVE_AGC) +#if defined(HAVE_HISTOGRAM) || defined(HAVE_AGC) /* store max peak value for peak_meter_get_peakhold_x readout */ pm_peakhold_left = MAX(pm_max_left, pm_peakhold_left); #endif @@ -843,7 +877,7 @@ static int peak_meter_read_r(void) retval = pm_max_right; -#if defined(HAVE_RECORDING_HISTOGRAM) || defined(HAVE_AGC) +#if defined(HAVE_HISTOGRAM) || defined(HAVE_AGC) /* store max peak value for peak_meter_get_peakhold_x readout */ pm_peakhold_right = MAX(pm_max_right, pm_peakhold_right); #endif @@ -857,7 +891,7 @@ static int peak_meter_read_r(void) return retval; } -#if defined(HAVE_AGC) || defined(HAVE_RECORDING_HISTOGRAM) +#if defined(HAVE_AGC) || defined(HAVE_HISTOGRAM) /** * Reads out the current peak-hold values since the last call. * This is used by the histogram feature in the recording screen. @@ -869,6 +903,14 @@ void peak_meter_get_peakhold(int *peak_left, int *peak_right) *peak_left = pm_peakhold_left; if (peak_right) *peak_right = pm_peakhold_right; + +#ifdef HAVE_HISTOGRAM + if (*peak_left > hist_l) + hist_l = *peak_left; + if (*peak_right > hist_r) + hist_r = *peak_right; +#endif + pm_peakhold_left = 0; pm_peakhold_right = 0; } @@ -1447,4 +1489,75 @@ bool peak_meter_histogram(void) } #endif +#ifdef HAVE_HISTOGRAM +void histogram_init() +{ + /* get update interval, clear buffer, reset drawing position */ + memset(history_l, 0, sizeof(unsigned char)*HIST_BUF_SIZE); + memset(history_r, 0, sizeof(unsigned char)*HIST_BUF_SIZE); + next_histogram_update = current_tick + + (global_settings.histogram_interval * HZ); +} + +void histogram_draw(int x1, int x2, int y1, int y2, int width, int height) +{ + int i, j; + if (current_tick >= next_histogram_update) + { + /* fill history buffer */ + history_l[history_pos] = hist_l * height / 32767; + history_r[history_pos] = hist_r * height / 32767; + history_pos = (history_pos + 1) % HIST_BUF_SIZE; + history_l[history_pos] = history_r[history_pos] = 0; + history_l[(history_pos + 1) % HIST_BUF_SIZE] = 0; + history_r[(history_pos + 1) % HIST_BUF_SIZE] = 0; + hist_l = 0; + hist_r = 0; + next_histogram_update = current_tick + + (global_settings.histogram_interval * HZ); + } + lcd_set_drawmode(DRMODE_SOLID); + lcd_drawrect(x1, y1, width, height); + lcd_drawrect(x2, y2, width, height); + lcd_set_drawmode(DRMODE_FG); + + j = history_pos; + for (i = width-2; i >= 0; i--) + { + j--; + if(j<0) + j = HIST_BUF_SIZE-1; + if (history_l[j]) + { + if (history_l[j] == height) + lcd_set_foreground(LCD_HIST_OVER); +#ifdef HAVE_LCD_COLOR + else if (history_l[j] > hist_level_marks[1]) + lcd_set_foreground(LCD_HIST_HI); +#endif + else + lcd_set_foreground(LCD_HIST_OK); + lcd_vline(x1 + i, y1 + height - 2, y1 + height - history_l[j]); + } + if (history_r[j]) + { + if (history_r[j] == height) + lcd_set_foreground(LCD_HIST_OVER); +#ifdef HAVE_LCD_COLOR + else if (history_r[j] > hist_level_marks[1]) + lcd_set_foreground(LCD_HIST_HI); +#endif + else + lcd_set_foreground(LCD_HIST_OK); + lcd_vline(x2 + i, y2 + height - 2, y2 + height - history_r[j]); + } + } + lcd_set_foreground( +#ifdef HAVE_LCD_COLOR + global_settings.fg_color); +#else + LCD_DEFAULT_FG); +#endif +} +#endif /* HAVE_HISTOGRAM */ diff --git a/apps/recorder/peakmeter.h b/apps/recorder/peakmeter.h index fee4882679..6be43a5f3a 100644 --- a/apps/recorder/peakmeter.h +++ b/apps/recorder/peakmeter.h @@ -56,6 +56,11 @@ extern int calc_db (int isample); extern int peak_meter_db2sample(int db); extern unsigned short peak_meter_scale_value(unsigned short val, int meterwidth); +#ifdef HAVE_HISTOGRAM +extern void histogram_init(void); +extern void histogram_draw(int x1, int x2, int y1, int y2, int width, int height); +#endif + /* valid values for trigger_status */ #define TRIG_OFF 0x00 #define TRIG_READY 0x01 @@ -103,3 +108,4 @@ struct meter_scales{ extern void peak_meter_screen(struct screen *display, int x, int y, int height); #endif /* __PEAKMETER_H__ */ + diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 34283b6cb5..6faaa6c48c 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -269,39 +269,9 @@ static short agc_baltime = 0; /* AGC maximum gain */ static short agc_maxgain; #endif /* HAVE_AGC */ -#if defined(HAVE_AGC) || defined(HAVE_RECORDING_HISTOGRAM) +#if defined(HAVE_AGC) static long hist_time = 0; -#endif /* HAVE_AGC or HAVE_RECORDING_HISTOGRAM */ -/* Histogram data */ -/* TO DO: move some of this stuff inside the recording function? */ -#ifdef HAVE_RECORDING_HISTOGRAM -static int hist_l = 0; -static int hist_r = 0; -#define HIST_BUF_SIZE (LCD_WIDTH) -#define HIST_Y (hist_pos_y+hist_size_h-1) -#define HIST_W (LCD_WIDTH / 2 - 4) -#if LCD_DEPTH > 1 -#ifdef HAVE_LCD_COLOR -#define LCD_BAL_L LCD_RGBPACK(0, 0, 255) -#define LCD_BAL_R LCD_RGBPACK(204, 0, 0) -#define LCD_HIST_OVER LCD_RGBPACK(204, 0, 0) -#define LCD_HIST_HI LCD_RGBPACK(255, 204, 0) -#define LCD_HIST_OK LCD_RGBPACK(51, 153, 0) -#else /* HAVE_LCD_COLOR */ -#define LCD_BATT_OK LCD_BLACK -#define LCD_BATT_LO LCD_DARKGRAY -#define LCD_DISK_OK LCD_BLACK -#define LCD_DISK_LO LCD_DARKGRAY -#define LCD_HIST_OVER LCD_BLACK -#define LCD_HIST_OK LCD_DARKGRAY -#define LCD_BAL LCD_DARKGRAY -#endif /* HAVE_LCD_COLOR */ -#else /* LCD_DEPTH > 1 */ -#define LCD_HIST_OVER LCD_DEFAULT_FG -#define LCD_HIST_OK LCD_DEFAULT_FG -#define LCD_BAL LCD_DEFAULT_FG -#endif /* LCD_DEPTH > 1 */ -#endif /* HAVE_RECORDING_HISTOGRAM */ +#endif /* HAVE_AGC */ static void set_gain(void) { @@ -368,13 +338,6 @@ static bool read_peak_levels(int *peak_l, int *peak_r, int *balance) *balance += balance_mem[i]; *balance = *balance / BAL_MEM_SIZE; -#ifdef HAVE_RECORDING_HISTOGRAM - if (*peak_l > hist_l) - hist_l = *peak_l; - if (*peak_r > hist_r) - hist_r = *peak_r; -#endif - return true; } @@ -1089,18 +1052,12 @@ bool recording_screen(bool no_source) /* tweak layout tiny screens / big fonts */ bool compact_view[NB_SCREENS] = { false }; struct gui_synclist lists; /* the list in the bottom vp */ -#if defined(HAVE_AGC) || defined(HAVE_RECORDING_HISTOGRAM) +#if defined(HAVE_AGC) bool peak_valid = false; #endif -#if defined(HAVE_RECORDING_HISTOGRAM) - int j; +#if defined(HAVE_HISTOGRAM) unsigned short hist_pos_y = 0; unsigned short hist_size_h = 0; - int history_pos = 0; - short hist_time_interval = 1; /* 1, 2, 4, 8 */ - unsigned char history_l[HIST_BUF_SIZE]; - unsigned char history_r[HIST_BUF_SIZE]; - const char hist_level_marks[6] = { 29, 26, 23, 17, 9, 2}; #endif #ifdef HAVE_FMRADIO_REC int prev_rec_source = global_settings.rec_source; /* detect source change */ @@ -1186,10 +1143,9 @@ bool recording_screen(bool no_source) /* top vp, 4 lines, force sys font if total screen < 6 lines NOTE: one could limit the list to 1 line and get away with 5 lines */ top_height_req[i] = 4; -#if defined(HAVE_RECORDING_HISTOGRAM) - if((global_settings.rec_histogram_interval) && (!i)) +#if defined(HAVE_HISTOGRAM) + if((global_settings.histogram_interval) && (!i)) top_height_req[i] += 1; /* use one line for histogram */ - hist_time_interval = 1 << global_settings.rec_histogram_interval; #endif v = &vp_top[i]; viewport_set_defaults(v, i); @@ -1229,13 +1185,11 @@ bool recording_screen(bool no_source) send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ -#if defined(HAVE_RECORDING_HISTOGRAM) - history_pos = 0; +#if defined(HAVE_HISTOGRAM) hist_pos_y = (compact_view[0] ? 3 : 4) * (font_get(vp_top[0].font)->height) + 1; hist_size_h = font_get(vp_top[0].font)->height - 2; - memset(history_l, 0, sizeof(unsigned char)*HIST_BUF_SIZE); - memset(history_r, 0, sizeof(unsigned char)*HIST_BUF_SIZE); + histogram_init(); #endif FOR_NB_SCREENS(i) @@ -1887,75 +1841,21 @@ bool recording_screen(bool no_source) } } -#ifdef HAVE_RECORDING_HISTOGRAM - if(global_settings.rec_histogram_interval) - { - if (peak_valid && !(hist_time % hist_time_interval) && hist_l) +#ifdef HAVE_HISTOGRAM + if(global_settings.histogram_interval) { - /* fill history buffer */ - history_l[history_pos] = hist_l * hist_size_h / 32767; - history_r[history_pos] = hist_r * hist_size_h / 32767; - history_pos = (history_pos + 1) % HIST_BUF_SIZE; - history_l[history_pos] = history_r[history_pos] = 0; - history_l[(history_pos + 1) % HIST_BUF_SIZE] = 0; - history_r[(history_pos + 1) % HIST_BUF_SIZE] = 0; - hist_l = 0; - hist_r = 0; + histogram_draw(0, + screens[0].getwidth()/2, + hist_pos_y, + hist_pos_y, + screens[0].getwidth()/2, + hist_size_h); } - lcd_set_drawmode(DRMODE_SOLID); - lcd_drawrect(0, hist_pos_y - 1, - HIST_W + 2, hist_size_h + 1); - lcd_drawrect(HIST_W + 6, hist_pos_y - 1, - HIST_W + 2, hist_size_h + 1); - lcd_set_drawmode(DRMODE_FG); - - j = history_pos; - for (i = HIST_W-1; i >= 0; i--) - { - j--; - if(j<0) - j = HIST_BUF_SIZE-1; - if (history_l[j]) - { - if (history_l[j] == hist_size_h) - lcd_set_foreground(LCD_HIST_OVER); -#ifdef HAVE_LCD_COLOR - else if (history_l[j] > hist_level_marks[1]) - lcd_set_foreground(LCD_HIST_HI); #endif - else - lcd_set_foreground(LCD_HIST_OK); - lcd_vline(1 + i, HIST_Y-1, HIST_Y - history_l[j]); - } - if (history_r[j]) - { - if (history_r[j] == hist_size_h) - lcd_set_foreground(LCD_HIST_OVER); -#ifdef HAVE_LCD_COLOR - else if (history_r[j] > hist_level_marks[1]) - lcd_set_foreground(LCD_HIST_HI); -#endif - else - lcd_set_foreground(LCD_HIST_OK); - lcd_vline(HIST_W+7 + i, HIST_Y-1, HIST_Y - history_r[j]); - } - } - lcd_set_foreground( -#ifdef HAVE_LCD_COLOR - global_settings.fg_color); -#else - LCD_DEFAULT_FG); -#endif - for (i = 0; i < 6; i++) - lcd_hline(HIST_W + 3, HIST_W + 4, - HIST_Y - hist_level_marks[i]); - } -#endif /* HAVE_RECORDING_HISTOGRAM */ #ifdef HAVE_AGC hist_time++; #endif - /* draw the trigger status */ if (peak_meter_trigger_status() != TRIG_OFF) { diff --git a/apps/settings.h b/apps/settings.h index bed88c82ea..05965b3119 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -438,8 +438,8 @@ struct user_settings int rec_stop_gap; /* index of trig_durations */ int rec_trigger_mode; /* see TRIG_MODE_XXX constants */ int rec_trigger_type; /* what to do when trigger released */ -#ifdef HAVE_RECORDING_HISTOGRAM - int rec_histogram_interval; /* recording peakmeter histogram */ +#ifdef HAVE_HISTOGRAM + int histogram_interval; /* recording peakmeter histogram */ #endif #ifdef HAVE_AGC diff --git a/apps/settings_list.c b/apps/settings_list.c index f282b8afc0..019a14437e 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1238,14 +1238,14 @@ const struct settings_list settings[] = { CHOICE_SETTING(F_RECSETTING, rec_trigger_type, LANG_RECORD_TRIGGER_TYPE, TRIG_TYPE_STOP, "trigger type","stop,pause,nf stp", NULL ,3, ID2P(LANG_RECORD_TRIGGER_STOP), ID2P(LANG_PAUSE), ID2P(LANG_RECORD_TRIGGER_NEWFILESTP)), -#ifdef HAVE_RECORDING_HISTOGRAM +#endif /* HAVE_RECORDING */ + +#ifdef HAVE_HISTOGRAM /* TO DO: additional restictions of following REP items? */ - TABLE_SETTING(F_RECSETTING, rec_histogram_interval, LANG_RECORDING_HISTOGRAM_INTERVAL, 0, + TABLE_SETTING(F_RECSETTING, histogram_interval, LANG_HISTOGRAM_INTERVAL, 0, "histogram interval","0s,1s,2s,4s", UNIT_SEC, NULL, NULL, NULL, 4, 0,1,2,4), -#endif /* HAVE_RECORDING_HISTOGRAM */ - -#endif /* HAVE_RECORDING */ +#endif /* HAVE_HISTOGRAM */ #ifdef HAVE_SPDIF_POWER OFFON_SETTING(F_SOUNDSETTING, spdif_enable, LANG_SPDIF_ENABLE, false, diff --git a/firmware/export/config/iriverh100.h b/firmware/export/config/iriverh100.h index 4ebbde8ab1..1a89c7ca2d 100644 --- a/firmware/export/config/iriverh100.h +++ b/firmware/export/config/iriverh100.h @@ -123,7 +123,7 @@ #define HAVE_AGC -#define HAVE_RECORDING_HISTOGRAM +#define HAVE_HISTOGRAM #define BATTERY_CAPACITY_DEFAULT 1300 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 1300 /* min. capacity selectable */ diff --git a/firmware/export/config/iriverh120.h b/firmware/export/config/iriverh120.h index 44b8988a1b..199b948245 100644 --- a/firmware/export/config/iriverh120.h +++ b/firmware/export/config/iriverh120.h @@ -114,7 +114,7 @@ /* define this if you have recording possibility */ #define HAVE_RECORDING -#define HAVE_RECORDING_HISTOGRAM +#define HAVE_HISTOGRAM /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ diff --git a/firmware/export/config/iriverh300.h b/firmware/export/config/iriverh300.h index c4224d03c6..dbe701362a 100644 --- a/firmware/export/config/iriverh300.h +++ b/firmware/export/config/iriverh300.h @@ -110,7 +110,7 @@ /* define this if you have recording possibility */ #define HAVE_RECORDING -#define HAVE_RECORDING_HISTOGRAM +#define HAVE_HISTOGRAM /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */