diff options
author | XANTRONIX Development | 2022-02-23 00:21:18 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-02-23 00:21:18 -0500 |
commit | fc378a22b3294bcb696b8600e6fd8f9f639c36fc (patch) | |
tree | 2d130445cc89ff053ffc8c962967524a0cd0a314 /examples | |
parent | 561b87224f8a474563ee70d33d148f0daf735249 (diff) | |
download | xas-fc378a22b3294bcb696b8600e6fd8f9f639c36fc.tar.gz xas-fc378a22b3294bcb696b8600e6fd8f9f639c36fc.tar.bz2 xas-fc378a22b3294bcb696b8600e6fd8f9f639c36fc.zip |
Add voice synth to examples/spatial.c
Diffstat (limited to 'examples')
-rw-r--r-- | examples/spatial.c | 34 |
1 files 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 <xas/spatial.h> #include <xas/synth.h> +#include <xas/vox.h> #include <xas/audio.h> #include <xas/riff.h> @@ -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<duration_s; i++) { void *buf; ssize_t readlen; @@ -156,6 +180,12 @@ error_spatial_scene_new_stream: xas_spatial_scene_destroy(scene); error_spatial_scene_new: + xas_audio_stream_destroy(voice); + +error_vox_stream_new: + xas_vox_destroy(vox); + +error_vox_new: xas_audio_stream_destroy(synth); error_synth_new: |