diff options
author | XANTRONIX Development | 2022-03-10 14:42:59 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-03-10 14:42:59 -0500 |
commit | 5ca4b3bcc5e934191a23283612ca711e90f217ed (patch) | |
tree | 86ec6134a728f55dd0c49364ff2c2b4e8ebeb7bb /src | |
parent | 12650a91c92708adc6a65b081be1ba4d6178dedc (diff) | |
download | xas-5ca4b3bcc5e934191a23283612ca711e90f217ed.tar.gz xas-5ca4b3bcc5e934191a23283612ca711e90f217ed.tar.bz2 xas-5ca4b3bcc5e934191a23283612ca711e90f217ed.zip |
so...bloody...close
Diffstat (limited to 'src')
-rw-r--r-- | src/drone.c | 171 |
1 files changed, 91 insertions, 80 deletions
diff --git a/src/drone.c b/src/drone.c index 47508f9..a4b1496 100644 --- a/src/drone.c +++ b/src/drone.c @@ -154,6 +154,8 @@ xas_drone_chamber *xas_drone_chamber_new(xas_spatial_scene *scene, XAS_DRONE_CHAMBER_BASS_FREQUENCY); xas_synth_start(chamber->synth_bass->ctx); + xas_synth_start(chamber->synth_l->ctx); + xas_synth_start(chamber->synth_r->ctx); chamber->drone_count = drone_count; @@ -179,80 +181,48 @@ void xas_drone_chamber_insert_drone(xas_drone_chamber *chamber, chamber->drones[index] = drone; } -int xas_drone_chamber_event_seq(xas_drone_chamber *chamber, - xas_drone_chamber_event *ev, - xas_seq *seq, - int advance, - struct timeval *now) { - struct timeval tmp = *now; - - switch (ev->type) { - case XAS_DRONE_CHAMBER_EVENT_NONE: - return 0; - - case XAS_DRONE_CHAMBER_EVENT_SYNTH: - if (xas_seq_add_set_frequency(seq, - chamber->synth_l, - *now, - ev->interval.freq_l) < 0) { - goto error_seq_add; - } - - if (xas_seq_add_set_synth_type(seq, - chamber->synth_l, - *now, - ev->interval.type_l) < 0) { - goto error_seq_add; - } - - if (xas_seq_add_set_frequency(seq, - chamber->synth_r, - *now, - ev->interval.freq_r) < 0) { - goto error_seq_add; - } - - if (xas_seq_add_set_synth_type(seq, - chamber->synth_r, - *now, - ev->interval.type_r) < 0) { - goto error_seq_add; - } - - if (advance) { - timeradd(&tmp, &ev->interval.duration, now); - } - - break; - - case XAS_DRONE_CHAMBER_EVENT_DRONE_SPEECH: - struct timeval duration, - delay = { 0, 5000000 }; - - xas_drone *drone = chamber->drones[ev->speech.drone_index]; - size_t slot = ev->speech.speech_line; - - xas_bank_entry_duration(drone->bank, slot, &duration); - - if (xas_seq_add_set_bank(seq, - drone->obj, - *now, - slot) < 0) { - goto error_seq_add; - } - - if (xas_seq_add_event_on(seq, - drone->obj, - *now) < 0) { - goto error_seq_add; - } - - if (advance) { - timeradd(now, &delay, &tmp); - timeradd(&tmp, &duration, now); - } - - break; +int xas_drone_chamber_seq_intervals(xas_drone_chamber *chamber, + xas_drone_chamber_interval *intervals, + xas_seq *seq, + size_t count, + struct timeval *now) { + size_t i; + + for (i=0; i<count; i++) { + struct timeval cur = { + .tv_sec = now->tv_sec, + .tv_usec = now->tv_usec + }; + + if (xas_seq_add_set_frequency(seq, + chamber->synth_l, + *now, + intervals[i].freq_l) < 0) { + goto error_seq_add; + } + + if (xas_seq_add_set_synth_type(seq, + chamber->synth_l, + *now, + intervals[i].type_l) < 0) { + goto error_seq_add; + } + + if (xas_seq_add_set_frequency(seq, + chamber->synth_r, + *now, + intervals[i].freq_r) < 0) { + goto error_seq_add; + } + + if (xas_seq_add_set_synth_type(seq, + chamber->synth_r, + *now, + intervals[i].type_r) < 0) { + goto error_seq_add; + } + + timeradd(&cur, &intervals[i].duration, now); } return 0; @@ -261,6 +231,42 @@ error_seq_add: return -1; } +int xas_drone_chamber_seq_speech(xas_drone_chamber *chamber, + xas_drone *drone, + xas_seq *seq, + size_t speech_part, + struct timeval *now) { + struct timeval duration, + tmp; + + if (xas_seq_add_set_bank(seq, + drone->obj, + *now, + speech_part) < 0) { + goto error_xas_seq_add; + } + + if (xas_seq_add_event_on(seq, + drone->obj, + *now) < 0) { + goto error_xas_seq_add; + } + + xas_bank_entry_duration(drone->bank, + speech_part, + &duration); + + timeradd(now, &duration, &tmp); + + now->tv_sec = tmp.tv_sec; + now->tv_usec = tmp.tv_usec; + + return 0; + +error_xas_seq_add: + return -1; +} + static void max_speech_duration(xas_drone_chamber *chamber, struct timeval *max) { size_t i; @@ -282,9 +288,9 @@ static void max_speech_duration(xas_drone_chamber *chamber, } } -int xas_drone_chamber_chorus_seq(xas_drone_chamber *chamber, +int xas_drone_chamber_seq_chorus(xas_drone_chamber *chamber, xas_seq *seq, - int advance, + size_t speech_part, struct timeval *now) { struct timeval duration, tmp, @@ -297,15 +303,20 @@ int xas_drone_chamber_chorus_seq(xas_drone_chamber *chamber, for (i=0; i<chamber->drone_count; i++) { xas_drone *drone = chamber->drones[i]; + if (xas_seq_add_set_bank(seq, + drone->obj, + *now, + speech_part) < 0) { + goto error_seq_add; + } + 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); - } + timeradd(now, &duration, &tmp); + timeradd(&tmp, &delay, now); return 0; |