#include #include #include #include #include #include #include #include #include #include #include #include static void usage(int argc, char **argv, const char *message, ...) { va_list args; va_start(args, message); if (message) { vfprintf(stderr, message, args); fputc('\n', stderr); } va_end(args); fprintf(stderr, "usage: %s output.wav\n", argv[0]); exit(EX_USAGE); } int main(int argc, char **argv) { xas_spatial_scene *scene; xas_synth *sine; xas_audio_stream *synth, *voice, *output, *wave; xas_vox *vox; xas_audio_format format = { .channels = XAS_AUDIO_STEREO, .sample_size = XAS_AUDIO_PCM_16_BIT, .sample_rate = 44100 }; size_t buffer_size = 735, duration_s = 300, i; xas_spatial_coord speakers[2] = { { -0.09, 0.0, 0.0 }, { 0.09, 0.0, 0.0 } }; if (argc != 2) { usage(argc, argv, "No output file provided"); } if ((wave = xas_riff_new_file(argv[1], format, O_WRONLY | O_CREAT | O_TRUNC)) == NULL) { goto error_riff_new_file; } if ((sine = xas_synth_new(format, buffer_size, XAS_SYNTH_SINE)) == NULL) { goto error_synth_new; } if ((synth = xas_synth_stream_new(sine)) == NULL) { goto error_synth_stream_new; } if ((vox = xas_vox_new(format, "/usr/bin/text2wave")) == NULL) { goto error_vox_new; } xas_vox_set_parameter_float(vox, "Duration_Stretch", 1.3); 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) { goto error_spatial_scene_new; } if ((output = xas_spatial_scene_stream_new(scene, buffer_size)) == NULL) { goto error_spatial_scene_stream_new; } if (xas_spatial_scene_add_object(scene, (xas_spatial_coord){ 5.2, 0.0, 0.0 }, synth, sine) == NULL) { goto error_spatial_scene_add_object; } if (xas_spatial_scene_add_object(scene, (xas_spatial_coord){ -5.2, 0.0, 0.0 }, voice, vox) == NULL) { goto error_spatial_scene_add_object; } xas_synth_set_frequency(sine, 2600); xas_vox_set_voice(vox, "voice_cmu_us_slt_cg"); xas_synth_start(sine); xas_vox_sayf(vox, "I want to eat your soul.\n"); xas_vox_sayf(vox, "You don't understand.\n"); xas_vox_sayf(vox, "I really want to eat your soul.\n"); xas_vox_generate(vox); for (i=0; i