summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/seq.c3
-rw-r--r--src/spatial.c14
2 files changed, 12 insertions, 5 deletions
diff --git a/examples/seq.c b/examples/seq.c
index 0788673..3dc94e4 100644
--- a/examples/seq.c
+++ b/examples/seq.c
@@ -96,6 +96,9 @@ int main(int argc, char **argv) {
goto error_spatial_scene_stream_new;
}
+ synth_l->heading = (xas_spatial_coord){ 0, M_PI * 1.5f, 0 };
+ synth_l->speed = 1.0f;
+
xas_vox_set_voice(voice->ctx, "voice_cmu_us_slt_cg");
xas_vox_set_parameter_float(voice->ctx, "Duration_Stretch", 1.3);
diff --git a/src/spatial.c b/src/spatial.c
index ce3b64e..ba0cd6e 100644
--- a/src/spatial.c
+++ b/src/spatial.c
@@ -130,7 +130,7 @@ error_realloc_buffer:
}
static inline size_t sample_delta(xas_spatial_scene *scene, float distance) {
- return floorf((distance / scene->speed) * scene->format.sample_rate);
+ return floorf((distance / scene->speed) * (float)scene->format.sample_rate);
}
static inline int16_t sample_scale(int16_t value, float distance) {
@@ -286,22 +286,26 @@ ssize_t scene_fill(xas_spatial_scene *scene,
obj->shift_l++;
} else {
if (obj->shift_l > 0) {
- index_l += obj->delta_l;
+ index_l++;
obj->shift_l--;
}
- dest[XAS_AUDIO_STEREO*index_l] += value_l;
+ if (index_l < buffer->size) {
+ dest[XAS_AUDIO_STEREO*index_l] += value_l;
+ }
}
if (obj->shift_r < 0) {
obj->shift_r++;
} else {
if (obj->shift_r > 0) {
- index_r += obj->delta_r;
+ index_r++;
obj->shift_r--;
}
- dest[XAS_AUDIO_STEREO*index_r+1] += value_r;
+ if (index_r < buffer->size) {
+ dest[XAS_AUDIO_STEREO*index_r+1] += value_r;
+ }
}
buffer->index++;