diff options
| author | XANTRONIX Development | 2022-03-06 11:22:23 -0500 | 
|---|---|---|
| committer | XANTRONIX Development | 2022-03-06 11:22:23 -0500 | 
| commit | 2e35d61d65c8ac02b6557c53065ce61b3a21f718 (patch) | |
| tree | 5409f9aff279b03ad124f8c4548cc151a399687b /src | |
| parent | cb7f5f0dc85cd3415d6e7893dde649670559e944 (diff) | |
| download | xas-2e35d61d65c8ac02b6557c53065ce61b3a21f718.tar.gz xas-2e35d61d65c8ac02b6557c53065ce61b3a21f718.tar.bz2 xas-2e35d61d65c8ac02b6557c53065ce61b3a21f718.zip | |
Improve aliasing on approaching objects
Diffstat (limited to 'src')
| -rw-r--r-- | src/spatial.c | 60 | 
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); | 
 
    