From 8fa45711501f308a98b2a5ac34cc51f041ab9ad5 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 21 Feb 2022 16:00:14 -0500 Subject: am i a good cat ??? --- src/spatial.c | 67 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/spatial.c b/src/spatial.c index a0cd29b..74a0cad 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -81,9 +81,9 @@ static inline float degf(float rad) { static int within_cone(xas_spatial_coord coord, xas_spatial_cone cone) { xas_spatial_rotation rotation = { - .pitch = -cone.rotation.x / 2.0f, - .roll = -cone.rotation.y / 2.0f, - .yaw = -cone.rotation.z / 2.0f + .x = (M_PI * 2.0f) - cone.rotation.x, + .y = (M_PI * 2.0f) - cone.rotation.y, + .z = (M_PI * 2.0f) - cone.rotation.z }; float radius; @@ -92,19 +92,12 @@ static int within_cone(xas_spatial_coord coord, coord.y -= cone.coord.y; coord.z -= cone.coord.z; + cone.coord.x = 0.0f; + cone.coord.y = 0.0f; + cone.coord.z = 0.0f; + rotate(rotation, &coord); - cone.coord.x = 0; - cone.coord.y = 0; - cone.coord.z = 0; - - /* - * If the point is to the left of the cone point, then the point is not - * within the cone. - */ - if (coord.x < 0) { - return 0; - } radius = tanf(cone.angle / 2.0f) * coord.x; @@ -112,7 +105,7 @@ static int within_cone(xas_spatial_coord coord, * If the given point is outside the cone radius at its X coordinate, then * it is outside of the cone. */ - if (fabs(coord.y) < radius || fabs(coord.z) < radius) { + if (fabs(coord.y) > radius || fabs(coord.z) > radius) { return 0; } @@ -207,6 +200,26 @@ ssize_t scene_fill(xas_spatial_scene *scene, int16_t *dest = (int16_t *)(scene->buffer + 1); + xas_spatial_cone cone_l = { + .coord = scene->speaker_l, + .rotation = { + .x = 0.0f, + .y = 0.5f * M_PI, + .z = 0.0f + }, + + .angle = M_PI / 4.0f + }, cone_r = { + .coord = scene->speaker_r, + .rotation = { + .x = 0.0f, + .y = 1.5f * M_PI, + .z = 0.0f + }, + + .angle = M_PI / 4.0f + }; + buffer_zero(buffer, count); while (obj) { @@ -232,32 +245,12 @@ ssize_t scene_fill(xas_spatial_scene *scene, size_t index_l, index_r; - xas_spatial_cone cone_l = { - .coord = scene->speaker_l, - .rotation = { - .x = 1.75f * M_PI, - .y = 0.0f, - .z = 0.0f - }, - - .angle = M_PI / 4.0f - }, cone_r = { - .coord = scene->speaker_r, - .rotation = { - .x = 0.25f * M_PI, - .y = 0.0f, - .z = 0.0f - }, - - .angle = M_PI / 4.0f - }; - if (!within_cone(obj->coord, cone_l)) { - value_l /= 2.0f; + value_l /= 3.0f; } if (!within_cone(obj->coord, cone_r)) { - value_r /= 2.0f; + value_r /= 3.0f; } if (buffer->index == buffer->size) { -- cgit v1.2.3