Patch #1352575 - Shorten codec from the ffmpeg project. Rockbox implementation by...
[Rockbox.git] / apps / sound_menu.c
blob766372471e0bb32bc2cbc6742b2b31a4cbe0dc39
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Björn Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "config.h"
20 #include <stdio.h>
21 #include <stdbool.h>
22 #include "system.h"
23 #include "kernel.h"
24 #include "lcd.h"
25 #include "menu.h"
26 #include "button.h"
27 #include "mp3_playback.h"
28 #include "settings.h"
29 #include "status.h"
30 #include "screens.h"
31 #ifdef HAVE_LCD_BITMAP
32 #include "icons.h"
33 #include "font.h"
34 #include "widgets.h"
35 #endif
36 #include "lang.h"
37 #include "sprintf.h"
38 #include "talk.h"
39 #include "misc.h"
40 #include "sound.h"
41 #if CONFIG_CODEC == MAS3587F
42 #include "peakmeter.h"
43 #include "mas.h"
44 #endif
46 int selected_setting; /* Used by the callback */
47 void dec_sound_formatter(char *buffer, int buffer_size, int val, const char * unit)
49 val = sound_val2phys(selected_setting, val);
50 int integer = val / 10;
51 int dec = val % 10;
52 snprintf(buffer, buffer_size, "%d.%d %s", integer, dec, unit);
55 bool set_sound(const char* string,
56 int* variable,
57 int setting)
59 int talkunit = UNIT_INT;
60 const char* unit = sound_unit(setting);
61 int numdec = sound_numdecimals(setting);
62 int steps = sound_steps(setting);
63 int min = sound_min(setting);
64 int max = sound_max(setting);
65 sound_set_type* sound_callback = sound_get_fn(setting);
66 if (*unit == 'd') /* crude reconstruction */
67 talkunit = UNIT_DB;
68 else if (*unit == '%')
69 talkunit = UNIT_PERCENT;
70 else if (*unit == 'H')
71 talkunit = UNIT_HERTZ;
72 if(!numdec)
73 return set_int(string, unit, talkunit, variable, sound_callback,
74 steps, min, max, NULL );
75 else
76 {/* Decimal number */
77 selected_setting=setting;
78 return set_int(string, unit, talkunit, variable, sound_callback,
79 steps, min, max, &dec_sound_formatter );
83 static bool volume(void)
85 return set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME);
88 static bool balance(void)
90 return set_sound(str(LANG_BALANCE), &global_settings.balance,
91 SOUND_BALANCE);
94 static bool bass(void)
96 return set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS);
99 static bool treble(void)
101 return set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE);
104 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
105 static bool loudness(void)
107 return set_sound(str(LANG_LOUDNESS), &global_settings.loudness,
108 SOUND_LOUDNESS);
111 static bool mdb_strength(void)
113 return set_sound(str(LANG_MDB_STRENGTH), &global_settings.mdb_strength,
114 SOUND_MDB_STRENGTH);
117 static bool mdb_harmonics(void)
119 return set_sound(str(LANG_MDB_HARMONICS), &global_settings.mdb_harmonics,
120 SOUND_MDB_HARMONICS);
123 static bool mdb_center(void)
125 return set_sound(str(LANG_MDB_CENTER), &global_settings.mdb_center,
126 SOUND_MDB_CENTER);
129 static bool mdb_shape(void)
131 return set_sound(str(LANG_MDB_SHAPE), &global_settings.mdb_shape,
132 SOUND_MDB_SHAPE);
135 static void set_mdb_enable(bool value)
137 sound_set_mdb_enable((int)value);
140 static bool mdb_enable(void)
142 return set_bool_options(str(LANG_MDB_ENABLE),
143 &global_settings.mdb_enable,
144 STR(LANG_SET_BOOL_YES),
145 STR(LANG_SET_BOOL_NO),
146 set_mdb_enable);
149 static void set_superbass(bool value)
151 sound_set_superbass((int)value);
154 static bool superbass(void)
156 return set_bool_options(str(LANG_SUPERBASS),
157 &global_settings.superbass,
158 STR(LANG_SET_BOOL_YES),
159 STR(LANG_SET_BOOL_NO),
160 set_superbass);
163 static bool avc(void)
165 static const struct opt_items names[] = {
166 { STR(LANG_OFF) },
167 { "20ms", TALK_ID(20, UNIT_MS) },
168 { "2s", TALK_ID(2, UNIT_SEC) },
169 { "4s", TALK_ID(4, UNIT_SEC) },
170 { "8s", TALK_ID(8, UNIT_SEC) }
172 return set_option(str(LANG_DECAY), &global_settings.avc, INT,
173 names, 5, sound_set_avc);
175 #endif
177 #ifdef HAVE_RECORDING
178 static bool recsource(void)
180 static const struct opt_items names[] = {
181 { STR(LANG_RECORDING_SRC_MIC) },
182 { STR(LANG_RECORDING_SRC_LINE) },
183 #ifdef HAVE_SPDIF_IN
184 { STR(LANG_RECORDING_SRC_DIGITAL) },
185 #endif
187 return set_option(str(LANG_RECORDING_SOURCE),
188 &global_settings.rec_source, INT, names,
189 sizeof(names)/sizeof(struct opt_items), NULL );
192 static bool recfrequency(void)
194 static const struct opt_items names[] = {
195 { "44.1kHz", TALK_ID(44, UNIT_KHZ) },
196 { "48kHz", TALK_ID(48, UNIT_KHZ) },
197 { "32kHz", TALK_ID(32, UNIT_KHZ) },
198 { "22.05kHz", TALK_ID(22, UNIT_KHZ) },
199 { "24kHz", TALK_ID(24, UNIT_KHZ) },
200 { "16kHz", TALK_ID(16, UNIT_KHZ) }
202 return set_option(str(LANG_RECORDING_FREQUENCY),
203 &global_settings.rec_frequency, INT,
204 names, 6, NULL );
207 static bool recchannels(void)
209 static const struct opt_items names[] = {
210 { STR(LANG_CHANNEL_STEREO) },
211 { STR(LANG_CHANNEL_MONO) }
213 return set_option(str(LANG_RECORDING_CHANNELS),
214 &global_settings.rec_channels, INT,
215 names, 2, NULL );
218 static bool recquality(void)
220 return set_int(str(LANG_RECORDING_QUALITY), "", UNIT_INT,
221 &global_settings.rec_quality,
222 NULL, 1, 0, 7, NULL );
225 static bool receditable(void)
227 return set_bool(str(LANG_RECORDING_EDITABLE),
228 &global_settings.rec_editable);
231 static bool rectimesplit(void)
233 static const struct opt_items names[] = {
234 { STR(LANG_OFF) },
235 { "00:05" , TALK_ID(5, UNIT_MIN) },
236 { "00:10" , TALK_ID(10, UNIT_MIN) },
237 { "00:15" , TALK_ID(15, UNIT_MIN) },
238 { "00:30" , TALK_ID(30, UNIT_MIN) },
239 { "01:00" , TALK_ID(1, UNIT_HOUR) },
240 { "01:14" , TALK_ID(74, UNIT_MIN) },
241 { "01:20" , TALK_ID(80, UNIT_MIN) },
242 { "02:00" , TALK_ID(2, UNIT_HOUR) },
243 { "04:00" , TALK_ID(4, UNIT_HOUR) },
244 { "06:00" , TALK_ID(6, UNIT_HOUR) },
245 { "08:00" , TALK_ID(8, UNIT_HOUR) },
246 { "10:00" , TALK_ID(10, UNIT_HOUR) },
247 { "12:00" , TALK_ID(12, UNIT_HOUR) },
248 { "18:00" , TALK_ID(18, UNIT_HOUR) },
249 { "24:00" , TALK_ID(24, UNIT_HOUR) }
251 return set_option(str(LANG_RECORD_TIMESPLIT),
252 &global_settings.rec_timesplit, INT,
253 names, 16, NULL );
256 static bool recprerecord(void)
258 static const struct opt_items names[] = {
259 { STR(LANG_OFF) },
260 { "1s", TALK_ID(1, UNIT_SEC) },
261 { "2s", TALK_ID(2, UNIT_SEC) },
262 { "3s", TALK_ID(3, UNIT_SEC) },
263 { "4s", TALK_ID(4, UNIT_SEC) },
264 { "5s", TALK_ID(5, UNIT_SEC) },
265 { "6s", TALK_ID(6, UNIT_SEC) },
266 { "7s", TALK_ID(7, UNIT_SEC) },
267 { "8s", TALK_ID(8, UNIT_SEC) },
268 { "9s", TALK_ID(9, UNIT_SEC) },
269 { "10s", TALK_ID(10, UNIT_SEC) },
270 { "11s", TALK_ID(11, UNIT_SEC) },
271 { "12s", TALK_ID(12, UNIT_SEC) },
272 { "13s", TALK_ID(13, UNIT_SEC) },
273 { "14s", TALK_ID(14, UNIT_SEC) },
274 { "15s", TALK_ID(15, UNIT_SEC) },
275 { "16s", TALK_ID(16, UNIT_SEC) },
276 { "17s", TALK_ID(17, UNIT_SEC) },
277 { "18s", TALK_ID(18, UNIT_SEC) },
278 { "19s", TALK_ID(19, UNIT_SEC) },
279 { "20s", TALK_ID(20, UNIT_SEC) },
280 { "21s", TALK_ID(21, UNIT_SEC) },
281 { "22s", TALK_ID(22, UNIT_SEC) },
282 { "23s", TALK_ID(23, UNIT_SEC) },
283 { "24s", TALK_ID(24, UNIT_SEC) },
284 { "25s", TALK_ID(25, UNIT_SEC) },
285 { "26s", TALK_ID(26, UNIT_SEC) },
286 { "27s", TALK_ID(27, UNIT_SEC) },
287 { "28s", TALK_ID(28, UNIT_SEC) },
288 { "29s", TALK_ID(29, UNIT_SEC) },
289 { "30s", TALK_ID(30, UNIT_SEC) }
291 return set_option(str(LANG_RECORD_PRERECORD_TIME),
292 &global_settings.rec_prerecord_time, INT,
293 names, 31, NULL );
296 static bool recdirectory(void)
298 static const struct opt_items names[] = {
299 { rec_base_directory, -1 },
300 { STR(LANG_RECORD_CURRENT_DIR) }
302 return set_option(str(LANG_RECORD_DIRECTORY),
303 &global_settings.rec_directory, INT,
304 names, 2, NULL );
307 static bool reconstartup(void)
309 return set_bool(str(LANG_RECORD_STARTUP),
310 &global_settings.rec_startup);
313 #endif /* MAS3587F */
315 static bool chanconf(void)
317 static const struct opt_items names[] = {
318 { STR(LANG_CHANNEL_STEREO) },
319 { STR(LANG_CHANNEL_MONO) },
320 { STR(LANG_CHANNEL_CUSTOM) },
321 { STR(LANG_CHANNEL_LEFT) },
322 { STR(LANG_CHANNEL_RIGHT) },
323 { STR(LANG_CHANNEL_KARAOKE) }
325 return set_option(str(LANG_CHANNEL), &global_settings.channel_config, INT,
326 names, 6, sound_set_channels);
329 static bool stereo_width(void)
331 return set_sound(str(LANG_STEREO_WIDTH), &global_settings.stereo_width,
332 SOUND_STEREO_WIDTH);
335 bool sound_menu(void)
337 int m;
338 bool result;
339 static const struct menu_item items[] = {
340 { ID2P(LANG_VOLUME), volume },
341 { ID2P(LANG_BASS), bass },
342 { ID2P(LANG_TREBLE), treble },
343 { ID2P(LANG_BALANCE), balance },
344 { ID2P(LANG_CHANNEL_MENU), chanconf },
345 { ID2P(LANG_STEREO_WIDTH), stereo_width },
346 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
347 { ID2P(LANG_LOUDNESS), loudness },
348 { ID2P(LANG_AUTOVOL), avc },
349 { ID2P(LANG_SUPERBASS), superbass },
350 { ID2P(LANG_MDB_ENABLE), mdb_enable },
351 { ID2P(LANG_MDB_STRENGTH), mdb_strength },
352 { ID2P(LANG_MDB_HARMONICS), mdb_harmonics },
353 { ID2P(LANG_MDB_CENTER), mdb_center },
354 { ID2P(LANG_MDB_SHAPE), mdb_shape },
355 #endif
358 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
359 NULL, NULL, NULL);
360 result = menu_run(m);
361 menu_exit(m);
363 return result;
366 #ifdef HAVE_RECORDING
367 enum trigger_menu_option
369 TRIGGER_MODE,
370 PRERECORD_TIME,
371 START_THRESHOLD,
372 START_DURATION,
373 STOP_THRESHOLD,
374 STOP_POSTREC,
375 STOP_GAP,
376 TRIG_OPTION_COUNT,
379 #if !defined(SIMULATOR) && CONFIG_CODEC == MAS3587F
380 static char* create_thres_str(int threshold)
382 static char retval[6];
383 if (threshold < 0) {
384 if (threshold < -88) {
385 snprintf (retval, sizeof retval, "%s", str(LANG_DB_INF));
386 } else {
387 snprintf (retval, sizeof retval, "%ddb", threshold + 1);
389 } else {
390 snprintf (retval, sizeof retval, "%d%%", threshold);
392 return retval;
395 #define INF_DB (-89)
396 static void change_threshold(int *threshold, int change)
398 if (global_settings.peak_meter_dbfs) {
399 if (*threshold >= 0) {
400 int db = (calc_db(*threshold * MAX_PEAK / 100) - 9000) / 100;
401 *threshold = db;
403 *threshold += change;
404 if (*threshold > -1) {
405 *threshold = INF_DB;
406 } else if (*threshold < INF_DB) {
407 *threshold = -1;
409 } else {
410 if (*threshold < 0) {
411 *threshold = peak_meter_db2sample(*threshold * 100) * 100 / MAX_PEAK;
413 *threshold += change;
414 if (*threshold > 100) {
415 *threshold = 0;
416 } else if (*threshold < 0) {
417 *threshold = 100;
422 /* Variable button definitions */
423 #if CONFIG_KEYPAD == RECORDER_PAD
424 #define TRIG_CANCEL BUTTON_OFF
425 #define TRIG_ACCEPT BUTTON_PLAY
426 #define TRIG_RESET_SIM BUTTON_F2
428 #elif CONFIG_KEYPAD == ONDIO_PAD
429 #define TRIG_CANCEL BUTTON_OFF
430 #define TRIG_ACCEPT BUTTON_MENU
431 #endif
434 * Displays a menu for editing the trigger settings.
436 bool rectrigger(void)
438 int exit_request = false;
439 enum trigger_menu_option selected = TRIGGER_MODE;
440 bool retval = false;
441 int old_x_margin, old_y_margin;
443 #define TRIGGER_MODE_COUNT 3
444 static const unsigned char *trigger_modes[] = {
445 ID2P(LANG_OFF),
446 ID2P(LANG_RECORD_TRIG_NOREARM),
447 ID2P(LANG_RECORD_TRIG_REARM)
450 #define PRERECORD_TIMES_COUNT 31
451 static const unsigned char *prerecord_times[] = {
452 ID2P(LANG_OFF),"1s","2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s",
453 "10s", "11s", "12s", "13s", "14s", "15s", "16s", "17s", "18s", "19s",
454 "20s", "21s", "22s", "23s", "24s", "25s", "26s", "27s", "28s", "29s",
455 "30s"
458 static const unsigned char *option_name[] = {
459 [TRIGGER_MODE] = ID2P(LANG_RECORD_TRIGGER_MODE),
460 [PRERECORD_TIME] = ID2P(LANG_RECORD_PRERECORD_TIME),
461 [START_THRESHOLD] = ID2P(LANG_RECORD_START_THRESHOLD),
462 [START_DURATION] = ID2P(LANG_RECORD_MIN_DURATION),
463 [STOP_THRESHOLD] = ID2P(LANG_RECORD_STOP_THRESHOLD),
464 [STOP_POSTREC] = ID2P(LANG_RECORD_STOP_POSTREC),
465 [STOP_GAP] = ID2P(LANG_RECORD_STOP_GAP)
468 int old_start_thres = global_settings.rec_start_thres;
469 int old_start_duration = global_settings.rec_start_duration;
470 int old_prerecord_time = global_settings.rec_prerecord_time;
471 int old_stop_thres = global_settings.rec_stop_thres;
472 int old_stop_postrec = global_settings.rec_stop_postrec;
473 int old_stop_gap = global_settings.rec_stop_gap;
474 int old_trigger_mode = global_settings.rec_trigger_mode;
476 int offset = 0;
477 int option_lines;
478 int w, h;
480 /* restart trigger with new values */
481 settings_apply_trigger();
482 peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF);
484 lcd_clear_display();
486 old_x_margin = lcd_getxmargin();
487 old_y_margin = lcd_getymargin();
488 if(global_settings.statusbar)
489 lcd_setmargins(0, STATUSBAR_HEIGHT);
490 else
491 lcd_setmargins(0, 0);
493 lcd_getstringsize("M", &w, &h);
495 // two lines are reserved for peak meter and trigger status
496 option_lines = (LCD_HEIGHT/h) - (global_settings.statusbar ? 1:0) - 2;
498 while (!exit_request) {
499 int stat_height = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
500 int button, i;
501 const char *str;
502 char option_value[TRIG_OPTION_COUNT][7];
504 snprintf(
505 option_value[TRIGGER_MODE],
506 sizeof option_value[TRIGGER_MODE],
507 "%s",
508 P2STR(trigger_modes[global_settings.rec_trigger_mode]));
510 snprintf (
511 option_value[PRERECORD_TIME],
512 sizeof option_value[PRERECORD_TIME],
513 "%s",
514 P2STR(prerecord_times[global_settings.rec_prerecord_time]));
516 /* due to value range shift (peak_meter_define_trigger) -1 is 0db */
517 if (global_settings.rec_start_thres == -1) {
518 str = str(LANG_OFF);
519 } else {
520 str = create_thres_str(global_settings.rec_start_thres);
522 snprintf(
523 option_value[START_THRESHOLD],
524 sizeof option_value[START_THRESHOLD],
525 "%s",
526 str);
528 snprintf(
529 option_value[START_DURATION],
530 sizeof option_value[START_DURATION],
531 "%s",
532 trig_durations[global_settings.rec_start_duration]);
535 if (global_settings.rec_stop_thres <= INF_DB) {
536 str = str(LANG_OFF);
537 } else {
538 str = create_thres_str(global_settings.rec_stop_thres);
540 snprintf(
541 option_value[STOP_THRESHOLD],
542 sizeof option_value[STOP_THRESHOLD],
543 "%s",
544 str);
546 snprintf(
547 option_value[STOP_POSTREC],
548 sizeof option_value[STOP_POSTREC],
549 "%s",
550 trig_durations[global_settings.rec_stop_postrec]);
552 snprintf(
553 option_value[STOP_GAP],
554 sizeof option_value[STOP_GAP],
555 "%s",
556 trig_durations[global_settings.rec_stop_gap]);
558 lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
559 lcd_fillrect(0, stat_height, LCD_WIDTH, LCD_HEIGHT - stat_height);
560 lcd_set_drawmode(DRMODE_SOLID);
561 status_draw(true);
563 /* reselect FONT_SYSFONT as status_draw has changed the font */
564 /*lcd_setfont(FONT_SYSFIXED);*/
566 for (i = 0; i < option_lines; i++) {
567 int x, y;
569 str = P2STR(option_name[i + offset]);
570 lcd_putsxy(5, stat_height + i * h, str);
572 str = option_value[i + offset];
573 lcd_getstringsize(str, &w, &h);
574 y = stat_height + i * h;
575 x = LCD_WIDTH - w;
576 lcd_putsxy(x, y, str);
577 if ((int)selected == (i + offset)) {
578 lcd_set_drawmode(DRMODE_COMPLEMENT);
579 lcd_fillrect(x, y, w, h);
580 lcd_set_drawmode(DRMODE_SOLID);
584 scrollbar(0, stat_height,
585 4, LCD_HEIGHT - 16 - stat_height,
586 TRIG_OPTION_COUNT, offset, offset + option_lines,
587 VERTICAL);
589 peak_meter_draw_trig(0, LCD_HEIGHT - 8 - TRIG_HEIGHT);
591 button = peak_meter_draw_get_btn(0, LCD_HEIGHT - 8, LCD_WIDTH, 8);
593 lcd_update();
595 switch (button) {
596 case TRIG_CANCEL:
597 splash(50, true, str(LANG_RESET_DONE_CANCEL));
598 global_settings.rec_start_thres = old_start_thres;
599 global_settings.rec_start_duration = old_start_duration;
600 global_settings.rec_prerecord_time = old_prerecord_time;
601 global_settings.rec_stop_thres = old_stop_thres;
602 global_settings.rec_stop_postrec = old_stop_postrec;
603 global_settings.rec_stop_gap = old_stop_gap;
604 global_settings.rec_trigger_mode = old_trigger_mode;
605 exit_request = true;
606 break;
608 case TRIG_ACCEPT:
609 exit_request = true;
610 break;
612 case BUTTON_UP:
613 selected += TRIG_OPTION_COUNT - 1;
614 selected %= TRIG_OPTION_COUNT;
615 offset = MIN(offset, (int)selected);
616 offset = MAX(offset, (int)selected - option_lines + 1);
617 break;
619 case BUTTON_DOWN:
620 selected ++;
621 selected %= TRIG_OPTION_COUNT;
622 offset = MIN(offset, (int)selected);
623 offset = MAX(offset, (int)selected - option_lines + 1);
624 break;
626 case BUTTON_RIGHT:
627 case BUTTON_RIGHT | BUTTON_REPEAT:
628 switch (selected) {
629 case TRIGGER_MODE:
630 global_settings.rec_trigger_mode ++;
631 global_settings.rec_trigger_mode %= TRIGGER_MODE_COUNT;
632 break;
634 case PRERECORD_TIME:
635 global_settings.rec_prerecord_time ++;
636 global_settings.rec_prerecord_time %= PRERECORD_TIMES_COUNT;
637 break;
639 case START_THRESHOLD:
640 change_threshold(&global_settings.rec_start_thres, 1);
641 break;
643 case START_DURATION:
644 global_settings.rec_start_duration ++;
645 global_settings.rec_start_duration %= TRIG_DURATION_COUNT;
646 break;
648 case STOP_THRESHOLD:
649 change_threshold(&global_settings.rec_stop_thres, 1);
650 break;
652 case STOP_POSTREC:
653 global_settings.rec_stop_postrec ++;
654 global_settings.rec_stop_postrec %= TRIG_DURATION_COUNT;
655 break;
657 case STOP_GAP:
658 global_settings.rec_stop_gap ++;
659 global_settings.rec_stop_gap %= TRIG_DURATION_COUNT;
660 break;
662 case TRIG_OPTION_COUNT:
663 // avoid compiler warnings
664 break;
666 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
667 settings_apply_trigger();
668 break;
670 case BUTTON_LEFT:
671 case BUTTON_LEFT | BUTTON_REPEAT:
672 switch (selected) {
673 case TRIGGER_MODE:
674 global_settings.rec_trigger_mode+=TRIGGER_MODE_COUNT-1;
675 global_settings.rec_trigger_mode %= TRIGGER_MODE_COUNT;
676 break;
678 case PRERECORD_TIME:
679 global_settings.rec_prerecord_time += PRERECORD_TIMES_COUNT - 1;
680 global_settings.rec_prerecord_time %= PRERECORD_TIMES_COUNT;
681 break;
683 case START_THRESHOLD:
684 change_threshold(&global_settings.rec_start_thres, -1);
685 break;
687 case START_DURATION:
688 global_settings.rec_start_duration += TRIG_DURATION_COUNT-1;
689 global_settings.rec_start_duration %= TRIG_DURATION_COUNT;
690 break;
692 case STOP_THRESHOLD:
693 change_threshold(&global_settings.rec_stop_thres, -1);
694 break;
696 case STOP_POSTREC:
697 global_settings.rec_stop_postrec +=
698 TRIG_DURATION_COUNT - 1;
699 global_settings.rec_stop_postrec %=
700 TRIG_DURATION_COUNT;
701 break;
703 case STOP_GAP:
704 global_settings.rec_stop_gap +=
705 TRIG_DURATION_COUNT - 1;
706 global_settings.rec_stop_gap %= TRIG_DURATION_COUNT;
707 break;
709 case TRIG_OPTION_COUNT:
710 // avoid compiler warnings
711 break;
713 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
714 settings_apply_trigger();
715 break;
717 #ifdef TRIG_RESET_SIM
718 case TRIG_RESET_SIM:
719 peak_meter_trigger(true);
720 break;
721 #endif
723 case SYS_USB_CONNECTED:
724 if(default_event_handler(button) == SYS_USB_CONNECTED) {
725 retval = true;
726 exit_request = true;
728 break;
732 peak_meter_trigger(false);
733 lcd_setfont(FONT_UI);
734 lcd_setmargins(old_x_margin, old_y_margin);
735 return retval;
737 #endif
739 bool recording_menu(bool no_source)
741 int m;
742 int i = 0;
743 struct menu_item items[10];
744 bool result;
746 items[i].desc = ID2P(LANG_RECORDING_QUALITY);
747 items[i++].function = recquality;
748 items[i].desc = ID2P(LANG_RECORDING_FREQUENCY);
749 items[i++].function = recfrequency;
750 if(!no_source) {
751 items[i].desc = ID2P(LANG_RECORDING_SOURCE);
752 items[i++].function = recsource;
754 items[i].desc = ID2P(LANG_RECORDING_CHANNELS);
755 items[i++].function = recchannels;
756 items[i].desc = ID2P(LANG_RECORDING_EDITABLE);
757 items[i++].function = receditable;
758 items[i].desc = ID2P(LANG_RECORD_TIMESPLIT);
759 items[i++].function = rectimesplit;
760 items[i].desc = ID2P(LANG_RECORD_PRERECORD_TIME);
761 items[i++].function = recprerecord;
762 items[i].desc = ID2P(LANG_RECORD_DIRECTORY);
763 items[i++].function = recdirectory;
764 items[i].desc = ID2P(LANG_RECORD_STARTUP);
765 items[i++].function = reconstartup;
766 #if !defined(SIMULATOR) && CONFIG_CODEC == MAS3587F
767 items[i].desc = ID2P(LANG_RECORD_TRIGGER);
768 items[i++].function = rectrigger;
769 #endif
771 m=menu_init( items, i, NULL, NULL, NULL, NULL);
772 result = menu_run(m);
773 menu_exit(m);
775 return result;
777 #endif