From 207514fb2578cfac611b4ab98b251d1524a55efe Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 6 Mar 2021 23:25:25 -0500 Subject: voice: Allow voice prompt volume to be configurable It defaults to 100%, allow it to be dialed back Change-Id: If997fb7d3057472a7fac0be4ae7d1e8fce654c49 --- apps/lang/english.lang | 14 ++++++++++++++ apps/menus/settings_menu.c | 3 ++- apps/settings.h | 1 + apps/settings_list.c | 4 ++++ apps/voice_thread.c | 11 ++++++++++- apps/voice_thread.h | 2 ++ 6 files changed, 33 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 8672c9f421..8fd482b0ac 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -9499,6 +9499,20 @@ *: "Announce Battery Level" + + id: LANG_TALK_MIXER_LEVEL + desc: Relative volume of voice prompts + user: core + + *: "Voice prompt volume" + + + *: "Voice prompt volume" + + + *: "Voice prompt volume" + + id: LANG_VOICE_FILETYPE desc: voice settings menu diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index 96ad8009d3..f8dbb86dc3 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c @@ -709,10 +709,11 @@ static int talk_callback(int action, MENUITEM_SETTING(talk_filetype_item, &global_settings.talk_filetype, NULL); MENUITEM_SETTING(talk_battery_level_item, &global_settings.talk_battery_level, NULL); +MENUITEM_SETTING(talk_mixer_amp_item, &global_settings.talk_mixer_amp, NULL); MAKE_MENU(voice_settings_menu, ID2P(LANG_VOICE), 0, Icon_Voice, &talk_menu_item, &talk_dir_item, &talk_dir_clip_item, &talk_file_item, &talk_file_clip_item, &talk_filetype_item, - &talk_battery_level_item); + &talk_battery_level_item, &talk_mixer_amp_item); /* VOICE MENU */ /***********************************/ diff --git a/apps/settings.h b/apps/settings.h index f9deae1ebe..e6af373e15 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -588,6 +588,7 @@ struct user_settings bool talk_file_clip; /* use file .talk clips */ bool talk_filetype; /* say file type */ bool talk_battery_level; + int talk_mixer_amp; /* Relative volume of voices, MIX_AMP_MPUTE->MIX_AMP_UNITY */ /* file browser sorting */ bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */ diff --git a/apps/settings_list.c b/apps/settings_list.c index e296582482..40dbdfa152 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -61,6 +61,8 @@ #include "onplay.h" #endif +#include "voice_thread.h" + #if defined(DX50) || defined(DX90) #include "governor-ibasso.h" #include "usb-ibasso.h" @@ -1327,6 +1329,8 @@ const struct settings_list settings[] = { "talk filetype", NULL), OFFON_SETTING(F_TEMPVAR, talk_battery_level, LANG_TALK_BATTERY_LEVEL, false, "Announce Battery Level", NULL), + INT_SETTING(0, talk_mixer_amp, LANG_TALK_MIXER_LEVEL, 100, + "talk mixer level", UNIT_PERCENT, 0, 100, 5, NULL, NULL, voice_set_mixer_level), #ifdef HAVE_RECORDING /* recording */ diff --git a/apps/voice_thread.c b/apps/voice_thread.c index d7c352509b..77bdd08d44 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c @@ -31,6 +31,7 @@ #include "pcm.h" #include "pcm_mixer.h" #include "codecs/libspeex/speex/speex.h" +#include "settings.h" /* Default number of PCM frames to queue - adjust as necessary per-target */ #define VOICE_FRAMES 4 @@ -327,6 +328,13 @@ void voice_wait(void) sleep(1); } +void voice_set_mixer_level(int percent) +{ + percent *= MIX_AMP_UNITY; + percent /= 100; + mixer_channel_set_amplitude(PCM_MIXER_CHAN_VOICE, percent); +} + /* Initialize voice thread data that must be valid upon starting and the * setup the DSP parameters */ static void voice_data_init(struct voice_thread_data *td) @@ -337,7 +345,8 @@ static void voice_data_init(struct voice_thread_data *td) dsp_configure(td->dsp, DSP_SET_SAMPLE_DEPTH, VOICE_SAMPLE_DEPTH); dsp_configure(td->dsp, DSP_SET_STEREO_MODE, STEREO_MONO); - mixer_channel_set_amplitude(PCM_MIXER_CHAN_VOICE, MIX_AMP_UNITY); + voice_set_mixer_level(global_settings.talk_mixer_amp); + voice_buf->td = td; td->dst = NULL; } diff --git a/apps/voice_thread.h b/apps/voice_thread.h index 81b11eea37..c0122f0fb9 100644 --- a/apps/voice_thread.h +++ b/apps/voice_thread.h @@ -38,6 +38,8 @@ void voice_stop(void); void voice_thread_init(void); void voice_thread_kill(void); +void voice_set_mixer_level(int percent); + #ifdef HAVE_PRIORITY_SCHEDULING void voice_thread_set_priority(int priority); #endif -- cgit v1.2.3