summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/spatial.c60
1 files changed, 47 insertions, 13 deletions
diff --git a/src/spatial.c b/src/spatial.c
index 87307f0..5d74fad 100644
--- a/src/spatial.c
+++ b/src/spatial.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
@@ -282,8 +283,45 @@ ssize_t scene_fill(xas_spatial_scene *scene,
index_l = index_r = buffer->index;
- dest[XAS_AUDIO_STEREO*index_l] += value_l;
- dest[XAS_AUDIO_STEREO*index_r+1] += value_r;
+ if (obj->shift_l == 0) {
+ dest[XAS_AUDIO_STEREO*index_l] += value_l;
+ } else {
+ while (obj->shift_l > 0) {
+ size_t index = index_l + obj->shift_l;
+
+ if (index < buffer->size) {
+ dest[XAS_AUDIO_STEREO*index] += value_l;
+ }
+
+ obj->shift_l--;
+ }
+
+ while (obj->shift_l < 0) {
+ dest[XAS_AUDIO_STEREO*index_l] += value_l;
+
+ obj->shift_l++;
+ }
+ }
+
+ if (obj->shift_r == 0) {
+ dest[XAS_AUDIO_STEREO*index_r] += value_r;
+ } else {
+ while (obj->shift_r > 0) {
+ size_t index = index_r + obj->shift_r;
+
+ if (index < buffer->size) {
+ dest[XAS_AUDIO_STEREO*index+1] += value_r;
+ }
+
+ obj->shift_r--;
+ }
+
+ while (obj->shift_r < 0) {
+ dest[XAS_AUDIO_STEREO*index_r] += value_r;
+
+ obj->shift_r++;
+ }
+ }
buffer->index++;
}
@@ -399,17 +437,13 @@ xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene,
goto error_malloc_object;
}
- object->point = point;
- object->source = source;
- object->ctx = ctx;
- object->flags = XAS_SPATIAL_OBJECT_NONE;
- object->heading.x = 0;
- object->heading.y = 0;
- object->heading.z = 0;
- object->speed = XAS_SPATIAL_DEFAULT_OBJECT_SPEED;
- object->next = NULL;
- object->delay_l = 0;
- object->delay_r = 0;
+ memset(object, '\0', sizeof(*object));
+
+ object->point = point;
+ object->source = source;
+ object->ctx = ctx;
+ object->flags = XAS_SPATIAL_OBJECT_NONE;
+ object->speed = XAS_SPATIAL_DEFAULT_OBJECT_SPEED;
object_position(scene, object, point);