From af0fe29878be566ac97d6455f4db45cd3e951598 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 18 Feb 2021 01:35:24 +0300
Subject: [PATCH] whitespace fixes
---
effect_position.c | 997 ++++++++++++++++++++---------------------
effect_stereoreverse.c | 13 +-
effects_internal.c | 10 +-
effects_internal.h | 7 +-
4 files changed, 504 insertions(+), 523 deletions(-)
diff --git a/effect_position.c b/effect_position.c
index 4206c86..081c7a0 100644
--- a/effect_position.c
+++ b/effect_position.c
@@ -24,8 +24,6 @@
effect callback API. They are meant for speed over quality. :)
*/
-/* $Id$ */
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -106,25 +104,23 @@ static void SDLCALL _Eff_PositionDone(int channel, void *udata)
pos_args_global = NULL;
}
}
-
else if (pos_args_array[channel] != NULL) {
SDL_free(pos_args_array[channel]);
pos_args_array[channel] = NULL;
}
}
-
static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Uint8 *ptr = (Uint8 *) stream;
int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
+ /*
+ * if there's only a mono channnel (the only way we wouldn't have
+ * a len divisible by 2 here), then left_f and right_f are always
+ * 1.0, and are therefore throwaways.
+ */
if (len % sizeof (Uint16) != 0) {
*ptr = (Uint8) (((float) *ptr) * args->distance_f);
ptr++;
@@ -134,34 +130,35 @@ static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udat
if (args->room_angle == 180)
for (i = 0; i < len; i += sizeof (Uint8) * 2) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
}
else for (i = 0; i < len; i += sizeof (Uint8) * 2) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
}
}
+
static void SDLCALL _Eff_position_u8_c4(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Uint8 *ptr = (Uint8 *) stream;
int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
+ /*
+ * if there's only a mono channnel (the only way we wouldn't have
+ * a len divisible by 2 here), then left_f and right_f are always
+ * 1.0, and are therefore throwaways.
+ */
if (len % sizeof (Uint16) != 0) {
*ptr = (Uint8) (((float) *ptr) * args->distance_f);
ptr++;
@@ -171,81 +168,80 @@ static void SDLCALL _Eff_position_u8_c4(int chan, void *stream, int len, void *u
if (args->room_angle == 0)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
}
else if (args->room_angle == 90)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
}
else if (args->room_angle == 180)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
}
else if (args->room_angle == 270)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
}
}
-
static void SDLCALL _Eff_position_u8_c6(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Uint8 *ptr = (Uint8 *) stream;
int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
+ /*
+ * if there's only a mono channnel (the only way we wouldn't have
+ * a len divisible by 2 here), then left_f and right_f are always
+ * 1.0, and are therefore throwaways.
+ */
if (len % sizeof (Uint16) != 0) {
*ptr = (Uint8) (((float) *ptr) * args->distance_f);
ptr++;
@@ -255,94 +251,94 @@ static void SDLCALL _Eff_position_u8_c6(int chan, void *stream, int len, void *u
if (args->room_angle == 0)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->center_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->lfe_f) * args->distance_f) + 128);
ptr++;
}
else if (args->room_angle == 90)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f/2) + 128)
- + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f/2) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->lfe_f) * args->distance_f) + 128);
ptr++;
}
else if (args->room_angle == 180)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f/2) + 128)
- + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f/2) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->lfe_f) * args->distance_f) + 128);
ptr++;
}
else if (args->room_angle == 270)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f/2) + 128)
- + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f/2) + 128);
ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
+ *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->lfe_f) * args->distance_f) + 128);
ptr++;
}
@@ -368,15 +364,15 @@ static void SDLCALL _Eff_position_table_u8(int chan, void *stream, int len, void
Uint8 *d = ((Uint8 *) _Eff_volume_table) + (256 * args->distance_u8);
if (args->room_angle == 180) {
- Uint8 *temp = l;
- l = r;
- r = temp;
- }
- /*
- * if there's only a mono channnel, then l[] and r[] are always
- * volume 255, and are therefore throwaways. Still, we have to
- * be sure not to overrun the audio buffer...
- */
+ Uint8 *temp = l;
+ l = r;
+ r = temp;
+ }
+ /*
+ * if there's only a mono channnel, then l[] and r[] are always
+ * volume 255, and are therefore throwaways. Still, we have to
+ * be sure not to overrun the audio buffer...
+ */
while (len % sizeof (Uint32) != 0) {
*ptr = d[l[*ptr]];
ptr++;
@@ -412,11 +408,11 @@ static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udat
Sint8 *ptr = (Sint8 *) stream;
int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
+ /*
+ * if there's only a mono channnel (the only way we wouldn't have
+ * a len divisible by 2 here), then left_f and right_f are always
+ * 1.0, and are therefore throwaways.
+ */
if (len % sizeof (Sint16) != 0) {
*ptr = (Sint8) (((float) *ptr) * args->distance_f);
ptr++;
@@ -444,11 +440,11 @@ static void SDLCALL _Eff_position_s8_c4(int chan, void *stream, int len, void *u
Sint8 *ptr = (Sint8 *) stream;
int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
+ /*
+ * if there's only a mono channnel (the only way we wouldn't have
+ * a len divisible by 2 here), then left_f and right_f are always
+ * 1.0, and are therefore throwaways.
+ */
if (len % sizeof (Sint16) != 0) {
*ptr = (Sint8) (((float) *ptr) * args->distance_f);
ptr++;
@@ -462,39 +458,40 @@ static void SDLCALL _Eff_position_s8_c4(int chan, void *stream, int len, void *u
*ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- break;
+ break;
case 90:
*ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- break;
+ break;
case 180:
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- break;
+ break;
case 270:
*ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- break;
+ break;
}
}
}
+
static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Sint8 *ptr = (Sint8 *) stream;
int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
+ /*
+ * if there's only a mono channnel (the only way we wouldn't have
+ * a len divisible by 2 here), then left_f and right_f are always
+ * 1.0, and are therefore throwaways.
+ */
if (len % sizeof (Sint16) != 0) {
*ptr = (Sint8) (((float) *ptr) * args->distance_f);
ptr++;
@@ -510,7 +507,7 @@ static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *u
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->center_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
- break;
+ break;
case 90:
*ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
@@ -519,7 +516,7 @@ static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *u
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
+ (Sint8)((((float) *ptr) * args->right_f) * args->distance_f / 2); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
- break;
+ break;
case 180:
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
@@ -528,7 +525,7 @@ static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *u
*ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
+ (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
- break;
+ break;
case 270:
*ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
@@ -537,12 +534,11 @@ static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *u
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f / 2)
+ (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
- break;
+ break;
}
}
}
-
/*
* This one runs about 10.1 times faster than the non-table version, with
* no loss in quality. It does, however, require 64k of memory for the
@@ -562,12 +558,11 @@ static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void
Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8);
if (args->room_angle == 180) {
- Sint8 *temp = l;
- l = r;
- r = temp;
+ Sint8 *temp = l;
+ l = r;
+ r = temp;
}
-
while (len % sizeof (Uint32) != 0) {
*ptr = d[l[*ptr]];
ptr++;
@@ -594,8 +589,6 @@ static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void
#endif
++p;
}
-
-
}
@@ -610,22 +603,23 @@ static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *
for (i = 0; i < len; i += sizeof (Uint16) * 2) {
Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
-
+
Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
* args->distance_f) + 32768);
Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
* args->distance_f) + 32768);
- if (args->room_angle == 180) {
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- }
- else {
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- }
+ if (args->room_angle == 180) {
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ }
+ else {
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ }
}
}
+
static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
@@ -637,7 +631,7 @@ static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, voi
Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
-
+
Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
* args->distance_f) + 32768);
Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
@@ -647,34 +641,35 @@ static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, voi
Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
* args->distance_f) + 32768);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- break;
- case 90:
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- break;
- case 180:
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- break;
- case 270:
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- break;
- }
+ switch (args->room_angle) {
+ case 0:
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
+ break;
+ case 90:
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
+ break;
+ case 180:
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ break;
+ case 270:
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ break;
+ }
}
}
+
static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
@@ -702,40 +697,40 @@ static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, voi
Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
* args->distance_f) + 32768);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapce);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
- break;
- case 90:
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2;
- *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
- break;
- case 180:
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
- *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
- break;
- case 270:
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
- *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
- break;
- }
+ switch (args->room_angle) {
+ case 0:
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapce);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
+ break;
+ case 90:
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2;
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
+ break;
+ case 180:
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
+ break;
+ case 270:
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
+ *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
+ break;
+ }
}
}
@@ -748,8 +743,8 @@ static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *
#if 0
if (len % (sizeof(Sint16) * 2)) {
- fprintf(stderr,"Not an even number of frames! len=%d\n", len);
- return;
+ fprintf(stderr,"Not an even number of frames! len=%d\n", len);
+ return;
}
#endif
@@ -758,14 +753,14 @@ static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *
args->left_f) * args->distance_f);
Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
args->right_f) * args->distance_f);
- if (args->room_angle == 180) {
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- }
- else {
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- }
+ if (args->room_angle == 180) {
+ *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
+ *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
+ }
+ else {
+ *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
+ *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
+ }
}
}
static void SDLCALL _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata)
@@ -784,32 +779,32 @@ static void SDLCALL _Eff_position_s16lsb_c4(int chan, void *stream, int len, voi
args->left_rear_f) * args->distance_f);
Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
args->right_rear_f) * args->distance_f);
- switch (args->room_angle) {
- case 0:
- *(
(Patch may be truncated, please check the link at the top of this post.)