From 7197ed68a4faa0f7fd580cfe116e75b2419b6730 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Thu, 17 Feb 2022 11:23:26 -0500 Subject: baby steps --- src/spatial.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/spatial.c b/src/spatial.c index bba5ace..f031ceb 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -129,11 +129,17 @@ ssize_t scene_fill(xas_spatial_scene *scene, buffer->index = 0; } - index_l = buffer->index + obj->shift_l; - index_r = buffer->index + obj->shift_r; + index_l = index_r = buffer->index; - if (obj->shift_l) obj->shift_l--; - if (obj->shift_r) obj->shift_r--; + if (obj->shift_l) { + index_l += obj->delta_l; + obj->shift_l--; + } + + if (obj->shift_r) { + index_r += obj->delta_r; + obj->shift_r--; + } dest[XAS_AUDIO_STEREO*index_l] += value_l; dest[XAS_AUDIO_STEREO*index_r+1] += value_r; @@ -213,7 +219,16 @@ void xas_spatial_scene_set_observer(xas_spatial_scene *scene, static void object_position(xas_spatial_scene *scene, xas_spatial_object *object, - xas_spatial_coord coord); + xas_spatial_coord coord) { + object->coord = coord; + + object->distance_l = dist(scene->speaker_l, coord); + object->distance_r = dist(scene->speaker_r, coord); + object->delta_l = sample_delta(scene, object->distance_l); + object->delta_r = sample_delta(scene, object->distance_r); + object->shift_l = object->delta_l; + object->shift_r = object->delta_r; +} void xas_spatial_scene_set_speaker_coords(xas_spatial_scene *scene, xas_spatial_coord speaker_l, @@ -244,19 +259,6 @@ int xas_spatial_scene_set_radius(xas_spatial_scene *scene, float radius) { return buffer_realloc(scene, scene->buffer); } -static void object_position(xas_spatial_scene *scene, - xas_spatial_object *object, - xas_spatial_coord coord) { - object->coord = coord; - - object->distance_l = dist(scene->speaker_l, coord); - object->distance_r = dist(scene->speaker_r, coord); - object->delta_l = sample_delta(scene, object->distance_l); - object->delta_r = sample_delta(scene, object->distance_r); - object->shift_l = object->delta_l; - object->shift_r = object->delta_r; -} - xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, xas_spatial_coord coord, xas_audio_stream *source) { -- cgit v1.2.3