summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorStéphane Doyon <s.doyon@videotron.ca>2007-10-10 01:41:48 +0000
committerStéphane Doyon <s.doyon@videotron.ca>2007-10-10 01:41:48 +0000
commit0279c71a92cd54210b91e80541c0688fb55c3a19 (patch)
treed5727603c46c7f22c0e2730fd3c8680455e7cbbf /apps
parent6799ac8051ad4237c1fbe0aa2ee6d4b2b5ddcee4 (diff)
downloadrockbox-0279c71a92cd54210b91e80541c0688fb55c3a19.tar.gz
rockbox-0279c71a92cd54210b91e80541c0688fb55c3a19.zip
Voice the recording trigger settings screen.
From FS#6325, with a slight coding improvement. Also take out a duplicated snprintf in there. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15059 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang14
-rw-r--r--apps/menus/recording_menu.c91
-rw-r--r--apps/recorder/recording.c12
-rw-r--r--apps/settings.h11
4 files changed, 93 insertions, 35 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index ce798fded3..abe70b4d9f 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -6310,7 +6310,7 @@
6310 </dest> 6310 </dest>
6311 <voice> 6311 <voice>
6312 *: none 6312 *: none
6313 recording: "" 6313 recording: "Once"
6314 </voice> 6314 </voice>
6315</phrase> 6315</phrase>
6316<phrase> 6316<phrase>
@@ -6326,7 +6326,7 @@
6326 </dest> 6326 </dest>
6327 <voice> 6327 <voice>
6328 *: none 6328 *: none
6329 recording: "Trigtype" 6329 recording: "Trigger type"
6330 </voice> 6330 </voice>
6331</phrase> 6331</phrase>
6332<phrase> 6332<phrase>
@@ -6375,7 +6375,7 @@
6375 </dest> 6375 </dest>
6376 <voice> 6376 <voice>
6377 *: none 6377 *: none
6378 recording: "" 6378 recording: "Start Above"
6379 </voice> 6379 </voice>
6380</phrase> 6380</phrase>
6381<phrase> 6381<phrase>
@@ -6392,7 +6392,7 @@
6392 </dest> 6392 </dest>
6393 <voice> 6393 <voice>
6394 *: none 6394 *: none
6395 recording: "" 6395 recording: "for at least"
6396 </voice> 6396 </voice>
6397</phrase> 6397</phrase>
6398<phrase> 6398<phrase>
@@ -6409,7 +6409,7 @@
6409 </dest> 6409 </dest>
6410 <voice> 6410 <voice>
6411 *: none 6411 *: none
6412 recording: "" 6412 recording: "Stop Below"
6413 </voice> 6413 </voice>
6414</phrase> 6414</phrase>
6415<phrase> 6415<phrase>
@@ -6426,7 +6426,7 @@
6426 </dest> 6426 </dest>
6427 <voice> 6427 <voice>
6428 *: none 6428 *: none
6429 recording: "" 6429 recording: "Presplit Gap"
6430 </voice> 6430 </voice>
6431</phrase> 6431</phrase>
6432<phrase> 6432<phrase>
@@ -8354,7 +8354,7 @@
8354 </dest> 8354 </dest>
8355 <voice> 8355 <voice>
8356 *: none 8356 *: none
8357 recording: "" 8357 recording: "minus infinity"
8358 </voice> 8358 </voice>
8359</phrase> 8359</phrase>
8360<phrase> 8360<phrase>
diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c
index e2be128d2d..70389045d7 100644
--- a/apps/menus/recording_menu.c
+++ b/apps/menus/recording_menu.c
@@ -381,17 +381,23 @@ enum trigger_menu_option
381 TRIG_OPTION_COUNT, 381 TRIG_OPTION_COUNT,
382}; 382};
383 383
384static char* create_thres_str(int threshold) 384static char* create_thres_str(int threshold, long *voice_id)
385{ 385{
386 static char retval[6]; 386 static char retval[6];
387 if (threshold < 0) { 387 if (threshold < 0) {
388 if (threshold < -88) { 388 if (threshold < -88) {
389 snprintf (retval, sizeof retval, "%s", str(LANG_DB_INF)); 389 snprintf (retval, sizeof retval, "%s", str(LANG_DB_INF));
390 if(voice_id)
391 *voice_id = LANG_DB_INF;
390 } else { 392 } else {
391 snprintf (retval, sizeof retval, "%ddb", threshold + 1); 393 snprintf (retval, sizeof retval, "%ddb", threshold + 1);
394 if(voice_id)
395 *voice_id = TALK_ID(threshold + 1, UNIT_DB);
392 } 396 }
393 } else { 397 } else {
394 snprintf (retval, sizeof retval, "%d%%", threshold); 398 snprintf (retval, sizeof retval, "%d%%", threshold);
399 if(voice_id)
400 *voice_id = TALK_ID(threshold, UNIT_PERCENT);
395 } 401 }
396 return retval; 402 return retval;
397} 403}
@@ -442,11 +448,13 @@ bool rectrigger(void)
442 }; 448 };
443 449
444#define PRERECORD_TIMES_COUNT 31 450#define PRERECORD_TIMES_COUNT 31
445 static const unsigned char *prerecord_times[] = { 451 static const struct opt_items prerecord_times[] = {
446 ID2P(LANG_OFF),"1s","2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", 452 { STR(LANG_OFF) },
447 "10s", "11s", "12s", "13s", "14s", "15s", "16s", "17s", "18s", "19s", 453#define T(x) { (unsigned char *)(#x "s"), TALK_ID(x, UNIT_SEC) }
448 "20s", "21s", "22s", "23s", "24s", "25s", "26s", "27s", "28s", "29s", 454 T(1), T(2), T(3), T(4), T(5), T(6), T(7), T(8), T(9), T(10),
449 "30s" 455 T(11), T(12), T(13), T(14), T(15), T(16), T(17), T(18), T(19), T(20),
456 T(21), T(22), T(23), T(24), T(25), T(26), T(27), T(28), T(29), T(30),
457#undef T
450 }; 458 };
451 459
452#define TRIGGER_TYPE_COUNT 3 460#define TRIGGER_TYPE_COUNT 3
@@ -486,6 +494,8 @@ bool rectrigger(void)
486 int trig_ypos[NB_SCREENS]; 494 int trig_ypos[NB_SCREENS];
487 int trig_width[NB_SCREENS]; 495 int trig_width[NB_SCREENS];
488 496
497 bool say_field = true, say_value = true;
498
489 FOR_NB_SCREENS(i) 499 FOR_NB_SCREENS(i)
490 { 500 {
491 offset[i] = 0; 501 offset[i] = 0;
@@ -535,23 +545,17 @@ bool rectrigger(void)
535 "%s", 545 "%s",
536 P2STR(trigger_types[global_settings.rec_trigger_type])); 546 P2STR(trigger_types[global_settings.rec_trigger_type]));
537 547
538 snprintf(
539 option_value[TRIGGER_TYPE],
540 sizeof option_value[TRIGGER_TYPE],
541 "%s",
542 P2STR(trigger_types[global_settings.rec_trigger_type]));
543
544 snprintf ( 548 snprintf (
545 option_value[PRERECORD_TIME], 549 option_value[PRERECORD_TIME],
546 sizeof option_value[PRERECORD_TIME], 550 sizeof option_value[PRERECORD_TIME],
547 "%s", 551 "%s",
548 P2STR(prerecord_times[global_settings.rec_prerecord_time])); 552 prerecord_times[global_settings.rec_prerecord_time].string);
549 553
550 /* due to value range shift (peak_meter_define_trigger) -1 is 0db */ 554 /* due to value range shift (peak_meter_define_trigger) -1 is 0db */
551 if (global_settings.rec_start_thres == -1) { 555 if (global_settings.rec_start_thres == -1) {
552 str = str(LANG_OFF); 556 str = str(LANG_OFF);
553 } else { 557 } else {
554 str = create_thres_str(global_settings.rec_start_thres); 558 str = create_thres_str(global_settings.rec_start_thres, NULL);
555 } 559 }
556 snprintf( 560 snprintf(
557 option_value[START_THRESHOLD], 561 option_value[START_THRESHOLD],
@@ -563,13 +567,12 @@ bool rectrigger(void)
563 option_value[START_DURATION], 567 option_value[START_DURATION],
564 sizeof option_value[START_DURATION], 568 sizeof option_value[START_DURATION],
565 "%s", 569 "%s",
566 trig_durations[global_settings.rec_start_duration]); 570 trig_durations[global_settings.rec_start_duration].string);
567
568 571
569 if (global_settings.rec_stop_thres <= INF_DB) { 572 if (global_settings.rec_stop_thres <= INF_DB) {
570 str = str(LANG_OFF); 573 str = str(LANG_OFF);
571 } else { 574 } else {
572 str = create_thres_str(global_settings.rec_stop_thres); 575 str = create_thres_str(global_settings.rec_stop_thres, NULL);
573 } 576 }
574 snprintf( 577 snprintf(
575 option_value[STOP_THRESHOLD], 578 option_value[STOP_THRESHOLD],
@@ -581,13 +584,13 @@ bool rectrigger(void)
581 option_value[STOP_POSTREC], 584 option_value[STOP_POSTREC],
582 sizeof option_value[STOP_POSTREC], 585 sizeof option_value[STOP_POSTREC],
583 "%s", 586 "%s",
584 trig_durations[global_settings.rec_stop_postrec]); 587 trig_durations[global_settings.rec_stop_postrec].string);
585 588
586 snprintf( 589 snprintf(
587 option_value[STOP_GAP], 590 option_value[STOP_GAP],
588 sizeof option_value[STOP_GAP], 591 sizeof option_value[STOP_GAP],
589 "%s", 592 "%s",
590 trig_durations[global_settings.rec_stop_gap]); 593 trig_durations[global_settings.rec_stop_gap].string);
591 594
592 FOR_NB_SCREENS(i) 595 FOR_NB_SCREENS(i)
593 { 596 {
@@ -629,6 +632,52 @@ bool rectrigger(void)
629 VERTICAL); 632 VERTICAL);
630 } 633 }
631 634
635 bool enqueue = false;
636 if(say_field) {
637 talk_id(P2ID(option_name[selected]), enqueue);
638 enqueue = true;
639 }
640 if(say_value) {
641 long id;
642 switch(selected) {
643 case TRIGGER_MODE:
644 id = P2ID(trigger_modes[global_settings.rec_trigger_mode]);
645 break;
646 case TRIGGER_TYPE:
647 id = P2ID(trigger_types[global_settings.rec_trigger_type]);
648 break;
649 case PRERECORD_TIME:
650 id = prerecord_times[global_settings.rec_prerecord_time]
651 .voice_id;
652 break;
653 case START_THRESHOLD:
654 if (global_settings.rec_start_thres == -1)
655 id = LANG_OFF;
656 else create_thres_str(global_settings.rec_start_thres, &id);
657 break;
658 case START_DURATION:
659 id = trig_durations[global_settings.rec_start_duration]
660 .voice_id;
661 break;
662 case STOP_THRESHOLD:
663 if (global_settings.rec_stop_thres <= INF_DB)
664 id = LANG_OFF;
665 else create_thres_str(global_settings.rec_stop_thres, &id);
666 break;
667 case STOP_POSTREC:
668 id = trig_durations[global_settings.rec_stop_postrec].voice_id;
669 break;
670 case STOP_GAP:
671 id = trig_durations[global_settings.rec_stop_gap].voice_id;
672 break;
673 case TRIG_OPTION_COUNT:
674 // avoid compiler warnings
675 break;
676 };
677 talk_id(id, enqueue);
678 }
679 say_field = say_value = false;
680
632 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS); 681 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS);
633 button = peak_meter_draw_get_btn(0, pm_y, 8, NB_SCREENS); 682 button = peak_meter_draw_get_btn(0, pm_y, 8, NB_SCREENS);
634 683
@@ -661,6 +710,7 @@ bool rectrigger(void)
661 offset[i] = MIN(offset[i], (int)selected); 710 offset[i] = MIN(offset[i], (int)selected);
662 offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1); 711 offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1);
663 } 712 }
713 say_field = say_value = true;
664 break; 714 break;
665 715
666 case ACTION_STD_NEXT: 716 case ACTION_STD_NEXT:
@@ -671,6 +721,7 @@ bool rectrigger(void)
671 offset[i] = MIN(offset[i], (int)selected); 721 offset[i] = MIN(offset[i], (int)selected);
672 offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1); 722 offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1);
673 } 723 }
724 say_field = say_value = true;
674 break; 725 break;
675 726
676 case ACTION_SETTINGS_INC: 727 case ACTION_SETTINGS_INC:
@@ -719,6 +770,7 @@ bool rectrigger(void)
719 } 770 }
720 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); 771 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
721 settings_apply_trigger(); 772 settings_apply_trigger();
773 say_value = true;
722 break; 774 break;
723 775
724 case ACTION_SETTINGS_DEC: 776 case ACTION_SETTINGS_DEC:
@@ -770,6 +822,7 @@ bool rectrigger(void)
770 } 822 }
771 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); 823 peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
772 settings_apply_trigger(); 824 settings_apply_trigger();
825 say_value = true;
773 break; 826 break;
774 827
775 case ACTION_REC_F2: 828 case ACTION_REC_F2:
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index ac06c93cf9..3b706e1a6d 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -123,11 +123,15 @@ static unsigned long rec_sizesplit_bytes(void)
123 * Time strings used for the trigger durations. 123 * Time strings used for the trigger durations.
124 * Keep synchronous to trigger_times in settings_apply_trigger 124 * Keep synchronous to trigger_times in settings_apply_trigger
125 */ 125 */
126const char * const trig_durations[TRIG_DURATION_COUNT] = 126const struct opt_items trig_durations[TRIG_DURATION_COUNT] =
127{ 127{
128 "0s", "1s", "2s", "5s", 128#define TS(x) { (unsigned char *)(#x "s"), TALK_ID(x, UNIT_SEC) }
129 "10s", "15s", "20s", "25s", "30s", 129#define TM(x) { (unsigned char *)(#x "min"), TALK_ID(x, UNIT_MIN) }
130 "1min", "2min", "5min", "10min" 130 TS(0), TS(1), TS(2), TS(5),
131 TS(10), TS(15), TS(20), TS(25), TS(30),
132 TM(1), TM(2), TM(5), TM(10)
133#undef TS
134#undef TM
131}; 135};
132 136
133void settings_apply_trigger(void) 137void settings_apply_trigger(void)
diff --git a/apps/settings.h b/apps/settings.h
index 7399f62b1e..cce7272eec 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -39,6 +39,11 @@
39#include "backlight.h" /* for [MIN|MAX]_BRIGHTNESS_SETTING */ 39#include "backlight.h" /* for [MIN|MAX]_BRIGHTNESS_SETTING */
40#endif 40#endif
41 41
42struct opt_items {
43 unsigned const char* string;
44 long voice_id;
45};
46
42/** Setting values defines **/ 47/** Setting values defines **/
43 48
44/* name of directory where configuration, fonts and other data 49/* name of directory where configuration, fonts and other data
@@ -103,7 +108,7 @@
103#define TRIG_MODE_REARM 2 108#define TRIG_MODE_REARM 2
104 109
105#define TRIG_DURATION_COUNT 13 110#define TRIG_DURATION_COUNT 13
106extern const char * const trig_durations[TRIG_DURATION_COUNT]; 111extern const struct opt_items trig_durations[TRIG_DURATION_COUNT];
107 112
108#define CROSSFADE_ENABLE_SHUFFLE 1 113#define CROSSFADE_ENABLE_SHUFFLE 1
109#define CROSSFADE_ENABLE_TRACKSKIP 2 114#define CROSSFADE_ENABLE_TRACKSKIP 2
@@ -255,10 +260,6 @@ void settings_display(void);
255 260
256enum optiontype { INT, BOOL }; 261enum optiontype { INT, BOOL };
257 262
258struct opt_items {
259 unsigned const char* string;
260 long voice_id;
261};
262const struct settings_list* find_setting(void* variable, int *id); 263const struct settings_list* find_setting(void* variable, int *id);
263bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len); 264bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len);
264void talk_setting(void *global_settings_variable); 265void talk_setting(void *global_settings_variable);