diff options
| author | XANTRONIX Development | 2022-02-17 11:23:26 -0500 | 
|---|---|---|
| committer | XANTRONIX Development | 2022-02-17 11:23:26 -0500 | 
| commit | 7197ed68a4faa0f7fd580cfe116e75b2419b6730 (patch) | |
| tree | c4049e40b7f71412e4d9e09138ccfd1c02a1ec78 | |
| parent | 9fb7aeb8d5806575b6f6a6042b5315de28a0d4ff (diff) | |
| download | xas-7197ed68a4faa0f7fd580cfe116e75b2419b6730.tar.gz xas-7197ed68a4faa0f7fd580cfe116e75b2419b6730.tar.bz2 xas-7197ed68a4faa0f7fd580cfe116e75b2419b6730.zip | |
baby steps
| -rw-r--r-- | src/spatial.c | 38 | 
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) { | 
 
    