wave/wave64: parse LIST chunk.
[kugel-rb.git] / apps / menus / recording_menu.c
blobdaea1ea8fc79739e7a6c0e658912b16e7af50e51
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "config.h"
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <stdbool.h>
26 #include "string.h"
27 #include "system.h"
28 #include "kernel.h"
29 #include "lcd.h"
30 #include "menu.h"
31 #include "button.h"
32 #include "mp3_playback.h"
33 #include "settings.h"
34 #include "screens.h"
35 #include "icons.h"
36 #ifdef HAVE_LCD_BITMAP
37 #include "font.h"
38 #include "scrollbar.h"
39 #endif
40 #include "lang.h"
41 #include "talk.h"
42 #include "misc.h"
43 #include "sound.h"
44 #ifdef HAVE_RECORDING
45 #include "audio.h"
46 #if CONFIG_TUNER
47 #include "radio.h"
48 #endif
49 #endif
50 #ifdef HAVE_RECORDING
51 #include "peakmeter.h"
52 #include "mas.h"
53 #endif
54 #include "splash.h"
55 #if CONFIG_CODEC == SWCODEC
56 #include "metadata.h"
57 #include "dsp.h"
58 #include "menus/eq_menu.h"
59 #ifdef HAVE_RECORDING
60 #include "enc_config.h"
61 #endif
62 #include "general.h"
63 #endif
64 #include "action.h"
65 #include "recording.h"
66 #include "sound_menu.h"
67 #include "option_select.h"
68 #include "settings_list.h"
69 #include "list.h"
70 #include "viewport.h"
71 #include "exported_menus.h"
73 static bool no_source_in_menu = false;
74 static int recmenu_callback(int action,const struct menu_item_ex *this_item);
76 static int recsource_func(void)
78 int n_opts = REC_NUM_SOURCES;
80 static const struct opt_items names[AUDIO_NUM_SOURCES] = {
81 HAVE_MIC_REC_([AUDIO_SRC_MIC]
82 = { STR(LANG_RECORDING_SRC_MIC) },)
83 HAVE_LINE_REC_([AUDIO_SRC_LINEIN]
84 = { STR(LANG_LINE_IN) },)
85 HAVE_SPDIF_REC_([AUDIO_SRC_SPDIF]
86 = { STR(LANG_RECORDING_SRC_DIGITAL) },)
87 HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO]
88 = { STR(LANG_FM_RADIO) },)
91 /* caveat: assumes it's the last item! */
92 #ifdef HAVE_FMRADIO_REC
93 if (!radio_hardware_present())
94 n_opts--;
95 #endif
97 return set_option(str(LANG_RECORDING_SOURCE),
98 &global_settings.rec_source, INT, names,
99 n_opts, NULL );
101 MENUITEM_FUNCTION(recsource, 0, ID2P(LANG_RECORDING_SOURCE),
102 recsource_func, NULL, recmenu_callback, Icon_Menu_setting);
104 #if CONFIG_CODEC == SWCODEC
105 /* Makes an options list from a source list of options and indexes */
106 static void make_options_from_indexes(const struct opt_items *src_names,
107 const long *src_indexes,
108 int n_indexes,
109 struct opt_items *dst_names)
111 while (--n_indexes >= 0)
112 dst_names[n_indexes] = src_names[src_indexes[n_indexes]];
113 } /* make_options_from_indexes */
116 #endif /* CONFIG_CODEC == SWCODEC */
118 static int recfrequency_func(void)
120 #if CONFIG_CODEC == MAS3587F
121 static const struct opt_items names[6] = {
122 { "44.1kHz", TALK_ID(44, UNIT_KHZ) },
123 { "48kHz", TALK_ID(48, UNIT_KHZ) },
124 { "32kHz", TALK_ID(32, UNIT_KHZ) },
125 { "22.05kHz", TALK_ID(22, UNIT_KHZ) },
126 { "24kHz", TALK_ID(24, UNIT_KHZ) },
127 { "16kHz", TALK_ID(16, UNIT_KHZ) }
129 return set_option(str(LANG_RECORDING_FREQUENCY),
130 &global_settings.rec_frequency, INT,
131 names, 6, NULL );
132 #endif /* CONFIG_CODEC == MAS3587F */
134 #if CONFIG_CODEC == SWCODEC
135 static const struct opt_items names[REC_NUM_FREQ] = {
136 REC_HAVE_96_([REC_FREQ_96] = { "96kHz", TALK_ID(96, UNIT_KHZ) },)
137 REC_HAVE_88_([REC_FREQ_88] = { "88.2kHz", TALK_ID(88, UNIT_KHZ) },)
138 REC_HAVE_64_([REC_FREQ_64] = { "64kHz", TALK_ID(64, UNIT_KHZ) },)
139 REC_HAVE_48_([REC_FREQ_48] = { "48kHz", TALK_ID(48, UNIT_KHZ) },)
140 REC_HAVE_44_([REC_FREQ_44] = { "44.1kHz", TALK_ID(44, UNIT_KHZ) },)
141 REC_HAVE_32_([REC_FREQ_32] = { "32kHz", TALK_ID(32, UNIT_KHZ) },)
142 REC_HAVE_24_([REC_FREQ_24] = { "24kHz", TALK_ID(24, UNIT_KHZ) },)
143 REC_HAVE_22_([REC_FREQ_22] = { "22.05kHz", TALK_ID(22, UNIT_KHZ) },)
144 REC_HAVE_16_([REC_FREQ_16] = { "16kHz", TALK_ID(16, UNIT_KHZ) },)
145 REC_HAVE_12_([REC_FREQ_12] = { "12kHz", TALK_ID(12, UNIT_KHZ) },)
146 REC_HAVE_11_([REC_FREQ_11] = { "11.025kHz", TALK_ID(11, UNIT_KHZ) },)
147 REC_HAVE_8_( [REC_FREQ_8 ] = { "8kHz", TALK_ID( 8, UNIT_KHZ) },)
150 struct opt_items opts[REC_NUM_FREQ];
151 unsigned long table[REC_NUM_FREQ];
152 int n_opts;
153 int rec_frequency;
154 bool ret;
156 #ifdef HAVE_SPDIF_REC
157 if (global_settings.rec_source == REC_SRC_SPDIF)
159 /* Inform user that frequency follows the source's frequency */
160 opts[0].string = ID2P(LANG_SOURCE_FREQUENCY);
161 opts[0].voice_id = LANG_SOURCE_FREQUENCY;
162 n_opts = 1;
163 rec_frequency = 0;
165 else
166 #endif
168 struct encoder_caps caps;
169 struct encoder_config cfg;
171 cfg.rec_format = global_settings.rec_format;
172 global_to_encoder_config(&cfg);
174 if (!enc_get_caps(&cfg, &caps, true))
175 return false;
177 /* Construct samplerate menu based upon encoder settings */
178 n_opts = make_list_from_caps32(REC_SAMPR_CAPS, NULL,
179 caps.samplerate_caps, table);
181 if (n_opts == 0)
182 return false; /* No common flags...?? */
184 make_options_from_indexes(names, table, n_opts, opts);
186 /* Find closest rate that the potentially restricted list
187 comes to */
188 make_list_from_caps32(REC_SAMPR_CAPS, rec_freq_sampr,
189 caps.samplerate_caps, table);
191 rec_frequency = round_value_to_list32(
192 rec_freq_sampr[global_settings.rec_frequency],
193 table, n_opts, false);
196 ret = set_option(str(LANG_RECORDING_FREQUENCY),
197 &rec_frequency, INT, opts, n_opts, NULL );
199 if (!ret
200 HAVE_SPDIF_REC_( && global_settings.rec_source != REC_SRC_SPDIF)
203 /* Translate back to full index */
204 global_settings.rec_frequency =
205 round_value_to_list32(table[rec_frequency],
206 rec_freq_sampr,
207 REC_NUM_FREQ,
208 false);
211 return ret;
212 #endif /* CONFIG_CODEC == SWCODEC */
213 } /* recfrequency */
214 MENUITEM_FUNCTION(recfrequency, 0, ID2P(LANG_RECORDING_FREQUENCY),
215 recfrequency_func, NULL, NULL, Icon_Menu_setting);
218 static int recchannels_func(void)
220 static const struct opt_items names[CHN_NUM_MODES] = {
221 [CHN_MODE_STEREO] = { STR(LANG_CHANNEL_STEREO) },
222 [CHN_MODE_MONO] = { STR(LANG_CHANNEL_MONO) }
224 #if CONFIG_CODEC == MAS3587F
225 return set_option(str(LANG_CHANNELS),
226 &global_settings.rec_channels, INT,
227 names, CHN_NUM_MODES, NULL );
228 #endif /* CONFIG_CODEC == MAS3587F */
230 #if CONFIG_CODEC == SWCODEC
231 struct opt_items opts[CHN_NUM_MODES];
232 long table[CHN_NUM_MODES];
233 struct encoder_caps caps;
234 struct encoder_config cfg;
235 int n_opts;
236 int rec_channels;
237 bool ret;
239 cfg.rec_format = global_settings.rec_format;
240 global_to_encoder_config(&cfg);
242 if (!enc_get_caps(&cfg, &caps, true))
243 return false;
245 n_opts = make_list_from_caps32(CHN_CAP_ALL, NULL,
246 caps.channel_caps, table);
248 rec_channels = round_value_to_list32(global_settings.rec_channels,
249 table, n_opts, false);
251 make_options_from_indexes(names, table, n_opts, opts);
253 ret = set_option(str(LANG_CHANNELS), &rec_channels,
254 INT, opts, n_opts, NULL );
256 if (!ret)
257 global_settings.rec_channels = table[rec_channels];
259 return ret;
260 #endif /* CONFIG_CODEC == SWCODEC */
262 MENUITEM_FUNCTION(recchannels, 0, ID2P(LANG_CHANNELS),
263 recchannels_func, NULL, NULL, Icon_Menu_setting);
265 #if CONFIG_CODEC == SWCODEC
267 static int recmonomode_func(void)
269 static const struct opt_items names[3] = {
270 [0] = { STR(LANG_CHANNEL_LEFTRIGHT) },
271 [1] = { STR(LANG_CHANNEL_LEFT) },
272 [2] = { STR(LANG_CHANNEL_RIGHT) },
275 int rec_mono_mode = global_settings.rec_mono_mode;
276 bool ret = set_option(str(LANG_RECORDING_MONO_MODE), &rec_mono_mode,
277 INT, names, 3, NULL );
279 if (rec_mono_mode != global_settings.rec_mono_mode)
280 global_settings.rec_mono_mode = rec_mono_mode;
282 return ret;
284 MENUITEM_FUNCTION(recmonomode, 0, ID2P(LANG_RECORDING_MONO_MODE),
285 recmonomode_func, NULL, NULL, Icon_Menu_setting);
287 static int recformat_func(void)
289 static const struct opt_items names[REC_NUM_FORMATS] = {
290 [REC_FORMAT_AIFF] = { STR(LANG_AFMT_AIFF) },
291 [REC_FORMAT_MPA_L3] = { STR(LANG_AFMT_MPA_L3) },
292 [REC_FORMAT_WAVPACK] = { STR(LANG_AFMT_WAVPACK) },
293 [REC_FORMAT_PCM_WAV] = { STR(LANG_AFMT_PCM_WAV) },
296 int rec_format = global_settings.rec_format;
297 bool res = set_option(str(LANG_RECORDING_FORMAT), &rec_format, INT,
298 names, REC_NUM_FORMATS, NULL );
300 if (rec_format != global_settings.rec_format)
302 global_settings.rec_format = rec_format;
303 enc_global_settings_apply();
306 return res;
307 } /* recformat */
308 MENUITEM_FUNCTION(recformat, 0, ID2P(LANG_RECORDING_FORMAT),
309 recformat_func, NULL, NULL, Icon_Menu_setting);
311 MENUITEM_FUNCTION(enc_global_config_menu_item, 0, ID2P(LANG_ENCODER_SETTINGS),
312 (int(*)(void))enc_global_config_menu,
313 NULL, NULL, Icon_Submenu);
315 #endif /* CONFIG_CODEC == SWCODEC */
318 static int recmenu_callback(int action,const struct menu_item_ex *this_item)
320 switch (action)
322 case ACTION_REQUEST_MENUITEM:
323 if (this_item == &recsource && no_source_in_menu)
324 return ACTION_EXIT_MENUITEM;
325 break;
327 return action;
329 #if CONFIG_CODEC == MAS3587F
330 MENUITEM_SETTING(rec_quality, &global_settings.rec_quality, NULL);
331 MENUITEM_SETTING(rec_editable, &global_settings.rec_editable, NULL);
332 #endif
334 MENUITEM_SETTING(rec_split_type, &global_settings.rec_split_type, NULL);
335 MENUITEM_SETTING(rec_split_method, &global_settings.rec_split_method, NULL);
336 MENUITEM_SETTING(rec_timesplit, &global_settings.rec_timesplit, NULL);
337 MENUITEM_SETTING(rec_sizesplit, &global_settings.rec_sizesplit, NULL);
338 MAKE_MENU(filesplitoptionsmenu, ID2P(LANG_RECORD_TIMESPLIT), NULL, Icon_NOICON,
339 &rec_split_method, &rec_split_type, &rec_timesplit, &rec_sizesplit);
342 MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL);
344 static int clear_rec_directory(void)
346 strcpy(global_settings.rec_directory, REC_BASE_DIR);
347 splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
348 return false;
350 MENUITEM_FUNCTION(clear_rec_directory_item, 0, ID2P(LANG_CLEAR_REC_DIR),
351 clear_rec_directory, NULL, NULL, Icon_Folder);
353 MENUITEM_SETTING(cliplight, &global_settings.cliplight, NULL);
355 #ifdef HAVE_AGC
356 static int agc_preset_func(void)
358 static const struct opt_items names[] = {
359 { STR(LANG_OFF) },
360 { STR(LANG_AGC_SAFETY) },
361 { STR(LANG_AGC_LIVE) },
362 { STR(LANG_AGC_DJSET) },
363 { STR(LANG_AGC_MEDIUM) },
364 { STR(LANG_AGC_VOICE) },
366 if (global_settings.rec_source)
367 return set_option(str(LANG_RECORDING_AGC_PRESET),
368 &global_settings.rec_agc_preset_line,
369 INT, names, 6, NULL );
370 else
371 return set_option(str(LANG_RECORDING_AGC_PRESET),
372 &global_settings.rec_agc_preset_mic,
373 INT, names, 6, NULL );
376 static int agc_cliptime_func(void)
378 static const struct opt_items names[] = {
379 { "200ms", TALK_ID(200, UNIT_MS) },
380 { "400ms", TALK_ID(400, UNIT_MS) },
381 { "600ms", TALK_ID(600, UNIT_MS) },
382 { "800ms", TALK_ID(800, UNIT_MS) },
383 { "1s", TALK_ID(1, UNIT_SEC) }
385 return set_option(str(LANG_RECORDING_AGC_CLIPTIME),
386 &global_settings.rec_agc_cliptime,
387 INT, names, 5, NULL );
389 MENUITEM_FUNCTION(agc_preset, 0, ID2P(LANG_RECORDING_AGC_PRESET),
390 agc_preset_func, NULL, NULL, Icon_Menu_setting);
391 MENUITEM_FUNCTION(agc_cliptime, 0, ID2P(LANG_RECORDING_AGC_CLIPTIME),
392 agc_cliptime_func, NULL, NULL, Icon_Menu_setting);
393 #endif /* HAVE_AGC */
395 #if defined(HAVE_RECORDING_HISTOGRAM)
396 static bool history_interval(void)
398 static const struct opt_items names[] = {
399 { "0s", TALK_ID(0, UNIT_SEC) },
400 { "1s", TALK_ID(1, UNIT_SEC) },
401 { "2s", TALK_ID(2, UNIT_SEC) },
402 { "4s", TALK_ID(4, UNIT_SEC) }
404 return set_option(str(LANG_RECORDING_HISTOGRAM_INTERVAL),
405 &global_settings.rec_histogram_interval,
406 INT, names, 4, NULL );
409 MENUITEM_FUNCTION(recording_histogram, 0,
410 ID2P(LANG_RECORDING_HISTOGRAM_INTERVAL),
411 history_interval, NULL, NULL, Icon_Menu_setting);
413 #endif
415 /** Rec trigger **/
416 enum trigger_menu_option
418 TRIGGER_MODE,
419 TRIGGER_TYPE,
420 PRERECORD_TIME,
421 START_THRESHOLD,
422 START_DURATION,
423 STOP_THRESHOLD,
424 STOP_POSTREC,
425 STOP_GAP,
426 TRIG_OPTION_COUNT,
429 static enum themable_icons trigger_get_icon(int selected_item, void * data)
431 (void)data;
432 if ((selected_item % 2) == 0) /* header */
433 return Icon_Menu_setting;
434 return Icon_NOICON;
437 static const char * trigger_get_name(int selected_item, void * data,
438 char * buffer, size_t buffer_len)
440 const struct settings_list **settings =
441 (const struct settings_list **)data;
442 const struct settings_list *s = settings[selected_item / 2];
443 if ((selected_item % 2) == 0) /* header */
444 return P2STR(ID2P(s->lang_id));
445 else
447 int temp;
448 temp = option_value_as_int(s);
449 if ((selected_item / 2 == START_THRESHOLD ||
450 selected_item / 2 == STOP_THRESHOLD) &&
451 temp == 0)
453 return str(LANG_OFF);
455 return option_get_valuestring(s, buffer, buffer_len, temp);
458 static void trigger_speak_item(const struct settings_list **settings,
459 int selected_setting, bool title)
461 const struct settings_list *s = settings[selected_setting];
462 int temp;
463 if (!global_settings.talk_menu)
464 return;
465 if (title)
466 talk_id(s->lang_id, false);
467 temp = option_value_as_int(s);
468 if ((selected_setting == START_THRESHOLD ||
469 selected_setting == STOP_THRESHOLD) &&
470 temp == 0)
472 talk_id(LANG_OFF, title);
473 } else {
474 option_talk_value(s, temp, title);
477 int rectrigger(void)
479 struct viewport vp[NB_SCREENS], triggervp[NB_SCREENS];
480 struct gui_synclist lists;
481 int i, action = ACTION_REDRAW;
482 bool done = false, changed = true;
483 const struct settings_list *settings[TRIG_OPTION_COUNT];
485 int pm_x[NB_SCREENS];
486 int pm_y[NB_SCREENS];
487 int pm_h[NB_SCREENS];
488 int trig_xpos[NB_SCREENS];
489 int trig_ypos[NB_SCREENS];
490 int trig_width[NB_SCREENS];
492 int old_start_thres_db = global_settings.rec_start_thres_db;
493 int old_start_thres_linear = global_settings.rec_start_thres_linear;
494 int old_start_duration = global_settings.rec_start_duration;
495 int old_prerecord_time = global_settings.rec_prerecord_time;
496 int old_stop_thres_db = global_settings.rec_stop_thres_db;
497 int old_stop_thres_linear = global_settings.rec_stop_thres_linear;
498 int old_stop_postrec = global_settings.rec_stop_postrec;
499 int old_stop_gap = global_settings.rec_stop_gap;
500 int old_trigger_mode = global_settings.rec_trigger_mode;
501 int old_trigger_type = global_settings.rec_trigger_type;
503 FOR_NB_SCREENS(i)
505 screens[i].clear_display();
506 screens[i].update();
507 viewport_set_defaults(&vp[i], i);
508 vp[i].height -= SYSFONT_HEIGHT*2;
509 triggervp[i] = vp[i];
510 triggervp[i].y = vp[i].y + vp[i].height;
511 triggervp[i].height = SYSFONT_HEIGHT*2;
512 trig_xpos[i] = 0;
513 trig_ypos[i] = 0;
514 pm_x[i] = 0;
515 pm_y[i] = SYSFONT_HEIGHT;
516 pm_h[i] = SYSFONT_HEIGHT;
517 trig_width[i] = triggervp[i].width;
519 /* TODO: what to do if there is < 4 lines on the screen? */
521 settings[TRIGGER_MODE] =
522 find_setting(&global_settings.rec_trigger_mode, NULL);
523 settings[TRIGGER_TYPE] =
524 find_setting(&global_settings.rec_trigger_type, NULL);
525 settings[PRERECORD_TIME] =
526 find_setting(&global_settings.rec_prerecord_time, NULL);
527 settings[START_DURATION] =
528 find_setting(&global_settings.rec_start_duration, NULL);
529 settings[STOP_POSTREC] =
530 find_setting(&global_settings.rec_stop_postrec, NULL);
531 settings[STOP_GAP] =
532 find_setting(&global_settings.rec_stop_gap, NULL);
533 if (global_settings.peak_meter_dbfs) /* show the dB settings */
535 settings[START_THRESHOLD] =
536 find_setting(&global_settings.rec_start_thres_db, NULL);
537 settings[STOP_THRESHOLD] =
538 find_setting(&global_settings.rec_stop_thres_db, NULL);
540 else
542 settings[START_THRESHOLD] =
543 find_setting(&global_settings.rec_start_thres_linear, NULL);
544 settings[STOP_THRESHOLD] =
545 find_setting(&global_settings.rec_stop_thres_linear, NULL);
547 gui_synclist_init(&lists, trigger_get_name, settings, false, 2, vp);
548 gui_synclist_set_nb_items(&lists, TRIG_OPTION_COUNT*2);
549 gui_synclist_set_icon_callback(&lists, global_settings.show_icons?trigger_get_icon:NULL);
550 /* restart trigger with new values */
551 settings_apply_trigger();
552 peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF);
554 trigger_speak_item(settings, 0, true);
556 while (!done)
558 if (changed)
560 gui_synclist_draw(&lists);
561 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
562 settings_apply_trigger();
563 changed = false;
566 FOR_NB_SCREENS(i)
567 screens[i].set_viewport(&triggervp[i]);
568 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS);
569 action = peak_meter_draw_get_btn(CONTEXT_SETTINGS_RECTRIGGER,
570 pm_x, pm_y, pm_h, NB_SCREENS, triggervp);
571 FOR_NB_SCREENS(i)
572 screens[i].update();
573 i = gui_synclist_get_sel_pos(&lists);
574 switch (action)
576 case ACTION_STD_CANCEL:
577 splash(HZ/2, ID2P(LANG_CANCEL));
578 global_settings.rec_start_thres_db = old_start_thres_db;
579 global_settings.rec_start_thres_linear = old_start_thres_linear;
580 global_settings.rec_start_duration = old_start_duration;
581 global_settings.rec_prerecord_time = old_prerecord_time;
582 global_settings.rec_stop_thres_db = old_stop_thres_db;
583 global_settings.rec_stop_thres_linear = old_stop_thres_linear;
584 global_settings.rec_stop_postrec = old_stop_postrec;
585 global_settings.rec_stop_gap = old_stop_gap;
586 global_settings.rec_trigger_mode = old_trigger_mode;
587 global_settings.rec_trigger_type = old_trigger_type;
588 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
589 settings_apply_trigger();
590 done = true;
591 break;
592 case ACTION_STD_OK:
593 done = true;
594 break;
595 case ACTION_SETTINGS_DEC:
596 case ACTION_SETTINGS_DECREPEAT:
597 option_select_next_val(settings[i/2], true, false);
598 trigger_speak_item(settings, i/2, false);
599 changed = true;
600 break;
601 case ACTION_SETTINGS_INC:
602 case ACTION_SETTINGS_INCREPEAT:
603 option_select_next_val(settings[i/2], false, false);
604 trigger_speak_item(settings, i/2, false);
605 changed = true;
606 break;
607 case ACTION_STD_PREV:
608 case ACTION_STD_PREVREPEAT:
609 i -= 2;
610 if (i<0)
611 i = (TRIG_OPTION_COUNT*2) - 2;
612 gui_synclist_select_item(&lists, i);
613 i = gui_synclist_get_sel_pos(&lists);
614 trigger_speak_item(settings, i/2, true);
615 changed = true;
616 break;
617 case ACTION_STD_NEXT:
618 case ACTION_STD_NEXTREPEAT:
619 gui_synclist_select_item(&lists, (i+2) % (TRIG_OPTION_COUNT*2));
620 i = gui_synclist_get_sel_pos(&lists);
621 trigger_speak_item(settings, i/2, true);
622 changed = true;
623 break;
626 peak_meter_trigger(false);
627 settings_save();
628 return 0;
630 MENUITEM_FUNCTION(rectrigger_item, 0, ID2P(LANG_RECORD_TRIGGER),
631 rectrigger, NULL, NULL, Icon_Menu_setting);
633 static struct browse_folder_info rec_config_browse = {RECPRESETS_DIR, SHOW_CFG};
634 MENUITEM_FUNCTION(browse_recconfigs, MENU_FUNC_USEPARAM, ID2P(LANG_CUSTOM_CFG),
635 browse_folder, (void*)&rec_config_browse, NULL, Icon_Config);
636 static int write_settings_file(void)
638 return settings_save_config(SETTINGS_SAVE_RECPRESETS);
640 MENUITEM_FUNCTION(save_recpresets_item, 0, ID2P(LANG_SAVE_SETTINGS),
641 write_settings_file, NULL, NULL, Icon_Config);
643 MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS),
644 NULL, Icon_Recording,
645 #if CONFIG_CODEC == MAS3587F
646 &rec_quality,
647 #endif
648 #if CONFIG_CODEC == SWCODEC
649 &recformat, &enc_global_config_menu_item,
650 #endif
651 &recfrequency, &recsource, /* recsource not shown if no_source */
652 &recchannels,
653 #if CONFIG_CODEC == SWCODEC
654 &recmonomode,
655 #endif
656 #if CONFIG_CODEC == MAS3587F
657 &rec_editable,
658 #endif
659 &filesplitoptionsmenu,
660 &rec_prerecord_time,
661 &clear_rec_directory_item,
662 #ifdef HAVE_BACKLIGHT
663 &cliplight,
664 #endif
665 &rectrigger_item,
666 #ifdef HAVE_AGC
667 &agc_preset, &agc_cliptime,
668 #endif
669 #if defined(HAVE_RECORDING_HISTOGRAM)
670 &recording_histogram,
671 #endif
672 #ifdef HAVE_LCD_BITMAP
673 &peak_meter_menu,
674 #endif
675 &browse_recconfigs, &save_recpresets_item
678 bool recording_menu(bool no_source)
680 bool retval;
681 no_source_in_menu = no_source;
682 retval = do_menu(&recording_settings_menu, NULL, NULL, false) == MENU_ATTACHED_USB;
683 no_source_in_menu = false; /* always fall back to the default */
684 return retval;
687 MENUITEM_FUNCTION(recording_settings, MENU_FUNC_USEPARAM, ID2P(LANG_RECORDING_SETTINGS),
688 (int (*)(void*))recording_menu, 0, NULL, Icon_Recording);