diff options
Diffstat (limited to 'src/vox.c')
-rw-r--r-- | src/vox.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -213,6 +213,12 @@ static ssize_t vox_fill(xas_vox *vox, if (readlen == 0) { vox_stop(vox); + } else if (vox->gain != 1.0f) { + xas_audio_apply_gain(vox->format, + samples, + vox->gain, + 0, + readlen); } readcount = readlen / vox->format.sample_size; @@ -264,6 +270,12 @@ static void tmpfile_close(xas_vox *vox) { vox->tmpfh = NULL; } +static int set_gain(xas_vox *vox, float gain) { + xas_vox_set_gain(vox, gain); + + return 0; +} + xas_vox *xas_vox_new_args(xas_audio_format format, size_t buffer_size, const char *text2wave_path, @@ -275,8 +287,9 @@ xas_vox *xas_vox_new_args(xas_audio_format format, goto error_malloc_vox; } - vox->obj.start = (xas_object_start_callback)xas_vox_generate; - vox->obj.stop = (xas_object_stop_callback)xas_vox_stop; + vox->obj.start = (xas_object_start_callback)xas_vox_generate; + vox->obj.stop = (xas_object_stop_callback)xas_vox_stop; + vox->obj.set_gain = (xas_object_set_gain_callback)set_gain; vox->text2wave_path = text2wave_path; @@ -285,6 +298,7 @@ xas_vox *xas_vox_new_args(xas_audio_format format, vox->format.sample_rate = format.sample_rate; vox->buffer_size = buffer_size; + vox->gain = XAS_VOX_DEFAULT_GAIN; vox->state = XAS_VOX_IDLE; vox->pid = -1; vox->stdin = -1; @@ -322,6 +336,10 @@ void xas_vox_destroy(xas_vox *vox) { free(vox); } +void xas_vox_set_gain(xas_vox *vox, float gain) { + vox->gain = gain; +} + int xas_vox_set_voice(xas_vox *vox, const char *voice) { if (tmpfile_open(vox) < 0) { goto error_tmpfile_open; |