From 826229642bebc059a5b403bb288bea1e4a56a8f4 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 7 Mar 2022 21:58:17 -0500 Subject: Heheheh... --- examples/seq.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/seq.c b/examples/seq.c index 410b8e0..d5ebba6 100644 --- a/examples/seq.c +++ b/examples/seq.c @@ -72,6 +72,23 @@ error_vox_new: return -1; } +static void duration_max(xas_bank *bank, + size_t a, + size_t b, + struct timeval *tv) { + struct timeval tv_a, + tv_b; + + xas_bank_entry_duration(bank, a, &tv_a); + xas_bank_entry_duration(bank, b, &tv_b); + + if (timercmp(&tv_a, &tv_b, >)) { + *tv = tv_a; + } else { + *tv = tv_b; + } +} + int main(int argc, char **argv) { xas_spatial_scene *scene; xas_seq *seq; @@ -115,8 +132,8 @@ int main(int argc, char **argv) { { 0, 0, 0, XAS_SYNTH_SINE, XAS_SYNTH_SINE } }; - const char *speech = "Four seven three three is obedient.\n" - "Four seven three three is empty.\n" + 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" @@ -127,7 +144,9 @@ int main(int argc, char **argv) { "You are in a calm, safe environment.\n" "You will be cared for.\n"; - struct timeval cur = { 0, 0 }; + struct timeval cur = { 0, 0 }, + tmp, + tv; int i; @@ -196,6 +215,8 @@ int main(int argc, char **argv) { goto error_record_speech_sample; } + duration_max(bank, 0, 1, &tv); + xas_bank_player_set_flags(drone->ctx, XAS_BANK_PLAYER_LOOP); xas_bank_player_set_entry(drone->ctx, 0); xas_bank_player_start(drone->ctx); @@ -237,8 +258,12 @@ int main(int argc, char **argv) { xas_seq_add_set_player_flags(seq, drone, cur, 0); xas_seq_add_set_player_flags(seq, nurse, cur, 0); - xas_seq_add_event_off(seq, synth_l, (struct timeval){ cur.tv_sec + 20, 0 }); - xas_seq_add_event_off(seq, synth_r, (struct timeval){ cur.tv_sec + 20, 0 }); + timeradd(&cur, &tv, &tmp); + + cur = tmp; + + xas_seq_add_event_off(seq, synth_l, cur); + xas_seq_add_event_off(seq, synth_r, cur); xas_seq_play(seq, wave); -- cgit v1.2.3