diff options
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r-- | apps/recorder/recording.c | 132 |
1 files changed, 16 insertions, 116 deletions
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; | |||
269 | /* AGC maximum gain */ | 269 | /* AGC maximum gain */ |
270 | static short agc_maxgain; | 270 | static short agc_maxgain; |
271 | #endif /* HAVE_AGC */ | 271 | #endif /* HAVE_AGC */ |
272 | #if defined(HAVE_AGC) || defined(HAVE_RECORDING_HISTOGRAM) | 272 | #if defined(HAVE_AGC) |
273 | static long hist_time = 0; | 273 | static long hist_time = 0; |
274 | #endif /* HAVE_AGC or HAVE_RECORDING_HISTOGRAM */ | 274 | #endif /* HAVE_AGC */ |
275 | /* Histogram data */ | ||
276 | /* TO DO: move some of this stuff inside the recording function? */ | ||
277 | #ifdef HAVE_RECORDING_HISTOGRAM | ||
278 | static int hist_l = 0; | ||
279 | static int hist_r = 0; | ||
280 | #define HIST_BUF_SIZE (LCD_WIDTH) | ||
281 | #define HIST_Y (hist_pos_y+hist_size_h-1) | ||
282 | #define HIST_W (LCD_WIDTH / 2 - 4) | ||
283 | #if LCD_DEPTH > 1 | ||
284 | #ifdef HAVE_LCD_COLOR | ||
285 | #define LCD_BAL_L LCD_RGBPACK(0, 0, 255) | ||
286 | #define LCD_BAL_R LCD_RGBPACK(204, 0, 0) | ||
287 | #define LCD_HIST_OVER LCD_RGBPACK(204, 0, 0) | ||
288 | #define LCD_HIST_HI LCD_RGBPACK(255, 204, 0) | ||
289 | #define LCD_HIST_OK LCD_RGBPACK(51, 153, 0) | ||
290 | #else /* HAVE_LCD_COLOR */ | ||
291 | #define LCD_BATT_OK LCD_BLACK | ||
292 | #define LCD_BATT_LO LCD_DARKGRAY | ||
293 | #define LCD_DISK_OK LCD_BLACK | ||
294 | #define LCD_DISK_LO LCD_DARKGRAY | ||
295 | #define LCD_HIST_OVER LCD_BLACK | ||
296 | #define LCD_HIST_OK LCD_DARKGRAY | ||
297 | #define LCD_BAL LCD_DARKGRAY | ||
298 | #endif /* HAVE_LCD_COLOR */ | ||
299 | #else /* LCD_DEPTH > 1 */ | ||
300 | #define LCD_HIST_OVER LCD_DEFAULT_FG | ||
301 | #define LCD_HIST_OK LCD_DEFAULT_FG | ||
302 | #define LCD_BAL LCD_DEFAULT_FG | ||
303 | #endif /* LCD_DEPTH > 1 */ | ||
304 | #endif /* HAVE_RECORDING_HISTOGRAM */ | ||
305 | 275 | ||
306 | static void set_gain(void) | 276 | static void set_gain(void) |
307 | { | 277 | { |
@@ -368,13 +338,6 @@ static bool read_peak_levels(int *peak_l, int *peak_r, int *balance) | |||
368 | *balance += balance_mem[i]; | 338 | *balance += balance_mem[i]; |
369 | *balance = *balance / BAL_MEM_SIZE; | 339 | *balance = *balance / BAL_MEM_SIZE; |
370 | 340 | ||
371 | #ifdef HAVE_RECORDING_HISTOGRAM | ||
372 | if (*peak_l > hist_l) | ||
373 | hist_l = *peak_l; | ||
374 | if (*peak_r > hist_r) | ||
375 | hist_r = *peak_r; | ||
376 | #endif | ||
377 | |||
378 | return true; | 341 | return true; |
379 | } | 342 | } |
380 | 343 | ||
@@ -1089,18 +1052,12 @@ bool recording_screen(bool no_source) | |||
1089 | /* tweak layout tiny screens / big fonts */ | 1052 | /* tweak layout tiny screens / big fonts */ |
1090 | bool compact_view[NB_SCREENS] = { false }; | 1053 | bool compact_view[NB_SCREENS] = { false }; |
1091 | struct gui_synclist lists; /* the list in the bottom vp */ | 1054 | struct gui_synclist lists; /* the list in the bottom vp */ |
1092 | #if defined(HAVE_AGC) || defined(HAVE_RECORDING_HISTOGRAM) | 1055 | #if defined(HAVE_AGC) |
1093 | bool peak_valid = false; | 1056 | bool peak_valid = false; |
1094 | #endif | 1057 | #endif |
1095 | #if defined(HAVE_RECORDING_HISTOGRAM) | 1058 | #if defined(HAVE_HISTOGRAM) |
1096 | int j; | ||
1097 | unsigned short hist_pos_y = 0; | 1059 | unsigned short hist_pos_y = 0; |
1098 | unsigned short hist_size_h = 0; | 1060 | unsigned short hist_size_h = 0; |
1099 | int history_pos = 0; | ||
1100 | short hist_time_interval = 1; /* 1, 2, 4, 8 */ | ||
1101 | unsigned char history_l[HIST_BUF_SIZE]; | ||
1102 | unsigned char history_r[HIST_BUF_SIZE]; | ||
1103 | const char hist_level_marks[6] = { 29, 26, 23, 17, 9, 2}; | ||
1104 | #endif | 1061 | #endif |
1105 | #ifdef HAVE_FMRADIO_REC | 1062 | #ifdef HAVE_FMRADIO_REC |
1106 | int prev_rec_source = global_settings.rec_source; /* detect source change */ | 1063 | int prev_rec_source = global_settings.rec_source; /* detect source change */ |
@@ -1186,10 +1143,9 @@ bool recording_screen(bool no_source) | |||
1186 | /* top vp, 4 lines, force sys font if total screen < 6 lines | 1143 | /* top vp, 4 lines, force sys font if total screen < 6 lines |
1187 | NOTE: one could limit the list to 1 line and get away with 5 lines */ | 1144 | NOTE: one could limit the list to 1 line and get away with 5 lines */ |
1188 | top_height_req[i] = 4; | 1145 | top_height_req[i] = 4; |
1189 | #if defined(HAVE_RECORDING_HISTOGRAM) | 1146 | #if defined(HAVE_HISTOGRAM) |
1190 | if((global_settings.rec_histogram_interval) && (!i)) | 1147 | if((global_settings.histogram_interval) && (!i)) |
1191 | top_height_req[i] += 1; /* use one line for histogram */ | 1148 | top_height_req[i] += 1; /* use one line for histogram */ |
1192 | hist_time_interval = 1 << global_settings.rec_histogram_interval; | ||
1193 | #endif | 1149 | #endif |
1194 | v = &vp_top[i]; | 1150 | v = &vp_top[i]; |
1195 | viewport_set_defaults(v, i); | 1151 | viewport_set_defaults(v, i); |
@@ -1229,13 +1185,11 @@ bool recording_screen(bool no_source) | |||
1229 | 1185 | ||
1230 | send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ | 1186 | send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ |
1231 | 1187 | ||
1232 | #if defined(HAVE_RECORDING_HISTOGRAM) | 1188 | #if defined(HAVE_HISTOGRAM) |
1233 | history_pos = 0; | ||
1234 | hist_pos_y = (compact_view[0] ? 3 : 4) * (font_get(vp_top[0].font)->height) | 1189 | hist_pos_y = (compact_view[0] ? 3 : 4) * (font_get(vp_top[0].font)->height) |
1235 | + 1; | 1190 | + 1; |
1236 | hist_size_h = font_get(vp_top[0].font)->height - 2; | 1191 | hist_size_h = font_get(vp_top[0].font)->height - 2; |
1237 | memset(history_l, 0, sizeof(unsigned char)*HIST_BUF_SIZE); | 1192 | histogram_init(); |
1238 | memset(history_r, 0, sizeof(unsigned char)*HIST_BUF_SIZE); | ||
1239 | #endif | 1193 | #endif |
1240 | 1194 | ||
1241 | FOR_NB_SCREENS(i) | 1195 | FOR_NB_SCREENS(i) |
@@ -1887,75 +1841,21 @@ bool recording_screen(bool no_source) | |||
1887 | } | 1841 | } |
1888 | } | 1842 | } |
1889 | 1843 | ||
1890 | #ifdef HAVE_RECORDING_HISTOGRAM | 1844 | #ifdef HAVE_HISTOGRAM |
1891 | if(global_settings.rec_histogram_interval) | 1845 | if(global_settings.histogram_interval) |
1892 | { | ||
1893 | if (peak_valid && !(hist_time % hist_time_interval) && hist_l) | ||
1894 | { | 1846 | { |
1895 | /* fill history buffer */ | 1847 | histogram_draw(0, |
1896 | history_l[history_pos] = hist_l * hist_size_h / 32767; | 1848 | screens[0].getwidth()/2, |
1897 | history_r[history_pos] = hist_r * hist_size_h / 32767; | 1849 | hist_pos_y, |
1898 | history_pos = (history_pos + 1) % HIST_BUF_SIZE; | 1850 | hist_pos_y, |
1899 | history_l[history_pos] = history_r[history_pos] = 0; | 1851 | screens[0].getwidth()/2, |
1900 | history_l[(history_pos + 1) % HIST_BUF_SIZE] = 0; | 1852 | hist_size_h); |
1901 | history_r[(history_pos + 1) % HIST_BUF_SIZE] = 0; | ||
1902 | hist_l = 0; | ||
1903 | hist_r = 0; | ||
1904 | } | 1853 | } |
1905 | lcd_set_drawmode(DRMODE_SOLID); | ||
1906 | lcd_drawrect(0, hist_pos_y - 1, | ||
1907 | HIST_W + 2, hist_size_h + 1); | ||
1908 | lcd_drawrect(HIST_W + 6, hist_pos_y - 1, | ||
1909 | HIST_W + 2, hist_size_h + 1); | ||
1910 | lcd_set_drawmode(DRMODE_FG); | ||
1911 | |||
1912 | j = history_pos; | ||
1913 | for (i = HIST_W-1; i >= 0; i--) | ||
1914 | { | ||
1915 | j--; | ||
1916 | if(j<0) | ||
1917 | j = HIST_BUF_SIZE-1; | ||
1918 | if (history_l[j]) | ||
1919 | { | ||
1920 | if (history_l[j] == hist_size_h) | ||
1921 | lcd_set_foreground(LCD_HIST_OVER); | ||
1922 | #ifdef HAVE_LCD_COLOR | ||
1923 | else if (history_l[j] > hist_level_marks[1]) | ||
1924 | lcd_set_foreground(LCD_HIST_HI); | ||
1925 | #endif | 1854 | #endif |
1926 | else | ||
1927 | lcd_set_foreground(LCD_HIST_OK); | ||
1928 | lcd_vline(1 + i, HIST_Y-1, HIST_Y - history_l[j]); | ||
1929 | } | ||
1930 | if (history_r[j]) | ||
1931 | { | ||
1932 | if (history_r[j] == hist_size_h) | ||
1933 | lcd_set_foreground(LCD_HIST_OVER); | ||
1934 | #ifdef HAVE_LCD_COLOR | ||
1935 | else if (history_r[j] > hist_level_marks[1]) | ||
1936 | lcd_set_foreground(LCD_HIST_HI); | ||
1937 | #endif | ||
1938 | else | ||
1939 | lcd_set_foreground(LCD_HIST_OK); | ||
1940 | lcd_vline(HIST_W+7 + i, HIST_Y-1, HIST_Y - history_r[j]); | ||
1941 | } | ||
1942 | } | ||
1943 | lcd_set_foreground( | ||
1944 | #ifdef HAVE_LCD_COLOR | ||
1945 | global_settings.fg_color); | ||
1946 | #else | ||
1947 | LCD_DEFAULT_FG); | ||
1948 | #endif | ||
1949 | for (i = 0; i < 6; i++) | ||
1950 | lcd_hline(HIST_W + 3, HIST_W + 4, | ||
1951 | HIST_Y - hist_level_marks[i]); | ||
1952 | } | ||
1953 | #endif /* HAVE_RECORDING_HISTOGRAM */ | ||
1954 | 1855 | ||
1955 | #ifdef HAVE_AGC | 1856 | #ifdef HAVE_AGC |
1956 | hist_time++; | 1857 | hist_time++; |
1957 | #endif | 1858 | #endif |
1958 | |||
1959 | /* draw the trigger status */ | 1859 | /* draw the trigger status */ |
1960 | if (peak_meter_trigger_status() != TRIG_OFF) | 1860 | if (peak_meter_trigger_status() != TRIG_OFF) |
1961 | { | 1861 | { |