From fc378a22b3294bcb696b8600e6fd8f9f639c36fc Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Wed, 23 Feb 2022 00:21:18 -0500 Subject: Add voice synth to examples/spatial.c --- examples/spatial.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/examples/spatial.c b/examples/spatial.c index 049fee5..93bb641 100644 --- a/examples/spatial.c +++ b/examples/spatial.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -65,9 +66,12 @@ int main(int argc, char **argv) { xas_spatial_scene *scene; xas_audio_stream *synth, + *voice, *output, *wave; + xas_vox *vox; + synth_sine sine_channels[2] = { { SYNTH_STATUS_ON, 0.0f, 2600 }, { SYNTH_STATUS_ON, 0.0f, 420 }, @@ -79,8 +83,8 @@ int main(int argc, char **argv) { .sample_rate = 44100 }; - size_t buffer_size = 44100, - duration_s = 5, + size_t buffer_size = 735, + duration_s = 300, i; xas_spatial_coord speakers[2] = { @@ -106,6 +110,16 @@ int main(int argc, char **argv) { goto error_synth_new; } + if ((vox = xas_vox_new("/usr/bin/text2wave", + format, + buffer_size)) == NULL) { + goto error_vox_new; + } + + if ((voice = xas_vox_stream_new(vox)) == NULL) { + goto error_vox_stream_new; + } + if ((scene = xas_spatial_scene_new(format, speakers[0], speakers[1])) == NULL) { @@ -123,6 +137,16 @@ int main(int argc, char **argv) { goto error_spatial_scene_add_object; } + if (xas_spatial_scene_add_object(scene, + (xas_spatial_coord){ -5.2, 0.0, 0.0 }, + voice) == NULL) { + goto error_spatial_scene_add_object; + } + + xas_vox_say(vox, "I want to eat your soul. You don't understand. I really want to eat your soul.\n"); + + xas_vox_generate(vox); + for (i=0; i