mirror of
https://github.com/linux-speakup/espeakup.git
synced 2026-08-22 07:44:16 +02:00
added frequency support
This patch, also from Kirk Reiser, adds frequency support.
This commit is contained in:
parent
cddead8aa9
commit
d7de943a3a
1 changed files with 17 additions and 0 deletions
17
espeakup.c
17
espeakup.c
|
|
@ -36,12 +36,14 @@ const int maxBufferSize = 1025;
|
|||
const char *pidPath = "/var/run/espeakup.pid";
|
||||
|
||||
/* multipliers and offsets */
|
||||
const int frequencyMultiplier = 11;
|
||||
const int pitchMultiplier = 10;
|
||||
const int rateMultiplier = 32;
|
||||
const int rateOffset = 80;
|
||||
const int volumeMultiplier = 10;
|
||||
|
||||
struct synth_t {
|
||||
int frequency;
|
||||
int pitch;
|
||||
int rate;
|
||||
char voice[40];
|
||||
|
|
@ -58,6 +60,11 @@ int SynthCallback(short *wav, int numsamples, espeak_EVENT *events)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void set_frequency (struct synth_t *s)
|
||||
{
|
||||
espeak_SetParameter(espeakRANGE, s->frequency * frequencyMultiplier, 0);
|
||||
}
|
||||
|
||||
static void set_pitch (struct synth_t *s)
|
||||
{
|
||||
espeak_SetParameter(espeakPITCH, s->pitch * pitchMultiplier, 0);
|
||||
|
|
@ -104,6 +111,10 @@ static int process_command(struct synth_t *s, char *buf, int start)
|
|||
if (buf[start+1] == '-')
|
||||
value = -value;
|
||||
switch (param) {
|
||||
case 'f':
|
||||
s->frequency += value;
|
||||
set_frequency (s);
|
||||
break;
|
||||
case 'p':
|
||||
s->pitch += value;
|
||||
set_pitch (s);
|
||||
|
|
@ -122,6 +133,10 @@ static int process_command(struct synth_t *s, char *buf, int start)
|
|||
value = buf[start+1]-'0';
|
||||
param = buf[start+2];
|
||||
switch (param) {
|
||||
case 'f':
|
||||
s->frequency = value;
|
||||
set_frequency (s);
|
||||
break;
|
||||
case 'p':
|
||||
s->pitch = value;
|
||||
set_pitch (s);
|
||||
|
|
@ -249,6 +264,7 @@ void espeakup_sighandler(int sig)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
struct synth_t s = {
|
||||
.frequency = 5,
|
||||
.pitch = 5,
|
||||
.rate = 5,
|
||||
.voice = "default",
|
||||
|
|
@ -298,6 +314,7 @@ int main(int argc, char **argv)
|
|||
|
||||
/* Setup initial voice parameters */
|
||||
set_voice(&s);
|
||||
set_frequency (&s);
|
||||
set_pitch (&s);
|
||||
set_rate (&s);
|
||||
set_volume(&s);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue