From 4d642a1810c7ba27c75bd35efa0b223bb38f5e5e Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 8 Mar 2022 00:55:29 -0500 Subject: Wow...I guess we're just about there. --- examples/seq.c | 58 +++++++++++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/examples/seq.c b/examples/seq.c index d5ebba6..1c333c5 100644 --- a/examples/seq.c +++ b/examples/seq.c @@ -72,23 +72,6 @@ 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; @@ -144,9 +127,7 @@ 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 }, - tmp, - tv; + struct timeval cur = { 0, 0 }; int i; @@ -215,13 +196,7 @@ 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); - - xas_bank_player_set_flags(nurse->ctx, XAS_BANK_PLAYER_LOOP); xas_bank_player_set_entry(nurse->ctx, 1); /* @@ -234,10 +209,6 @@ int main(int argc, char **argv) { xas_synth_set_type(bass->ctx, XAS_SYNTH_SQUARE); xas_synth_start(bass->ctx); - xas_seq_add_event_on(seq, - nurse, - (struct timeval){ 10, 0 }); - timerclear(&cur); for (i=0; freqs[i].duration; i++) { @@ -255,12 +226,29 @@ int main(int argc, char **argv) { cur = res; } - xas_seq_add_set_player_flags(seq, drone, cur, 0); - xas_seq_add_set_player_flags(seq, nurse, cur, 0); - - timeradd(&cur, &tv, &tmp); + timerclear(&cur); - cur = tmp; + for (i=0; i<3; i++) { + struct timeval duration_drone, + duration_nurse, + delay = { 0, 500000 }, + tmp; + + xas_bank_entry_duration(bank, 0, &duration_drone); + xas_bank_entry_duration(bank, 1, &duration_nurse); + + xas_seq_add_event_on(seq, drone, cur); + timeradd(&cur, &duration_drone, &tmp); + cur = tmp; + timeradd(&cur, &delay, &tmp); + cur = tmp; + + xas_seq_add_event_on(seq, nurse, cur); + timeradd(&cur, &duration_nurse, &tmp); + cur = tmp; + timeradd(&cur, &delay, &tmp); + cur = tmp; + } xas_seq_add_event_off(seq, synth_l, cur); xas_seq_add_event_off(seq, synth_r, cur); -- cgit v1.2.3