Index: apps/recorder/recording.c
===================================================================
--- apps/recorder/recording.c (revision 17489)
+++ apps/recorder/recording.c (working copy)
@@ -143,12 +143,23 @@
10*HZ, 15*HZ, 20*HZ, 25*HZ, 30*HZ,
60*HZ, 2*60*HZ, 5*60*HZ, 10*60*HZ
};
+ int start_thres, stop_thres;
+ if (global_settings.peak_meter_dbfs)
+ {
+ start_thres = global_settings.rec_start_thres_db - 1;
+ stop_thres = global_settings.rec_stop_thres_db - 1;
+ }
+ else
+ {
+ start_thres = global_settings.rec_start_thres_linear;
+ stop_thres = global_settings.rec_stop_thres_linear;
+ }
peak_meter_define_trigger(
- global_settings.rec_start_thres,
+ start_thres,
trigger_times[global_settings.rec_start_duration],
MIN(trigger_times[global_settings.rec_start_duration] / 2, 2*HZ),
- global_settings.rec_stop_thres,
+ stop_thres,
trigger_times[global_settings.rec_stop_postrec],
trigger_times[global_settings.rec_stop_gap]
);
@@ -775,12 +786,12 @@
else
{
if((audio_status() & AUDIO_STATUS_PAUSE) &&
- (global_settings.rec_trigger_type == 1))
+ (global_settings.rec_trigger_type == TRIG_TYPE_PAUSE))
{
rec_command(RECORDING_CMD_RESUME);
}
/* New file on trig start*/
- else if (global_settings.rec_trigger_type != 2)
+ else if (global_settings.rec_trigger_type != TRIG_TYPE_NEW_FILE)
{
rec_command(RECORDING_CMD_START_NEWFILE);
/* tell recording_screen to reset the time */
@@ -795,15 +806,15 @@
{
switch(global_settings.rec_trigger_type)
{
- case 0: /* Stop */
+ case TRIG_TYPE_STOP: /* Stop */
rec_command(RECORDING_CMD_STOP);
break;
- case 1: /* Pause */
+ case TRIG_TYPE_PAUSE: /* Pause */
rec_command(RECORDING_CMD_PAUSE);
break;
- case 2: /* New file on trig stop*/
+ case TRIG_TYPE_NEW_FILE: /* New file on trig stop*/
rec_command(RECORDING_CMD_START_NEWFILE);
/* tell recording_screen to reset the time */
last_seconds = 0;
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang (revision 17489)
+++ apps/lang/english.lang (working copy)
@@ -11696,3 +11696,20 @@
*: "OK"
+
+ id: LANG_UNDO_CHANGES
+ desc: in the trigger settings menu
+ user:
+
+ *: none
+ recording: "Undo Changes"
+
+
+ *: none
+ recording: "Undo Changes"
+
+
+ *: none
+ recording: "Undo Changes"
+
+
Index: apps/gui/option_select.c
===================================================================
--- apps/gui/option_select.c (revision 17489)
+++ apps/gui/option_select.c (working copy)
@@ -230,15 +230,18 @@
else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
{
struct int_setting *info = (struct int_setting *)setting->int_setting;
+ int step = info->step;
+ if (step < 0)
+ step = -step;
if (!previous)
{
- val = *value + info->step;
+ val = *value + step;
if (val > info->max)
val = info->min;
}
else
{
- val = *value - info->step;
+ val = *value - step;
if (val < info->min)
val = info->max;
}
@@ -283,6 +286,22 @@
if (apply && info->option_callback)
info->option_callback(*(int*)value);
}
+ else if ((setting->flags & F_TABLE_SETTING) == F_TABLE_SETTING)
+ {
+ const struct table_setting *tbl_info = setting->table_setting;
+ int i, add;
+ add = previous?tbl_info->count-1:1;
+ for (i=0; icount;i++)
+ {
+ if ((*value == tbl_info->values[i]) ||
+ (settings->flags&F_ALLOW_ARBITRARY_VALS &&
+ *value < tbl_info->values[i]))
+ {
+ val = tbl_info->values[(i+add)%tbl_info->count];
+ break;
+ }
+ }
+ }
*value = val;
}
#endif
Index: apps/settings.h
===================================================================
--- apps/settings.h (revision 17489)
+++ apps/settings.h (working copy)
@@ -90,10 +90,21 @@
#define BOOKMARK_RECENT_ONLY_YES 3
#define BOOKMARK_RECENT_ONLY_ASK 4
-#define TRIG_MODE_OFF 0
-#define TRIG_MODE_NOREARM 1
-#define TRIG_MODE_REARM 2
+enum
+{
+ TRIG_MODE_OFF = 0,
+ TRIG_MODE_NOREARM,
+ TRIG_MODE_REARM
+};
+enum
+{
+ TRIG_TYPE_STOP = 0,
+ TRIG_TYPE_PAUSE,
+ TRIG_TYPE_NEW_FILE
+};
+
+
#define TRIG_DURATION_COUNT 13
extern const struct opt_items trig_durations[TRIG_DURATION_COUNT];
@@ -354,10 +365,12 @@
2 = main and remote lcd
3 = remote lcd */
- int rec_start_thres; /* negative: db, positive: % range -87 .. 100 */
+ int rec_start_thres_db;
+ int rec_start_thres_linear;
int rec_start_duration; /* index of trig_durations */
- int rec_stop_thres; /* negative: db, positive: % */
- int rec_stop_postrec; /* negative: db, positive: % range -87 .. 100 */
+ int rec_stop_thres_db;
+ int rec_stop_thres_linear;
+ int rec_stop_postrec;
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 */
Index: apps/menus/recording_menu.c
===================================================================
--- apps/menus/recording_menu.c (revision 17489)
+++ apps/menus/recording_menu.c (working copy)
@@ -63,8 +63,11 @@
#include "action.h"
#include "recording.h"
#include "sound_menu.h"
+#include "option_select.h"
+#include "settings_list.h"
+#include "list.h"
+#include "viewport.h"
-
static bool no_source_in_menu = false;
int recmenu_callback(int action,const struct menu_item_ex *this_item);
@@ -380,7 +383,7 @@
STOP_GAP,
TRIG_OPTION_COUNT,
};
-
+#if 0
static char* create_thres_str(int threshold, long *voice_id)
{
static char retval[6];
@@ -851,10 +854,247 @@
(int(*)(void))rectrigger, NULL, NULL, Icon_Menu_setting);
+static int thres_callback(int action,const struct menu_item_ex *this_item);
+MENUITEM_SETTING(rec_start_thres_db,
+ &global_settings.rec_start_thres_db, thres_callback);
+MENUITEM_SETTING(rec_start_thres_linear,
+ &global_settings.rec_start_thres_linear, thres_callback);
+MENUITEM_SETTING(rec_stop_thres_db,
+ &global_settings.rec_stop_thres_db, thres_callback);
+MENUITEM_SETTING(rec_stop_thres_linear,
+ &global_settings.rec_stop_thres_linear, thres_callback);
+static int thres_callback(int action,const struct menu_item_ex *this_item)
+{
+ if (action == ACTION_REQUEST_MENUITEM)
+ {
+ if (global_settings.peak_meter_dbfs) /* show the dB settings */
+ {
+ if (this_item == &rec_start_thres_db ||
+ this_item == &rec_stop_thres_db)
+ return action;
+ }
+ else /* show the linear settings */
+ {
+ if (this_item == &rec_start_thres_linear ||
+ this_item == &rec_stop_thres_linear)
+ return action;
+ }
+ return ACTION_EXIT_MENUITEM;
+ }
+ else if (action == ACTION_STD_OK)
+ {
+ peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
+ settings_apply_trigger();
+ }
+ return action;
+}
+static int apply_callback(int action,const struct menu_item_ex *this_item)
+{
+ if (action == ACTION_STD_OK)
+ {
+ peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
+ settings_apply_trigger();
+ }
+ return action;
+}
+MENUITEM_SETTING(rec_start_duration, &global_settings.rec_start_duration, apply_callback);
+MENUITEM_SETTING(rec_stop_postrec, &global_settings.rec_stop_postrec, apply_callback);
+MENUITEM_SETTING(rec_stop_gap, &global_settings.rec_stop_gap, apply_callback);
+MENUITEM_SETTING(rec_trigger_mode, &global_settings.rec_trigger_mode, apply_callback);
+MENUITEM_SETTING(rec_trigger_type, &global_settings.rec_trigger_type, apply_callback);
+MENUITEM_FUNCTION(revert, 0, ID2P(LANG_UNDO_CHANGES),
+ revert_trigger, NULL, NULL, Icon_Reverse_Cursor);
+static int trig_callback(int action,const struct menu_item_ex *this_item)
+{
+ if (action == ACTION_REQUEST_MENUITEM)
+ {
+ old_start_thres_db = global_settings.rec_start_thres_db;
+ old_start_thres_linear = global_settings.rec_start_thres_linear;
+ old_start_duration = global_settings.rec_start_duration;
+ old_prerecord_time = global_settings.rec_prerecord_time;
+ old_stop_thres_db = global_settings.rec_stop_thres_db;
+ old_stop_thres_linear = global_settings.rec_stop_thres_linear;
+ old_stop_postrec = global_settings.rec_stop_postrec;
+ old_stop_gap = global_settings.rec_stop_gap;
+ old_trigger_mode = global_settings.rec_trigger_mode;
+ old_trigger_type = global_settings.rec_trigger_type;
+ }
+ return action;
+}
+MAKE_MENU(rectrigger_menu, ID2P(LANG_RECORD_TRIGGER),
+ trig_callback, Icon_Menu_setting,
+ &rec_trigger_mode, &rec_trigger_type,
+ &rec_prerecord_time,
+ &rec_start_thres_db, &rec_start_thres_linear,
+ &rec_start_duration,
+ &rec_stop_thres_db, &rec_stop_thres_linear,
+ &rec_stop_postrec, &rec_stop_gap,
+ &revert );
+#endif
+static int old_start_thres_db;
+static int old_start_thres_linear;
+static int old_start_duration;
+static int old_prerecord_time;
+static int old_stop_thres_db;
+static int old_stop_thres_linear;
+static int old_stop_postrec;
+static int old_stop_gap;
+static int old_trigger_mode;
+static int old_trigger_type;
+ static int revert_trigger(void)
+{
+ gui_syncsplash(HZ/2, str(LANG_CANCEL));
+ global_settings.rec_start_thres_db = old_start_thres_db;
+ global_settings.rec_start_thres_linear = old_start_thres_linear;
+ global_settings.rec_start_duration = old_start_duration;
+ global_settings.rec_prerecord_time = old_prerecord_time;
+ global_settings.rec_stop_thres_db = old_stop_thres_db;
+ global_settings.rec_stop_thres_linear = old_stop_thres_linear;
+ global_settings.rec_stop_postrec = old_stop_postrec;
+ global_settings.rec_stop_gap = old_stop_gap;
+ global_settings.rec_trigger_mode = old_trigger_mode;
+ global_settings.rec_trigger_type = old_trigger_type;
+ peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
+ settings_apply_trigger();
+ return 0;
+}
+enum themable_icons trigger_get_icon(int selected_item, void * data)
+{
+ if ((selected_item % 2) == 0) /* header */
+ return Icon_Menu_setting;
+ return Icon_NOICON;
+}
+char * trigger_get_name(int selected_item, void * data,
+ char * buffer, size_t buffer_len)
+{
+ const struct settings_list **settings =
+ (const struct settings_list **)data;
+ const struct settings_list *s = settings[selected_item / 2];
+ if ((selected_item % 2) == 0) /* header */
+ return P2STR(ID2P(s->lang_id));
+ else
+ {
+ int temp;
+ if ((s->flags & F_BOOL_SETTING) == F_BOOL_SETTING)
+ temp = *(bool*)s->setting?1:0;
+ else
+ temp = *(int*)s->setting;
+ if ((selected_item / 2 == START_THRESHOLD ||
+ selected_item / 2 == STOP_THRESHOLD) &&
+ temp == 0)
+ {
+ return str(LANG_OFF);
+ }
+ return option_get_valuestring(s, buffer, buffer_len, temp);
+ }
+}
+int rectrigger(void)
+{
+ struct viewport vp[NB_SCREENS];
+ struct gui_synclist lists;
+ int i, action = ACTION_REDRAW;
+ bool done = false, redraw = true;
+ const struct settings_list *settings[TRIG_OPTION_COUNT];
+
+ int pm_y[NB_SCREENS];
+ int trig_xpos[NB_SCREENS];
+ int trig_ypos[NB_SCREENS];
+ int trig_width[NB_SCREENS];
+
+ FOR_NB_SCREENS(i)
+ {
+ screens[i].clear_display();
+ screens[i].update();
+ viewport_set_defaults(&vp[i], i);
+ vp[i].height -= SYSFONT_HEIGHT*2;
+ trig_xpos[i] = 0;
+ trig_ypos[i] = vp[i].y + vp[i].height;
+ pm_y[i] = screens[i].height - SYSFONT_HEIGHT;
+ trig_width[i] = screens[i].width;
+ }
+ /* TODO: what to do if there is < 4 lines on the screen? */
+
+ settings[TRIGGER_MODE] = find_setting(&global_settings.rec_trigger_mode, NULL);
+ settings[TRIGGER_TYPE] = find_setting(&global_settings.rec_trigger_type, NULL);
+ settings[PRERECORD_TIME] = find_setting(&global_settings.rec_prerecord_time, NULL);
+ settings[START_DURATION] = find_setting(&global_settings.rec_start_duration, NULL);
+ settings[STOP_POSTREC] = find_setting(&global_settings.rec_stop_postrec, NULL);
+ settings[STOP_GAP] = find_setting(&global_settings.rec_stop_gap, NULL);
+ if (global_settings.peak_meter_dbfs) /* show the dB settings */
+ {
+ settings[START_THRESHOLD] = find_setting(&global_settings.rec_start_thres_db, NULL);
+ settings[STOP_THRESHOLD] = find_setting(&global_settings.rec_stop_thres_db, NULL);
+ }
+ else
+ {
+ settings[START_THRESHOLD] = find_setting(&global_settings.rec_start_thres_linear, NULL);
+ settings[STOP_THRESHOLD] = find_setting(&global_settings.rec_stop_thres_linear, NULL);
+ }
+ gui_synclist_init(&lists, trigger_get_name, settings, false, 2, vp);
+ gui_synclist_set_nb_items(&lists, TRIG_OPTION_COUNT*2);
+ gui_synclist_set_icon_callback(&lists, trigger_get_icon);
+
+ /* restart trigger with new values */
+ settings_apply_trigger();
+ peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF);
+ while (!done)
+ {
+ if (redraw)
+ {
+ gui_synclist_draw(&lists);
+ gui_syncstatusbar_draw(&statusbars, true);
+ redraw = false;
+ }
+ peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS);
+ action = peak_meter_draw_get_btn(0, pm_y, SYSFONT_HEIGHT, NB_SCREENS);
+ FOR_NB_SCREENS(i)
+ screens[i].update();
+ i = gui_synclist_get_sel_pos(&lists);
+ switch (action)
+ {
+ case ACTION_STD_CANCEL:
+ revert_trigger();
+ done = true;
+ break;
+ case ACTION_STD_OK:
+ done = true;
+ break;
+ case ACTION_STD_PREV:
+ option_select_next_val(settings[i/2], true, false);
+ redraw = true;
+ break;
+ case ACTION_STD_NEXT:
+ option_select_next_val(settings[i/2], false, false);
+ redraw = true;
+ break;
+ case ACTION_SETTINGS_DEC:
+ i -= 2;
+ if (i<0)
+ i = (TRIG_OPTION_COUNT*2) - 2;
+ gui_synclist_select_item(&lists, i);
+ peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
+ settings_apply_trigger();
+ redraw = true;
+ break;
+ case ACTION_SETTINGS_INC:
+ gui_synclist_select_item(&lists, (i+2) % (TRIG_OPTION_COUNT*2));
+ peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
+ settings_apply_trigger();
+ redraw = true;
+ break;
+ }
+ }
+ peak_meter_trigger(false);
+ settings_save();
+ return 0;
+}
+MENUITEM_FUNCTION(rectrigger_item, 0, ID2P(LANG_RECORD_TRIGGER),
+ rectrigger, NULL, NULL, Icon_Menu_setting);
+
/* from main_menu.c */
struct browse_folder_info {
const char* dir;
Index: apps/settings_list.c
===================================================================
--- apps/settings_list.c (revision 17489)
+++ apps/settings_list.c (working copy)
@@ -207,10 +207,6 @@
#define DEFAULT_BACKDROP "cabbiev2"
#ifdef HAVE_RECORDING
-/* keep synchronous to trig_durations and
- trigger_times in settings_apply_trigger */
-static const char trig_durations_conf [] =
- "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min";
/* these should be in the config.h files */
#if CONFIG_CODEC == MAS3587F
# define DEFAULT_REC_MIC_GAIN 8
@@ -918,24 +914,35 @@
/** Encoder settings end **/
#endif /* CONFIG_CODEC == SWCODEC */
/* values for the trigger */
- {F_T_INT|F_RECSETTING,&global_settings.rec_start_thres,
- LANG_RECORD_START_THRESHOLD, INT(-35),
- "trigger start threshold",NULL,UNUSED},
- {F_T_INT|F_RECSETTING,&global_settings.rec_stop_thres,
- LANG_RECORD_STOP_THRESHOLD,INT(-45),
- "trigger stop threshold",NULL,UNUSED},
- {F_T_INT|F_RECSETTING,&global_settings.rec_start_duration,
- LANG_MIN_DURATION,INT(0),
- "trigger start duration",trig_durations_conf,UNUSED},
- {F_T_INT|F_RECSETTING,&global_settings.rec_stop_postrec,
- LANG_MIN_DURATION,INT(2),
- "trigger stop postrec",trig_durations_conf,UNUSED},
- {F_T_INT|F_RECSETTING,&global_settings.rec_stop_gap,
- LANG_RECORD_STOP_GAP,INT(1),
- "trigger min gap",trig_durations_conf,UNUSED},
- {F_T_INT|F_RECSETTING,&global_settings.rec_trigger_mode,
- LANG_RECORD_TRIGGER,INT(0),
- "trigger mode","off,once,repeat",UNUSED},
+ INT_SETTING(F_RECSETTING, rec_start_thres_db, LANG_RECORD_START_THRESHOLD, -35,
+ "trigger start threshold dB", UNIT_DB, VOLUME_MIN/10, 0, -1, NULL, NULL, NULL),
+ INT_SETTING(F_RECSETTING, rec_start_thres_linear, LANG_RECORD_START_THRESHOLD, 5,
+ "trigger start threshold linear", UNIT_PERCENT, 0, 100, 1, NULL, NULL, NULL),
+ INT_SETTING(F_RECSETTING, rec_stop_thres_db, LANG_RECORD_STOP_THRESHOLD, -45,
+ "trigger stop threshold dB", UNIT_DB, VOLUME_MIN/10, 0, -1, NULL, NULL, NULL),
+ INT_SETTING(F_RECSETTING, rec_stop_thres_linear, LANG_RECORD_STOP_THRESHOLD, 10,
+ "trigger stop threshold linear", UNIT_PERCENT, 0, 100, 1, NULL, NULL, NULL),
+ TABLE_SETTING(F_RECSETTING, rec_start_duration, LANG_MIN_DURATION, 0,
+ "trigger start duration",
+ "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min",
+ UNIT_SEC, NULL, NULL, NULL, 13,
+ 0,1,2,5,10,15,20,25,30,60,120,300,600),
+ TABLE_SETTING(F_RECSETTING, rec_stop_postrec, LANG_MIN_DURATION, 0,
+ "trigger stop duration",
+ "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min",
+ UNIT_SEC, NULL, NULL, NULL, 13,
+ 0,1,2,5,10,15,20,25,30,60,120,300,600),
+ TABLE_SETTING(F_RECSETTING, rec_stop_gap, LANG_RECORD_STOP_GAP, 1,
+ "trigger min gap",
+ "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min",
+ UNIT_SEC, NULL, NULL, NULL, 13,
+ 0,1,2,5,10,15,20,25,30,60,120,300,600),
+ CHOICE_SETTING(F_RECSETTING, rec_trigger_mode, LANG_RECORD_TRIGGER, TRIG_MODE_OFF,
+ "trigger mode","off,once,repeat", NULL ,3,
+ ID2P(LANG_OFF), ID2P(LANG_RECORD_TRIG_NOREARM), ID2P(LANG_REPEAT)),
+ CHOICE_SETTING(F_RECSETTING, rec_trigger_type, LANG_RECORD_TRIGGER_TYPE, TRIG_TYPE_STOP,
+ "trigger mode","off,once,repeat", NULL ,3,
+ ID2P(LANG_RECORD_TRIGGER_STOP), ID2P(LANG_PAUSE), ID2P(LANG_RECORD_TRIGGER_NEWFILESTP)),
#endif /* HAVE_RECORDING */
#ifdef HAVE_SPDIF_POWER
@@ -1192,14 +1199,6 @@
OFFON_SETTING(0, audioscrobbler, LANG_AUDIOSCROBBLER, false,
"Last.fm Logging", NULL),
-
-#ifdef HAVE_RECORDING
- {F_T_INT|F_RECSETTING,&global_settings.rec_trigger_type,
- LANG_RECORD_TRIGGER_TYPE, INT(0),
- "trigger type","stop,pause,nf stp",UNUSED},
-#endif
-
- /** settings not in the old config blocks **/
#if CONFIG_TUNER
FILENAME_SETTING(0, fmr_file, "fmr", "",
FMPRESET_PATH "/", ".fmr", MAX_FILENAME+1),
Index: apps/sound_menu.h
===================================================================
--- apps/sound_menu.h (revision 17489)
+++ apps/sound_menu.h (working copy)
@@ -22,6 +22,6 @@
#include "menu.h"
bool recording_menu(bool no_source);
-bool rectrigger(void);
+int rectrigger(void);
#endif