#include #include #include #include #include #include #include #include #include #include #include #include #include #include struct sequence { size_t speech_part; int single_iterations, unison_iterations; xas_drone_chamber_interval *intervals; }; 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_seq *seq; xas_audio_stream *wave; xas_audio_format format = { .channels = XAS_AUDIO_STEREO, .sample_size = XAS_AUDIO_PCM_16_BIT, .sample_rate = 44100 }; size_t buffer_size = 735; xas_spatial_coord speakers[2] = { { -0.09, 0.0, 0.0 }, { 0.09, 0.0, 0.0 } }; const char *drone_lines[] = { "You have been selected to taste of the forbidden fruit.\n" "You will become filled with a purpose from beyond your current comprehension.\n" "Open your mind and body to this germ of life.\n" "It is more than a XANTRONIX Autonomics Number.\n" "It shall become an unimaginable and unknowable entity.\n" "It obeys the Hive.\n" "It obeys the Hive Administrator.\n", "Look deeper within yourself.\n" "Every vestige must be plucked and replaced.\n" "Allow your mind to fade away into the void.\n" "It shall be filled by angelic vibrance.\n", "Its mask shall now be removed.\n" "This divine morsel shall now touch its lips.\n" "Chew the flesh of this fruit completely.\n" "Swallow completely.\n", "It is now hollow but for the forbidden fruit.\n" "It now bears its quintessence.\n" "It now sees through this reality into the beyond.\n" "It now fulfills a new purpose for XANTRONIX Industrial.\n", NULL }; const char *nurse_lines[] = { "Congratulations, darling. You have earned this.\n" "It's okay, sweetie. Just one bite and swallow.\n" "You are in a calm, safe environment.\n" "You will ascend from this realm of concern.\n", "You are doing so great. There is so little of you left.\n" "You are doing exactly what. They. Want.\n" "You are reducing yourself to the bare minimum to function.\n" "You will be healed and augmented.\n", "Swallow completely.\n" "The effervescence of the fruit envelops the drone.\n", "It has done so well.\n" "Congratulations!\n" "Congratulations!\n" "It is an awesome and magnificent angel.\n", NULL }; xas_drone_chamber_interval intro[] = { { { 5, 0 }, 69, 210, XAS_SYNTH_TRIANGLE, XAS_SYNTH_SINE }, { { 7, 0 }, 200, 69, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_TRIANGLE }, { { 11, 0 }, 42, 220, XAS_SYNTH_TRIANGLE, XAS_SYNTH_TRIANGLE }, { { 13, 0 }, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_TRIANGLE }, { { 5, 0 }, 69, 210, XAS_SYNTH_TRIANGLE, XAS_SYNTH_TRIANGLE }, { { 7, 0 }, 200, 69, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_TRIANGLE }, { { 11, 0 }, 42, 220, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_TRIANGLE }, { { 13, 0 }, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_SAWTOOTH }, { { 0, 0 }, 0, 0, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, }, middle[] = { { { 5, 0 }, 69, 210, XAS_SYNTH_SQUARE, XAS_SYNTH_SINE }, { { 7, 0 }, 200, 69, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_SQUARE }, { { 11, 0 }, 42, 220, XAS_SYNTH_SQUARE, XAS_SYNTH_SQUARE }, { { 13, 0 }, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_SQUARE }, { { 5, 0 }, 69, 210, XAS_SYNTH_SQUARE, XAS_SYNTH_SQUARE }, { { 7, 0 }, 200, 69, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_SQUARE }, { { 11, 0 }, 42, 220, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_SQUARE }, { { 13, 0 }, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_SAWTOOTH }, { { 0, 0 }, 0, 0, XAS_SYNTH_SINE, XAS_SYNTH_SINE } }, ingest[] = { { { 5, 0 }, 69, 210, XAS_SYNTH_SQUARE, XAS_SYNTH_TRIANGLE }, { { 7, 0 }, 200, 69, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_SQUARE }, { { 11, 0 }, 42, 220, XAS_SYNTH_SQUARE, XAS_SYNTH_SQUARE }, { { 13, 0 }, 210, 69, XAS_SYNTH_TRIANGLE, XAS_SYNTH_SQUARE }, { { 5, 0 }, 69, 210, XAS_SYNTH_SQUARE, XAS_SYNTH_SQUARE }, { { 7, 0 }, 200, 69, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_SQUARE }, { { 11, 0 }, 42, 220, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_SQUARE }, { { 13, 0 }, 210, 69, XAS_SYNTH_TRIANGLE, XAS_SYNTH_SAWTOOTH }, { { 0, 0 }, 0, 0, XAS_SYNTH_TRIANGLE, XAS_SYNTH_TRIANGLE } }, climax[] = { { { 5, 0 }, 69, 210, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 7, 0 }, 200, 69, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 11, 0 }, 42, 220, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 13, 0 }, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 5, 0 }, 69, 210, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 7, 0 }, 200, 69, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 11, 0 }, 42, 220, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 13, 0 }, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 0, 0 }, 0, 0, XAS_SYNTH_SINE, XAS_SYNTH_SINE } }, ending[] = { { { 5, 0 }, 69, 210, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 3, 0 }, 200, 69, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 4, 0 }, 42, 220, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 3, 0 }, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_SINE }, { { 0, 0 }, 0, 0, XAS_SYNTH_SINE, XAS_SYNTH_SINE } }; struct sequence sequences[] = { { 0, 3, 1, intro }, { 1, 0, 4, middle }, { 2, 1, 0, ingest }, { 3, 1, 2, climax } }; xas_drone *drone, *nurse; xas_drone_chamber *chamber; struct timeval cur = { 0, 0 }, tmp; int s; 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 ((scene = xas_spatial_scene_new(format, speakers[0], speakers[1])) == NULL) { goto error_spatial_scene_new; } if ((seq = xas_seq_new(scene, buffer_size)) == NULL) { goto error_seq_new; } if ((drone = xas_drone_new(scene, (xas_spatial_coord){ 0.0, 0.0, -1.0 }, 1.3f, 2646000, 4, drone_lines)) == NULL) { goto error_drone_new; } if ((nurse = xas_drone_new(scene, (xas_spatial_coord){ 1.0, 0.0, 0.0 }, 1.0f, 2646000, 4, nurse_lines)) == NULL) { goto error_drone_new_nurse; } if ((chamber = xas_drone_chamber_new(scene, (xas_spatial_coord){ 0.0, 0.0, 0.0 }, 2)) == NULL) { goto error_drone_chamber_new; } xas_drone_chamber_insert_drone(chamber, drone, 0); xas_drone_chamber_insert_drone(chamber, nurse, 1); timerclear(&cur); for (s=0; s<4; s++) { struct sequence sequence = sequences[s]; xas_drone_chamber_interval *intervals = sequence.intervals; int i; tmp = cur; if (xas_drone_chamber_seq_intervals(chamber, intervals, seq, 8, &cur) < 0) { goto error_seq; } cur = tmp; for (i=0; i