mirror of
https://github.com/linux-speakup/espeakup.git
synced 2026-08-09 09:19:09 +02:00
added volume support
I added support for setting the volume.
This commit is contained in:
parent
4e3bbdb0b0
commit
572f333378
1 changed files with 17 additions and 0 deletions
17
espeakup.c
17
espeakup.c
|
|
@ -30,11 +30,13 @@
|
|||
const int pitchMultiplier = 10;
|
||||
const int rateMultiplier = 32;
|
||||
const int rateOffset = 80;
|
||||
const int volumeMultiplier = 10;
|
||||
|
||||
struct synth_t {
|
||||
int fd;
|
||||
int pitch;
|
||||
int rate;
|
||||
int volume;
|
||||
char buf[1025];
|
||||
};
|
||||
|
||||
|
|
@ -53,6 +55,11 @@ static void set_rate (struct synth_t *s)
|
|||
espeak_SetParameter(espeakRATE, s->rate * rateMultiplier + rateOffset, 0);
|
||||
}
|
||||
|
||||
static void set_volume (struct synth_t *s)
|
||||
{
|
||||
espeak_SetParameter(espeakVOLUME, s->volume * volumeMultiplier, 0);
|
||||
}
|
||||
|
||||
static void stop_speech(void)
|
||||
{
|
||||
espeak_Cancel();
|
||||
|
|
@ -87,6 +94,10 @@ static int process_command(struct synth_t *s, char *buf, int start)
|
|||
s->rate += value;
|
||||
set_rate (s);
|
||||
break;
|
||||
case 'v':
|
||||
s->volume += value;
|
||||
set_volume (s);
|
||||
break;
|
||||
}
|
||||
return 4;
|
||||
} else if (buf[start+1] >= '0' && buf[start+1] <= '9') {
|
||||
|
|
@ -101,6 +112,10 @@ static int process_command(struct synth_t *s, char *buf, int start)
|
|||
s->rate = value;
|
||||
set_rate (s);
|
||||
break;
|
||||
case 'v':
|
||||
s->volume = value;
|
||||
set_volume (s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 3;
|
||||
|
|
@ -176,9 +191,11 @@ int main ()
|
|||
/* Setup initial voice parameters */
|
||||
s.pitch = 5;
|
||||
s.rate = 5;
|
||||
s.volume = 5;
|
||||
strcpy(s.buf,"");
|
||||
set_pitch (&s);
|
||||
set_rate (&s);
|
||||
set_volume(&s);
|
||||
|
||||
/* run the main loop */
|
||||
main_loop (&s);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue