[Feature] Persist pitch settings through reboots

saves the pitch setting across reboots

adds option 'Reset Setting'

Change-Id: I75d88f9653883a256c6cca0f7adcdccb2dd51406
This commit is contained in:
William Wilgus 2025-01-17 03:01:53 -05:00 committed by William Wilgus
parent 5e8d3fec66
commit 13c3214d9c
7 changed files with 126 additions and 10 deletions

View file

@ -38,6 +38,11 @@
#include "talk.h"
#include "settings.h"
#if defined(HAVE_PITCHCONTROL)
#include "pitchscreen.h"
#include "misc.h"
#include "strcasecmp.h"
#endif
/* Macros to enable logf for queues
logging on SYS_TIMEOUT can be disabled */
#ifdef SIMULATOR
@ -185,4 +190,36 @@ void INIT_ATTR audio_init(void)
audio_is_initialized = true;
sound_settings_apply();
#if defined(HAVE_PITCHCONTROL)
int fd;
char line[64];
char* name;
char* value;
int32_t num;
fd = open_utf8(PITCH_CFG_FILE, O_RDONLY);
if (fd >= 0)
{
while (read_line(fd, line, sizeof line) > 0)
{
if (!settings_parseline(line, &name, &value))
continue;
if (strcasecmp(name, "pitch") == 0)
{
num = atoi(value);
if (num != PITCH_SPEED_100)
sound_set_pitch(num);
}
if (strcasecmp(name, "stretch") == 0)
{
num = atoi(value);
if (num != PITCH_SPEED_100)
dsp_set_timestretch(num);
}
}
}
#endif
}