summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/spatial.c38
1 files changed, 20 insertions, 18 deletions
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) {