diff options
author | XANTRONIX Development | 2022-02-28 13:12:34 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-02-28 13:12:47 -0500 |
commit | 8723f399b2e63693d0e90a1b0af87be865069e22 (patch) | |
tree | 9e15df6b4cd051b9642001d546fb6c3488afffc2 /src | |
parent | 1b8fe922c267844f08b1795682ff8ab7e2b2a40c (diff) | |
download | xas-8723f399b2e63693d0e90a1b0af87be865069e22.tar.gz xas-8723f399b2e63693d0e90a1b0af87be865069e22.tar.bz2 xas-8723f399b2e63693d0e90a1b0af87be865069e22.zip |
Allow setting vox gain
Diffstat (limited to 'src')
-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; |