added volume support

I added support for setting the volume.
This commit is contained in:
William Hubbs 2008-07-28 07:20:46 -05:00
commit 572f333378

View file

@ -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);