diff options
author | XANTRONIX Development | 2022-03-05 23:27:04 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-03-05 23:27:04 -0500 |
commit | 7b69e2696ecee24dbfba77749d5400d342a03636 (patch) | |
tree | b4ee75c625d715097dc68aa660920fc427f9e843 /src | |
parent | 346fbb71cb39d578a39c88be51fbe81614c87dc0 (diff) | |
download | xas-7b69e2696ecee24dbfba77749d5400d342a03636.tar.gz xas-7b69e2696ecee24dbfba77749d5400d342a03636.tar.bz2 xas-7b69e2696ecee24dbfba77749d5400d342a03636.zip |
yeah, i guess
Diffstat (limited to 'src')
-rw-r--r-- | src/spatial.c | 14 |
1 files changed, 9 insertions, 5 deletions
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++; |