From 7b69e2696ecee24dbfba77749d5400d342a03636 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 5 Mar 2022 23:27:04 -0500 Subject: yeah, i guess --- src/spatial.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') 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++; -- cgit v1.2.3