summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-04-19 13:19:04 +0000
committerNils Wallménius <nils@rockbox.org>2008-04-19 13:19:04 +0000
commit05d2bfd5e096d76ede965226520e680cafe22dc4 (patch)
tree13b4b4c8fc13e82755cee2fe1f4aad4e244bf4f4 /apps
parenta1b3c69a0fd3c16d09e284fb2365c69b7efdd555 (diff)
downloadrockbox-05d2bfd5e096d76ede965226520e680cafe22dc4.zip
rockbox-05d2bfd5e096d76ede965226520e680cafe22dc4.tar.gz
rockbox-05d2bfd5e096d76ede965226520e680cafe22dc4.tar.bz2
rockbox-05d2bfd5e096d76ede965226520e680cafe22dc4.tar.xz
Introduce support for passing decimal numbers in talk ids and speak them, use in the settings menu to fix FS#7622
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17168 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/settings_list.c40
-rw-r--r--apps/talk.c36
-rw-r--r--apps/talk.h9
3 files changed, 64 insertions, 21 deletions
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 52eb0c1..e72b259 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -307,6 +307,16 @@ static void db_format(char* buffer, size_t buffer_size, int value,
v / 10, v % 10, unit);
}
+static int32_t get_dec_talkid(int value, int unit)
+{
+ return TALK_ID_DECIMAL(value, 1, unit);
+}
+
+static int32_t get_precut_talkid(int value, int unit)
+{
+ return TALK_ID_DECIMAL(-value, 1, unit);
+}
+
#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
static void set_mdb_enable(bool value)
@@ -905,7 +915,7 @@ const struct settings_list settings[] = {
OFFON_SETTING(F_SOUNDSETTING, replaygain_noclip, LANG_REPLAYGAIN_NOCLIP,
false, "replaygain noclip", NULL),
INT_SETTING_NOWRAP(F_SOUNDSETTING, replaygain_preamp, LANG_REPLAYGAIN_PREAMP, 0, "replaygain preamp",
- UNIT_DB, -120, 120, 5, db_format, NULL, NULL),
+ UNIT_DB, -120, 120, 5, db_format, get_dec_talkid, NULL),
CHOICE_SETTING(0, beep, LANG_BEEP, 0,
"beep", "off,weak,moderate,strong", NULL, 4,
@@ -933,13 +943,13 @@ const struct settings_list settings[] = {
"crossfeed", dsp_set_crossfeed),
INT_SETTING_NOWRAP(F_SOUNDSETTING, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN,
-15, "crossfeed direct gain", UNIT_DB, -60, 0, 5,
- db_format, NULL, dsp_set_crossfeed_direct_gain),
+ db_format, get_dec_talkid, dsp_set_crossfeed_direct_gain),
INT_SETTING_NOWRAP(F_SOUNDSETTING, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, -60,
"crossfeed cross gain", UNIT_DB, -120, -30, 5,
- db_format, NULL, crossfeed_cross_set),
+ db_format, get_dec_talkid, crossfeed_cross_set),
INT_SETTING_NOWRAP(F_SOUNDSETTING, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, -160,
"crossfeed hf attenuation", UNIT_DB, -240, -60, 5,
- db_format, NULL, crossfeed_cross_set),
+ db_format, get_dec_talkid, crossfeed_cross_set),
INT_SETTING_NOWRAP(F_SOUNDSETTING, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF, 700,
"crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100,
NULL, NULL, crossfeed_cross_set),
@@ -948,7 +958,7 @@ const struct settings_list settings[] = {
OFFON_SETTING(F_EQSETTING, eq_enabled, LANG_EQUALIZER_ENABLED, false,
"eq enabled", NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_precut, LANG_EQUALIZER_PRECUT, 0,
- "eq precut", UNIT_DB, 0, 240, 5, eq_precut_format, NULL,
+ "eq precut", UNIT_DB, 0, 240, 5, eq_precut_format, get_precut_talkid,
dsp_set_eq_precut),
/* 0..32768 Hz */
INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_cutoff, LANG_EQUALIZER_BAND_CUTOFF,
@@ -969,35 +979,35 @@ const struct settings_list settings[] = {
/* 0..64 (or 0.0 to 6.4) */
INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_q, LANG_EQUALIZER_BAND_Q, 7,
"eq band 0 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
- eq_q_format, NULL, NULL),
+ eq_q_format, get_dec_talkid, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_q, LANG_EQUALIZER_BAND_Q, 10,
"eq band 1 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
- eq_q_format, NULL, NULL),
+ eq_q_format, get_dec_talkid, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_q, LANG_EQUALIZER_BAND_Q, 10,
"eq band 2 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
- eq_q_format, NULL, NULL),
+ eq_q_format, get_dec_talkid, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_q, LANG_EQUALIZER_BAND_Q, 10,
"eq band 3 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
- eq_q_format, NULL, NULL),
+ eq_q_format, get_dec_talkid, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_q, LANG_EQUALIZER_BAND_Q, 7,
"eq band 4 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
- eq_q_format, NULL, NULL),
+ eq_q_format, get_dec_talkid, NULL),
/* -240..240 (or -24db to +24db) */
INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_gain, LANG_GAIN, 0,
"eq band 0 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
- EQ_GAIN_STEP, db_format, NULL, NULL),
+ EQ_GAIN_STEP, db_format, get_dec_talkid, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_gain, LANG_GAIN, 0,
"eq band 1 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
- EQ_GAIN_STEP, db_format, NULL, NULL),
+ EQ_GAIN_STEP, db_format, get_dec_talkid, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_gain, LANG_GAIN, 0,
"eq band 2 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
- EQ_GAIN_STEP, db_format, NULL, NULL),
+ EQ_GAIN_STEP, db_format, get_dec_talkid, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_gain, LANG_GAIN, 0,
"eq band 3 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
- EQ_GAIN_STEP, db_format, NULL, NULL),
+ EQ_GAIN_STEP, db_format, get_dec_talkid, NULL),
INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_gain, LANG_GAIN, 0,
"eq band 4 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
- EQ_GAIN_STEP, db_format, NULL, NULL),
+ EQ_GAIN_STEP, db_format, get_dec_talkid, NULL),
/* dithering */
OFFON_SETTING(F_SOUNDSETTING, dithering_enabled, LANG_DITHERING,
diff --git a/apps/talk.c b/apps/talk.c
index 8286ff6..4ecdc38 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -558,6 +558,7 @@ int talk_id(int32_t id, bool enqueue)
long clipsize;
unsigned char* clipbuf;
int32_t unit;
+ int decimals;
if (talk_temp_disable_count > 0)
return -1; /* talking has been disabled */
@@ -575,13 +576,16 @@ int talk_id(int32_t id, bool enqueue)
if (id == -1) /* -1 is an indication for silence */
return -1;
+ decimals = (((uint32_t)id) >> DECIMAL_SHIFT) & 0x7;
+ DEBUGF("decimals %d\n", decimals);
/* check if this is a special ID, with a value */
unit = ((uint32_t)id) >> UNIT_SHIFT;
- if (unit)
+ if (unit || decimals)
{ /* sign-extend the value */
- id = (uint32_t)id << (32-UNIT_SHIFT);
- id >>= (32-UNIT_SHIFT);
- talk_value(id, unit, enqueue); /* speak it */
+ id = (uint32_t)id << (32-DECIMAL_SHIFT);
+ id >>= (32-DECIMAL_SHIFT);
+
+ talk_value_decimal(id, unit, decimals, enqueue); /* speak it */
return 0; /* and stop, end of special case */
}
@@ -593,7 +597,6 @@ int talk_id(int32_t id, bool enqueue)
return 0;
}
-
/* Speaks zero or more IDs (from an array). */
int talk_idarray(long *ids, bool enqueue)
{
@@ -760,9 +763,14 @@ static int talk_time_unit(long secs, bool exact, bool enqueue)
return 0;
}
-/* singular/plural aware saying of a value */
int talk_value(long n, int unit, bool enqueue)
{
+ return talk_value_decimal(n, unit, 0, enqueue);
+}
+
+/* singular/plural aware saying of a value */
+int talk_value_decimal(long n, int unit, int decimals, bool enqueue)
+{
int unit_id;
static const int unit_voiced[] =
{ /* lookup table for the voice ID of the units */
@@ -826,6 +834,22 @@ int talk_value(long n, int unit, bool enqueue)
enqueue = true;
}
+ if (decimals)
+ {
+ /* needed for the "-0.5" corner case */
+ if (n < 0)
+ {
+ talk_id(VOICE_MINUS, enqueue);
+ n = -n;
+ enqueue = true;
+ }
+
+ talk_number(n / (10*decimals), enqueue);
+ talk_id(LANG_POINT, true);
+ n %= (10*decimals);
+ enqueue = true;
+ }
+
talk_number(n, enqueue); /* say the number */
talk_id(unit_id, true); /* say the unit, if any */
diff --git a/apps/talk.h b/apps/talk.h
index 97b8c58..afd280e 100644
--- a/apps/talk.h
+++ b/apps/talk.h
@@ -55,10 +55,18 @@ enum {
#define UNIT_SHIFT (32-5) /* this many bits left from UNIT_xx enum */
+#define DECIMAL_SHIFT (32 - 8)
+
/* make a "talkable" ID from number + unit
unit is upper 4 bits, number the remaining (in regular 2's complement) */
#define TALK_ID(n,u) (((long)(u))<<UNIT_SHIFT | ((n) & ~(-1L<<UNIT_SHIFT)))
+/* make a "talkable" ID from a decimal number + unit, the decimal number
+ is represented like x*10*d where d is the number of decimal digits */
+#define TALK_ID_DECIMAL(n,d,u) (((long)(u))<<UNIT_SHIFT |\
+ ((long)(d))<<DECIMAL_SHIFT |\
+ ((n) & ~(-1L<<DECIMAL_SHIFT)))
+
/* convenience macro to have both virtual pointer and ID as arguments */
#define STR(id) ID2P(id), id
@@ -77,6 +85,7 @@ int talk_id(int32_t id, bool enqueue); /* play a voice ID from voicefont */
int talk_file(const char* filename, bool enqueue); /* play a thumbnail from file */
int talk_number(long n, bool enqueue); /* say a number */
int talk_value(long n, int unit, bool enqueue); /* say a numeric value */
+int talk_value_decimal(long n, int unit, int decimals, bool enqueue);
int talk_spell(const char* spell, bool enqueue); /* spell a string */
void talk_setting(const void *global_settings_variable); /* read a setting */
void talk_disable(bool disable); /* temporarily disable (or re-enable) talking (temporarily, not persisted) */