#ifndef _XAS_SPATIAL_H #define _XAS_SPATIAL_H #include #define XAS_SPATIAL_DEFAULT_OBSERVER_WIDTH 0.18f #define XAS_SPATIAL_DEFAULT_RADIUS 4000.0f /* metres */ #define XAS_SPATIAL_DEFAULT_SPEED 343.0f /* m/s */ #define XAS_SPATIAL_DEFAULT_CONE_ANGLE 35.0f /* degrees */ typedef struct _xas_spatial_coord { float x, y, z; } xas_spatial_coord; typedef struct _xas_spatial_cone { xas_spatial_coord apex, rotation; float angle; } xas_spatial_cone; typedef struct _xas_spatial_observer { xas_spatial_coord point, rotation; float width; } xas_spatial_observer; typedef struct _xas_spatial_object xas_spatial_object; struct _xas_spatial_object { float distance_l, distance_r; size_t delta_l, delta_r; ssize_t shift_l, shift_r; xas_audio_stream *source; void *ctx; xas_spatial_coord point; xas_spatial_object *next; }; typedef struct _xas_spatial_buffer { size_t index, size; } xas_spatial_buffer; typedef struct _xas_spatial_scene { xas_audio_format format; xas_spatial_observer observer; xas_spatial_coord speaker_l, speaker_r; float speed, radius; xas_spatial_object *first, *last; xas_spatial_buffer *buffer; } xas_spatial_scene; xas_spatial_scene *xas_spatial_scene_new(xas_audio_format format, xas_spatial_coord speaker_l, xas_spatial_coord speaker_r); void xas_spatial_scene_destroy(xas_spatial_scene *scene); void xas_spatial_scene_set_observer(xas_spatial_scene *scene, xas_spatial_coord point, xas_spatial_coord rotation, float width); void xas_spatial_scene_set_speaker_coords(xas_spatial_scene *scene, xas_spatial_coord speaker_l, xas_spatial_coord speaker_r); int xas_spatial_scene_set_speed(xas_spatial_scene *scene, float speed); int xas_spatial_scene_set_radius(xas_spatial_scene *scene, float radius); xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, xas_spatial_coord point, xas_audio_stream *source, void *ctx); void xas_spatial_scene_position_object(xas_spatial_scene *scene, xas_spatial_object *object, xas_spatial_coord point); int xas_spatial_object_start(xas_spatial_object *object); int xas_spatial_object_stop(xas_spatial_object *object); void xas_spatial_object_get_point(xas_spatial_object *object, xas_spatial_coord *point); xas_audio_stream *xas_spatial_scene_stream_new(xas_spatial_scene *scene, size_t buffer_size); #endif /* _XAS_SPATIAL_H */