From c66d69c2c3646cad9ef2746ddbd7acb68a5f73da Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Thu, 10 Mar 2022 15:31:42 -0500 Subject: I'm not CURRENTLY operating a bimbo hive... --- examples/seq.c | 361 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 177 insertions(+), 184 deletions(-) (limited to 'examples') diff --git a/examples/seq.c b/examples/seq.c index 18dd60f..1482ac3 100644 --- a/examples/seq.c +++ b/examples/seq.c @@ -11,6 +11,7 @@ #include #include #include +#include #include static void usage(int argc, char **argv, const char *message, ...) { @@ -30,60 +31,10 @@ static void usage(int argc, char **argv, const char *message, ...) { exit(EX_USAGE); } -static int record_speech_sample(xas_bank *bank, - size_t buffer_size, - size_t entry_index, - float speed, - const char *text) { - xas_vox *vox; - xas_audio_stream *source; - - if ((vox = xas_vox_new(bank->format, - buffer_size, - "/usr/bin/text2wave")) == NULL) { - goto error_vox_new; - } - - if ((source = xas_vox_stream_new(vox)) == NULL) { - goto error_vox_stream_new; - } - - xas_vox_set_voice(vox, "voice_cmu_us_slt_cg"); - xas_vox_set_parameter_float(vox, "Duration_Stretch", speed); - xas_vox_say(vox, text); - xas_vox_generate(vox); - - if (xas_bank_record(bank, source, entry_index, bank->entry_size) < 0) { - goto error_bank_record; - } - - xas_audio_stream_destroy(source); - xas_vox_destroy(vox); - - return 0; - -error_bank_record: - xas_audio_stream_destroy(source); - -error_vox_stream_new: - xas_vox_destroy(vox); - -error_vox_new: - return -1; -} - int main(int argc, char **argv) { xas_spatial_scene *scene; xas_seq *seq; - xas_bank *bank; - - xas_spatial_object *synth_l, - *synth_r, - *bass, - *drone, - *nurse; - xas_audio_stream *wave; xas_audio_format format = { @@ -99,37 +50,116 @@ int main(int argc, char **argv) { { 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 } + }; + struct { - time_t duration; - size_t freq_l, freq_r; - enum xas_synth_type type_l, type_r; - } freqs[] = { - { 5, 69, 210, XAS_SYNTH_TRIANGLE, XAS_SYNTH_SINE }, - { 7, 200, 69, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_TRIANGLE }, - { 11, 42, 220, XAS_SYNTH_TRIANGLE, XAS_SYNTH_TRIANGLE }, - { 13, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_TRIANGLE }, - { 5, 69, 210, XAS_SYNTH_TRIANGLE, XAS_SYNTH_TRIANGLE }, - { 7, 200, 69, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_TRIANGLE }, - { 11, 42, 220, XAS_SYNTH_SAWTOOTH, XAS_SYNTH_TRIANGLE }, - { 13, 210, 69, XAS_SYNTH_SINE, XAS_SYNTH_SAWTOOTH }, - { 0, 0, 0, XAS_SYNTH_SINE, XAS_SYNTH_SINE } + size_t speech_part; + xas_drone_chamber_interval *intervals; + } sequences[] = { + { 0, intro }, + { 1, middle }, + { 2, ingest }, + { 3, climax } }; - const char *speech = "Three three three four is obedient.\n" - "Three three three four is empty.\n" - "Obey XANTRONIX Industrial.\n" - "It is just a XANTRONIX semi-autonomous number.\n" - "It obeys the Hive.\n" - "It obeys the Hive Administrator.\n"; + xas_drone *drone, + *nurse; - const char *calm = "Relax, honey. There is no point trying to escape.\n" - "It's okay, sweetie. This one is right here with you.\n" - "You are in a calm, safe environment.\n" - "You will be cared for.\n"; + xas_drone_chamber *chamber; - struct timeval cur = { 0, 0 }; + struct timeval cur = { 0, 0 }, + tmp; - int i; + size_t part; if (argc != 2) { usage(argc, argv, "No output file provided"); @@ -141,155 +171,118 @@ int main(int argc, char **argv) { goto error_riff_new_file; } - if ((bank = xas_bank_new(format, 2646000, 4)) == NULL) { - goto error_bank_new; - } - if ((scene = xas_spatial_scene_new(format, speakers[0], speakers[1])) == NULL) { goto error_spatial_scene_new; } - if ((drone = xas_spatial_scene_add_bank_player(scene, - (xas_spatial_coord){ 0.0, 0.0, -1.0 }, - bank)) == NULL) { - goto error_spatial_scene_add_bank_player; - } - - if ((nurse = xas_spatial_scene_add_bank_player(scene, - (xas_spatial_coord){ 3.0, 0.0, 0.0 }, - bank)) == NULL) { - goto error_spatial_scene_add_bank_player; - } - - if ((synth_l = xas_spatial_scene_add_synth(scene, - (xas_spatial_coord){ -5.0, 0.0, 0.0 }, - XAS_SYNTH_SINE)) == NULL) { - goto error_spatial_scene_add_synth_l; - } - - if ((synth_r = xas_spatial_scene_add_synth(scene, - (xas_spatial_coord){ 5.0, 0.0, 0.0 }, - XAS_SYNTH_SINE)) == NULL) { - goto error_spatial_scene_add_synth_r; - } - - if ((bass = xas_spatial_scene_add_synth(scene, - (xas_spatial_coord){ 0.0, 0.0, 5.0 }, - XAS_SYNTH_SQUARE)) == NULL) { - goto error_spatial_scene_add_synth_r; - } - if ((seq = xas_seq_new(scene, buffer_size)) == NULL) { goto error_seq_new; } - /* - * Generate drone voice lines - */ - if (record_speech_sample(bank, buffer_size, 0, 1.3f, speech) < 0) { - goto error_record_speech_sample; + 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 (record_speech_sample(bank, buffer_size, 1, 1.0, calm) < 0) { - goto error_record_speech_sample; + 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; } - xas_bank_player_set_entry(drone->ctx, 0); - xas_bank_player_set_entry(nurse->ctx, 1); - - /* - * Start synths - */ - xas_synth_start(synth_l->ctx); - xas_synth_start(synth_r->ctx); - - xas_synth_set_frequency(bass->ctx, 20); - xas_synth_set_type(bass->ctx, XAS_SYNTH_SQUARE); - xas_synth_start(bass->ctx); - - timerclear(&cur); - - for (i=0; freqs[i].duration; i++) { - struct timeval res, duration = { - freqs[i].duration, 0 - }; - - xas_seq_add_set_frequency( seq, synth_l, cur, freqs[i].freq_l); - xas_seq_add_set_synth_type(seq, synth_l, cur, freqs[i].type_l); - xas_seq_add_set_frequency( seq, synth_r, cur, freqs[i].freq_r); - xas_seq_add_set_synth_type(seq, synth_r, cur, freqs[i].type_r); - - timeradd(&cur, &duration, &res); - - cur = res; + 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 (i=0; i<2; i++) { - struct timeval duration_drone, - duration_nurse, - delay = { 0, 500000 }, - tmp; + for (part=0; part<4; part++) { + xas_drone_chamber_interval *intervals = sequences[part].intervals; + int i; - xas_bank_entry_duration(bank, 0, &duration_drone); - xas_bank_entry_duration(bank, 1, &duration_nurse); + tmp = cur; - xas_seq_add_event_on(seq, drone, cur); - timeradd(&cur, &duration_drone, &tmp); - cur = tmp; - timeradd(&cur, &delay, &tmp); - cur = tmp; + if (xas_drone_chamber_seq_intervals(chamber, + intervals, + seq, + 8, + &cur) < 0) { + goto error_seq; + } - xas_seq_add_event_on(seq, nurse, cur); - timeradd(&cur, &duration_nurse, &tmp); cur = tmp; - timeradd(&cur, &delay, &tmp); - cur = tmp; - } - - for (i=0; i<2; i++) { - struct timeval duration_drone, - delay = { 0, 500000 }, - tmp; - xas_bank_entry_duration(bank, 0, &duration_drone); - - xas_seq_add_event_on(seq, drone, cur); - xas_seq_add_event_on(seq, nurse, cur); - timeradd(&cur, &duration_drone, &tmp); - cur = tmp; - timeradd(&cur, &delay, &tmp); - cur = tmp; + for (i=0; i<2; i++) { + if (xas_drone_chamber_seq_speech(chamber, + drone, + seq, + part, + &cur) < 0) { + goto error_seq; + } + + if (xas_drone_chamber_seq_speech(chamber, + nurse, + seq, + part, + &cur) < 0) { + goto error_seq; + } + } + + for (i=0; i<2; i++) { + if (xas_drone_chamber_seq_chorus(chamber, + seq, + part, + &cur) < 0) { + goto error_seq; + } + } } - xas_seq_add_event_off(seq, synth_l, cur); - xas_seq_add_event_off(seq, synth_r, cur); + xas_seq_add_stop(seq, cur); xas_seq_play(seq, wave); + xas_drone_chamber_destroy(chamber); + xas_drone_destroy(nurse); + xas_drone_destroy(drone); xas_seq_destroy(seq); xas_spatial_scene_destroy(scene); - xas_bank_destroy(bank); xas_audio_stream_destroy(wave); return EX_OK; -error_record_speech_sample: +error_seq: + xas_drone_chamber_destroy(chamber); + +error_drone_chamber_new: + xas_drone_destroy(nurse); + +error_drone_new_nurse: + xas_drone_destroy(drone); + +error_drone_new: xas_seq_destroy(seq); error_seq_new: -error_spatial_scene_add_synth_r: -error_spatial_scene_add_synth_l: -error_spatial_scene_add_bank_player: xas_spatial_scene_destroy(scene); error_spatial_scene_new: - xas_bank_destroy(bank); - -error_bank_new: xas_audio_stream_destroy(wave); error_riff_new_file: -- cgit v1.2.3