Add speech feedback in pitchscreen

Patch by Igor Poretsky

Change-Id: I8828cefdb3346a25071fba0afff2c9d3bca440a1
This commit is contained in:
Solomon Peachy 2019-01-01 23:33:44 -05:00
parent ee2ab046da
commit fd9d4a889b
2 changed files with 127 additions and 1 deletions

View file

@ -31,6 +31,7 @@
#include "lang.h" #include "lang.h"
#include "icons.h" #include "icons.h"
#include "screens.h" #include "screens.h"
#include "talk.h"
#include "viewport.h" #include "viewport.h"
#include "font.h" #include "font.h"
#include "system.h" #include "system.h"
@ -164,6 +165,18 @@ static bool at_limit = false;
* *
*/ */
static void speak_pitch_mode(bool enqueue)
{
bool timestretch_mode = global_settings.pitch_mode_timestretch && dsp_timestretch_available();
if (timestretch_mode)
talk_id(VOICE_PITCH_TIMESTRETCH_MODE, enqueue);
if (global_settings.pitch_mode_semitone)
talk_id(VOICE_PITCH_SEMITONE_MODE, timestretch_mode ? true : enqueue);
else
talk_id(VOICE_PITCH_ABSOLUTE_MODE, timestretch_mode ? true : enqueue);
return;
}
/* /*
* Fixes the viewports so they represent the 3 rows, and adds a little margin * Fixes the viewports so they represent the 3 rows, and adds a little margin
* on all sides for the icons (which are drawn outside of the grid * on all sides for the icons (which are drawn outside of the grid
@ -739,6 +752,7 @@ int gui_syncpitchscreen_run(void)
int32_t new_pitch; int32_t new_pitch;
int32_t pitch_delta; int32_t pitch_delta;
bool nudged = false; bool nudged = false;
int i, updated = 4, decimals = 0;
bool exit = false; bool exit = false;
/* should maybe be passed per parameter later, not needed for now */ /* should maybe be passed per parameter later, not needed for now */
struct viewport parent[NB_SCREENS]; struct viewport parent[NB_SCREENS];
@ -769,6 +783,10 @@ int gui_syncpitchscreen_run(void)
} }
#endif #endif
/* Count decimals for speaking */
for (i = PITCH_SPEED_PRECISION; i >= 10; i /= 10)
decimals++;
/* set the semitone index based on the current pitch */ /* set the semitone index based on the current pitch */
semitone = get_semitone_from_pitch(pitch); semitone = get_semitone_from_pitch(pitch);
@ -801,6 +819,49 @@ int gui_syncpitchscreen_run(void)
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
new_speed = 0; new_speed = 0;
#endif #endif
if (global_settings.talk_menu && updated)
{
talk_shutup();
switch (updated)
{
case 1:
if (global_settings.pitch_mode_semitone)
talk_value_decimal(semitone, UNIT_SIGNED, decimals, false);
else
talk_value_decimal(pitch, UNIT_PERCENT, decimals, false);
break;
#if CONFIG_CODEC == SWCODEC
case 2:
talk_value_decimal(speed, UNIT_PERCENT, decimals, false);
break;
#endif
case 3:
speak_pitch_mode(false);
break;
case 4:
#if CONFIG_CODEC == SWCODEC
if (global_settings.pitch_mode_timestretch && dsp_timestretch_available())
talk_id(LANG_PITCH, false);
else
#endif
talk_id(LANG_PLAYBACK_RATE, false);
talk_value_decimal(pitch, UNIT_PERCENT, decimals, true);
#if CONFIG_CODEC == SWCODEC
if (global_settings.pitch_mode_timestretch && dsp_timestretch_available())
{
talk_id(LANG_SPEED, true);
talk_value_decimal(speed, UNIT_PERCENT, decimals, true);
}
#endif
speak_pitch_mode(true);
break;
default:
break;
}
}
updated = 0;
button = get_action(CONTEXT_PITCHSCREEN, HZ); button = get_action(CONTEXT_PITCHSCREEN, HZ);
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN
@ -817,6 +878,7 @@ int gui_syncpitchscreen_run(void)
pitch_delta = SEMITONE_SMALL_DELTA; pitch_delta = SEMITONE_SMALL_DELTA;
else else
pitch_delta = PITCH_SMALL_DELTA; pitch_delta = PITCH_SMALL_DELTA;
updated = 1;
break; break;
case ACTION_PS_INC_BIG: case ACTION_PS_INC_BIG:
@ -824,6 +886,7 @@ int gui_syncpitchscreen_run(void)
pitch_delta = SEMITONE_BIG_DELTA; pitch_delta = SEMITONE_BIG_DELTA;
else else
pitch_delta = PITCH_BIG_DELTA; pitch_delta = PITCH_BIG_DELTA;
updated = 1;
break; break;
case ACTION_PS_DEC_SMALL: case ACTION_PS_DEC_SMALL:
@ -831,6 +894,7 @@ int gui_syncpitchscreen_run(void)
pitch_delta = -SEMITONE_SMALL_DELTA; pitch_delta = -SEMITONE_SMALL_DELTA;
else else
pitch_delta = -PITCH_SMALL_DELTA; pitch_delta = -PITCH_SMALL_DELTA;
updated = 1;
break; break;
case ACTION_PS_DEC_BIG: case ACTION_PS_DEC_BIG:
@ -838,6 +902,7 @@ int gui_syncpitchscreen_run(void)
pitch_delta = -SEMITONE_BIG_DELTA; pitch_delta = -SEMITONE_BIG_DELTA;
else else
pitch_delta = -PITCH_BIG_DELTA; pitch_delta = -PITCH_BIG_DELTA;
updated = 1;
break; break;
case ACTION_PS_NUDGE_RIGHT: case ACTION_PS_NUDGE_RIGHT:
@ -856,6 +921,7 @@ int gui_syncpitchscreen_run(void)
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
speed = pitch; speed = pitch;
#endif #endif
updated = nudged ? 1 : 0;
break; break;
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
} }
@ -863,6 +929,7 @@ int gui_syncpitchscreen_run(void)
{ {
new_speed = speed + SPEED_SMALL_DELTA; new_speed = speed + SPEED_SMALL_DELTA;
at_limit = false; at_limit = false;
updated = 2;
} }
break; break;
@ -874,6 +941,7 @@ int gui_syncpitchscreen_run(void)
if(new_speed % PITCH_SPEED_PRECISION != 0) if(new_speed % PITCH_SPEED_PRECISION != 0)
new_speed -= new_speed % PITCH_SPEED_PRECISION; new_speed -= new_speed % PITCH_SPEED_PRECISION;
at_limit = false; at_limit = false;
updated = 2;
} }
break; break;
#endif #endif
@ -891,6 +959,7 @@ int gui_syncpitchscreen_run(void)
#endif #endif
semitone = get_semitone_from_pitch(pitch); semitone = get_semitone_from_pitch(pitch);
nudged = false; nudged = false;
updated = 1;
} }
break; break;
@ -910,6 +979,7 @@ int gui_syncpitchscreen_run(void)
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
speed = pitch; speed = pitch;
#endif #endif
updated = nudged ? 1 : 0;
break; break;
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
} }
@ -917,6 +987,7 @@ int gui_syncpitchscreen_run(void)
{ {
new_speed = speed - SPEED_SMALL_DELTA; new_speed = speed - SPEED_SMALL_DELTA;
at_limit = false; at_limit = false;
updated = 2;
} }
break; break;
@ -928,6 +999,7 @@ int gui_syncpitchscreen_run(void)
if(new_speed % PITCH_SPEED_PRECISION != 0) if(new_speed % PITCH_SPEED_PRECISION != 0)
new_speed += PITCH_SPEED_PRECISION - speed % PITCH_SPEED_PRECISION; new_speed += PITCH_SPEED_PRECISION - speed % PITCH_SPEED_PRECISION;
at_limit = false; at_limit = false;
updated = 2;
} }
break; break;
#endif #endif
@ -945,6 +1017,7 @@ int gui_syncpitchscreen_run(void)
#endif #endif
semitone = get_semitone_from_pitch(pitch); semitone = get_semitone_from_pitch(pitch);
nudged = false; nudged = false;
updated = 1;
} }
break; break;
@ -960,6 +1033,7 @@ int gui_syncpitchscreen_run(void)
} }
#endif #endif
semitone = get_semitone_from_pitch(pitch); semitone = get_semitone_from_pitch(pitch);
updated = 4;
break; break;
case ACTION_PS_TOGGLE_MODE: case ACTION_PS_TOGGLE_MODE:
@ -978,6 +1052,7 @@ int gui_syncpitchscreen_run(void)
} }
settings_save(); settings_save();
#endif #endif
updated = 3;
break; break;
case ACTION_PS_EXIT: case ACTION_PS_EXIT:

View file

@ -11361,7 +11361,7 @@
</dest> </dest>
<voice> <voice>
*: none *: none
swcodec: "Timestretch" swcodec: "Time stretch"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
@ -14000,3 +14000,54 @@
charging: "Delay Before Resume" charging: "Delay Before Resume"
</voice> </voice>
</phrase> </phrase>
<phrase>
id: VOICE_PITCH_ABSOLUTE_MODE
desc: spoken only
user: core
<source>
*: none
pitchscreen: ""
</source>
<dest>
*: none
pitchscreen: ""
</dest>
<voice>
*: none
pitchscreen: "Absolute mode"
</voice>
</phrase>
<phrase>
id: VOICE_PITCH_SEMITONE_MODE
desc: spoken only
user: core
<source>
*: none
pitchscreen: ""
</source>
<dest>
*: none
pitchscreen: ""
</dest>
<voice>
*: none
pitchscreen: "Semitone mode"
</voice>
</phrase>
<phrase>
id: VOICE_PITCH_TIMESTRETCH_MODE
desc: spoken only
user: core
<source>
*: none
pitchscreen: ""
</source>
<dest>
*: none
pitchscreen: ""
</dest>
<voice>
*: none
pitchscreen: "Time stretch"
</voice>
</phrase>