summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXANTRONIX Development2022-03-10 10:47:58 -0500
committerXANTRONIX Development2022-03-10 10:47:58 -0500
commit18bd94f7e42d9410967b15c2db4f62b4c6153575 (patch)
tree49f678b5754c9f77442a8fbfa8bc10e78c6c2594 /src
parentc1d4b998ae16a8dd4738e6da2b9f98b61b7e707c (diff)
downloadxas-18bd94f7e42d9410967b15c2db4f62b4c6153575.tar.gz
xas-18bd94f7e42d9410967b15c2db4f62b4c6153575.tar.bz2
xas-18bd94f7e42d9410967b15c2db4f62b4c6153575.zip
Implement xas_chamber_drone_chorus_seq()
Implement xas_chamber_drone_chorus_seq() to add a chorus of all drones speaking their selected speech parts
Diffstat (limited to 'src')
-rw-r--r--src/drone.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/drone.c b/src/drone.c
index e3748f1..47508f9 100644
--- a/src/drone.c
+++ b/src/drone.c
@@ -260,3 +260,55 @@ int xas_drone_chamber_event_seq(xas_drone_chamber *chamber,
error_seq_add:
return -1;
}
+
+static void max_speech_duration(xas_drone_chamber *chamber,
+ struct timeval *max) {
+ size_t i;
+
+ for (i=0; i<chamber->drone_count; i++) {
+ xas_drone *drone = chamber->drones[i];
+ xas_bank_player *player = (xas_bank_player *)drone->obj->ctx;
+
+ struct timeval duration;
+
+ xas_bank_entry_duration(drone->bank,
+ player->entry,
+ &duration);
+
+ if (timercmp(&duration, max, >)) {
+ duration.tv_sec = max->tv_sec;
+ duration.tv_usec = max->tv_usec;
+ }
+ }
+}
+
+int xas_drone_chamber_chorus_seq(xas_drone_chamber *chamber,
+ xas_seq *seq,
+ int advance,
+ struct timeval *now) {
+ struct timeval duration,
+ tmp,
+ delay = { 0, 500000 };
+
+ size_t i;
+
+ max_speech_duration(chamber, &duration);
+
+ for (i=0; i<chamber->drone_count; i++) {
+ xas_drone *drone = chamber->drones[i];
+
+ if (xas_seq_add_event_on(seq, drone->obj, *now) < 0) {
+ goto error_seq_add;
+ }
+ }
+
+ if (advance) {
+ timeradd(now, &duration, &tmp);
+ timeradd(&tmp, &delay, now);
+ }
+
+ return 0;
+
+error_seq_add:
+ return -1;
+}