diff options
author | XANTRONIX Development | 2022-03-07 21:58:17 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-03-07 21:58:17 -0500 |
commit | 826229642bebc059a5b403bb288bea1e4a56a8f4 (patch) | |
tree | f925dfca12627b3f2c36b939d26a46d2e7b4a12a /examples | |
parent | ac0defb30297d38a032104ae3c953a5d3c5ada60 (diff) | |
download | xas-826229642bebc059a5b403bb288bea1e4a56a8f4.tar.gz xas-826229642bebc059a5b403bb288bea1e4a56a8f4.tar.bz2 xas-826229642bebc059a5b403bb288bea1e4a56a8f4.zip |
Heheheh...
Diffstat (limited to 'examples')
-rw-r--r-- | examples/seq.c | 35 |
1 files changed, 30 insertions, 5 deletions
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); |