diff --git a/espeak.c b/espeak.c index 8871d1b..0ce680f 100644 --- a/espeak.c +++ b/espeak.c @@ -28,6 +28,7 @@ /* default voice settings */ const int defaultFrequency = 5; const int defaultPitch = 5; +const int defaultRange = 5; const int defaultRate = 2; const int defaultVolume = 5; char *defaultVoice = NULL; @@ -35,6 +36,7 @@ char *defaultVoice = NULL; /* multipliers and offsets */ const int frequencyMultiplier = 11; const int pitchMultiplier = 11; +const int rangeMultiplier = 11; const int rateMultiplier = 41; const int rateOffset = 80; const int volumeMultiplier = 22; @@ -87,6 +89,21 @@ static espeak_ERROR set_pitch(struct synth_t *s, int pitch, return rc; } +static espeak_ERROR set_range(struct synth_t *s, int range, + enum adjust_t adj) +{ + espeak_ERROR rc; + + if (adj == ADJ_DEC) + range = -range; + if (adj != ADJ_SET) + range += s->range; + rc = espeak_SetParameter(espeakRANGE, range * rangeMultiplier, 0); + if (rc == EE_OK) + s->range = range; + return rc; +} + static espeak_ERROR set_punctuation(struct synth_t *s, int punct, enum adjust_t adj) { @@ -261,6 +278,9 @@ static void queue_process_entry(struct synth_t *s) case CMD_SET_PITCH: error = set_pitch(s, current->value, current->adjust); break; + case CMD_SET_RANGE: + error = set_range(s, current->value, current->adjust); + break; case CMD_SET_PUNCTUATION: error = set_punctuation(s, current->value, current->adjust); break; @@ -318,6 +338,7 @@ int initialize_espeak(struct synth_t *s) } set_frequency(s, defaultFrequency, ADJ_SET); set_pitch(s, defaultPitch, ADJ_SET); + set_range(s, defaultRange, ADJ_SET); set_rate(s, defaultRate, ADJ_SET); set_volume(s, defaultVolume, ADJ_SET); espeak_SetParameter(espeakCAPITALS, 0, 0); diff --git a/espeakup.h b/espeakup.h index e8e89a7..2e2295f 100644 --- a/espeakup.h +++ b/espeakup.h @@ -39,6 +39,7 @@ enum espeakup_mode_t { enum command_t { CMD_SET_FREQUENCY, CMD_SET_PITCH, + CMD_SET_RANGE, CMD_SET_PUNCTUATION, CMD_SET_RATE, CMD_SET_VOICE, @@ -66,6 +67,7 @@ struct espeak_entry_t { struct synth_t { int frequency; int pitch; + int range; int punct; int rate; char voice[10]; diff --git a/softsynth.c b/softsynth.c index fffef44..574d37e 100644 --- a/softsynth.c +++ b/softsynth.c @@ -127,6 +127,9 @@ static int process_command(struct synth_t *s, char *buf, int start) case 'p': cmd = CMD_SET_PITCH; break; + case 'r': + cmd = CMD_SET_RANGE; + break; case 's': cmd = CMD_SET_RATE; break;