Skip to content

Latest commit

 

History

History
1619 lines (1471 loc) · 61.7 KB

effect_position.c

File metadata and controls

1619 lines (1471 loc) · 61.7 KB
 
Dec 31, 2011
Dec 31, 2011
2
SDL_mixer: An audio mixer library based on the SDL library
Feb 15, 2013
Feb 15, 2013
3
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
Dec 31, 2011
Dec 31, 2011
5
6
7
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Dec 31, 2011
Dec 31, 2011
9
10
11
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
Dec 31, 2011
Dec 31, 2011
13
14
15
16
17
18
19
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Dec 31, 2011
Dec 31, 2011
21
This file by Ryan C. Gordon (icculus@icculus.org)
Dec 31, 2011
Dec 31, 2011
23
24
These are some internally supported special effects that use SDL_mixer's
effect callback API. They are meant for speed over quality. :)
25
26
27
28
29
30
*/
/* $Id$ */
#include <stdio.h>
#include <stdlib.h>
Sep 11, 2001
Sep 11, 2001
31
32
#include <string.h>
33
34
#include "SDL.h"
#include "SDL_mixer.h"
Feb 7, 2002
Feb 7, 2002
35
#include "SDL_endian.h"
36
37
38
39
40
41
42
43
44
#define __MIX_INTERNAL_EFFECT__
#include "effects_internal.h"
/* profile code:
#include <sys/time.h>
#include <unistd.h>
struct timeval tv1;
struct timeval tv2;
May 22, 2013
May 22, 2013
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
gettimeofday(&tv1, NULL);
... do your thing here ...
gettimeofday(&tv2, NULL);
printf("%ld\n", tv2.tv_usec - tv1.tv_usec);
*/
/*
* Positional effects...panning, distance attenuation, etc.
*/
typedef struct _Eff_positionargs
{
volatile float left_f;
volatile float right_f;
volatile Uint8 left_u8;
volatile Uint8 right_u8;
Aug 21, 2004
Aug 21, 2004
65
66
67
68
69
70
71
72
volatile float left_rear_f;
volatile float right_rear_f;
volatile float center_f;
volatile float lfe_f;
volatile Uint8 left_rear_u8;
volatile Uint8 right_rear_u8;
volatile Uint8 center_u8;
volatile Uint8 lfe_u8;
73
74
volatile float distance_f;
volatile Uint8 distance_u8;
Aug 21, 2004
Aug 21, 2004
75
volatile Sint16 room_angle;
76
77
78
79
80
81
82
83
volatile int in_use;
volatile int channels;
} position_args;
static position_args **pos_args_array = NULL;
static position_args *pos_args_global = NULL;
static int position_channels = 0;
Jul 15, 2007
Jul 15, 2007
84
85
86
87
void _Eff_PositionDeinit(void)
{
int i;
for (i = 0; i < position_channels; i++) {
Jan 13, 2012
Jan 13, 2012
88
SDL_free(pos_args_array[i]);
Jul 15, 2007
Jul 15, 2007
89
90
}
Feb 4, 2008
Feb 4, 2008
91
92
position_channels = 0;
Jan 13, 2012
Jan 13, 2012
93
SDL_free(pos_args_global);
Jul 15, 2007
Jul 15, 2007
94
pos_args_global = NULL;
Jan 13, 2012
Jan 13, 2012
95
SDL_free(pos_args_array);
Jul 15, 2007
Jul 15, 2007
96
97
98
99
pos_args_array = NULL;
}
100
101
102
103
104
/* This just frees up the callback-specific data. */
static void _Eff_PositionDone(int channel, void *udata)
{
if (channel < 0) {
if (pos_args_global != NULL) {
Jan 13, 2012
Jan 13, 2012
105
SDL_free(pos_args_global);
106
107
108
109
110
pos_args_global = NULL;
}
}
else if (pos_args_array[channel] != NULL) {
Jan 13, 2012
Jan 13, 2012
111
SDL_free(pos_args_array[channel]);
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
pos_args_array[channel] = NULL;
}
}
static void _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 (len % sizeof (Uint16) != 0) {
Feb 21, 2003
Feb 21, 2003
129
130
*ptr = (Uint8) (((float) *ptr) * args->distance_f);
ptr++;
131
132
133
len--;
}
Oct 10, 2009
Oct 10, 2009
134
if (args->room_angle == 180)
135
for (i = 0; i < len; i += sizeof (Uint8) * 2) {
Aug 21, 2004
Aug 21, 2004
136
/* must adjust the sample so that 0 is the center */
May 22, 2013
May 22, 2013
137
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
138
139
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
140
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
141
142
143
144
* args->left_f) * args->distance_f) + 128);
ptr++;
}
else for (i = 0; i < len; i += sizeof (Uint8) * 2) {
Dec 27, 2002
Dec 27, 2002
145
/* must adjust the sample so that 0 is the center */
May 22, 2013
May 22, 2013
146
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Dec 27, 2002
Dec 27, 2002
147
* args->left_f) * args->distance_f) + 128);
Feb 21, 2003
Feb 21, 2003
148
ptr++;
May 22, 2013
May 22, 2013
149
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Dec 27, 2002
Dec 27, 2002
150
* args->right_f) * args->distance_f) + 128);
Feb 21, 2003
Feb 21, 2003
151
ptr++;
152
153
}
}
Aug 21, 2004
Aug 21, 2004
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
static void _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 (len % sizeof (Uint16) != 0) {
*ptr = (Uint8) (((float) *ptr) * args->distance_f);
ptr++;
len--;
}
if (args->room_angle == 0)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
May 22, 2013
May 22, 2013
174
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
175
176
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
177
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
178
179
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
180
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
181
182
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
183
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
184
185
186
187
188
189
* 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 */
May 22, 2013
May 22, 2013
190
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
191
192
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
193
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
194
195
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
196
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
197
198
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
199
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
200
201
202
203
204
205
* 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 */
May 22, 2013
May 22, 2013
206
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
207
208
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
209
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
210
211
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
212
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
213
214
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
215
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
216
217
218
219
220
221
* 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 */
May 22, 2013
May 22, 2013
222
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
223
224
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
225
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
226
227
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
228
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
229
230
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
231
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
* args->right_f) * args->distance_f) + 128);
ptr++;
}
}
static void _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 (len % sizeof (Uint16) != 0) {
*ptr = (Uint8) (((float) *ptr) * args->distance_f);
ptr++;
len--;
}
if (args->room_angle == 0)
for (i = 0; i < len; i += sizeof (Uint8) * 6) {
/* must adjust the sample so that 0 is the center */
May 22, 2013
May 22, 2013
258
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
259
260
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
261
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
262
263
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
264
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
265
266
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
267
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
268
269
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
270
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
271
272
* args->center_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
273
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
274
275
276
277
278
279
* 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 */
May 22, 2013
May 22, 2013
280
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
281
282
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
283
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
284
285
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
286
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
287
288
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
289
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
290
291
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
292
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
293
* args->right_rear_f) * args->distance_f/2) + 128)
May 22, 2013
May 22, 2013
294
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
295
296
* args->right_f) * args->distance_f/2) + 128);
ptr++;
May 22, 2013
May 22, 2013
297
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
298
299
300
301
302
303
* 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 */
May 22, 2013
May 22, 2013
304
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
305
306
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
307
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
308
309
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
310
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
311
312
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
313
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
314
315
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
316
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
317
* args->right_rear_f) * args->distance_f/2) + 128)
May 22, 2013
May 22, 2013
318
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
319
320
* args->left_rear_f) * args->distance_f/2) + 128);
ptr++;
May 22, 2013
May 22, 2013
321
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
322
323
324
325
326
327
* 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 */
May 22, 2013
May 22, 2013
328
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
329
330
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
331
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
332
333
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
334
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
335
336
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
337
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
338
339
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
340
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
341
* args->left_f) * args->distance_f/2) + 128)
May 22, 2013
May 22, 2013
342
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
343
344
* args->left_rear_f) * args->distance_f/2) + 128);
ptr++;
May 22, 2013
May 22, 2013
345
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
346
347
348
349
* args->lfe_f) * args->distance_f) + 128);
ptr++;
}
}
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/*
* 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
* lookup table. Also, this will only update position information once per
* call; the non-table version always checks the arguments for each sample,
* in case the user has called Mix_SetPanning() or whatnot again while this
* callback is running.
*/
static void _Eff_position_table_u8(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Uint8 *ptr = (Uint8 *) stream;
Uint32 *p;
int i;
Uint8 *l = ((Uint8 *) _Eff_volume_table) + (256 * args->left_u8);
Uint8 *r = ((Uint8 *) _Eff_volume_table) + (256 * args->right_u8);
Uint8 *d = ((Uint8 *) _Eff_volume_table) + (256 * args->distance_u8);
Aug 21, 2004
Aug 21, 2004
370
if (args->room_angle == 180) {
May 22, 2013
May 22, 2013
371
372
373
Uint8 *temp = l;
l = r;
r = temp;
Aug 21, 2004
Aug 21, 2004
374
}
375
376
377
378
379
380
/*
* 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) {
Feb 21, 2003
Feb 21, 2003
381
382
383
384
385
386
*ptr = d[l[*ptr]];
ptr++;
if (args->channels > 1) {
*ptr = d[r[*ptr]];
ptr++;
}
387
388
389
390
391
392
len -= args->channels;
}
p = (Uint32 *) ptr;
for (i = 0; i < len; i += sizeof (Uint32)) {
Feb 7, 2002
Feb 7, 2002
393
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
Jul 21, 2007
Jul 21, 2007
394
395
396
397
*p = (d[l[(*p & 0xFF000000) >> 24]] << 24) |
(d[r[(*p & 0x00FF0000) >> 16]] << 16) |
(d[l[(*p & 0x0000FF00) >> 8]] << 8) |
(d[r[(*p & 0x000000FF) ]] ) ;
398
#else
Jul 21, 2007
Jul 21, 2007
399
400
401
402
*p = (d[r[(*p & 0xFF000000) >> 24]] << 24) |
(d[l[(*p & 0x00FF0000) >> 16]] << 16) |
(d[r[(*p & 0x0000FF00) >> 8]] << 8) |
(d[l[(*p & 0x000000FF) ]] ) ;
403
#endif
Jul 21, 2007
Jul 21, 2007
404
++p;
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
}
}
static void _Eff_position_s8(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 (len % sizeof (Sint16) != 0) {
Feb 21, 2003
Feb 21, 2003
421
422
*ptr = (Sint8) (((float) *ptr) * args->distance_f);
ptr++;
423
424
425
len--;
}
Aug 21, 2004
Aug 21, 2004
426
427
428
429
430
431
432
433
if (args->room_angle == 180)
for (i = 0; i < len; i += sizeof (Sint8) * 2) {
*ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
ptr++;
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
ptr++;
}
else
434
for (i = 0; i < len; i += sizeof (Sint8) * 2) {
Feb 21, 2003
Feb 21, 2003
435
436
437
438
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
ptr++;
*ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
ptr++;
439
440
}
}
Aug 21, 2004
Aug 21, 2004
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
static void _Eff_position_s8_c4(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 (len % sizeof (Sint16) != 0) {
*ptr = (Sint8) (((float) *ptr) * args->distance_f);
ptr++;
len--;
}
for (i = 0; i < len; i += sizeof (Sint8) * 4) {
switch (args->room_angle) {
case 0:
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
*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++;
May 22, 2013
May 22, 2013
465
break;
Aug 21, 2004
Aug 21, 2004
466
467
468
469
470
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++;
May 22, 2013
May 22, 2013
471
break;
Aug 21, 2004
Aug 21, 2004
472
473
474
475
476
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++;
May 22, 2013
May 22, 2013
477
break;
Aug 21, 2004
Aug 21, 2004
478
479
480
481
482
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++;
May 22, 2013
May 22, 2013
483
break;
Aug 21, 2004
Aug 21, 2004
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
}
}
}
static void _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 (len % sizeof (Sint16) != 0) {
*ptr = (Sint8) (((float) *ptr) * args->distance_f);
ptr++;
len--;
}
for (i = 0; i < len; i += sizeof (Sint8) * 6) {
switch (args->room_angle) {
case 0:
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
*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++;
*ptr = (Sint8)((((float) *ptr) * args->center_f) * args->distance_f); ptr++;
*ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
May 22, 2013
May 22, 2013
513
break;
Aug 21, 2004
Aug 21, 2004
514
515
516
517
518
519
520
521
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++;
*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++;
May 22, 2013
May 22, 2013
522
break;
Aug 21, 2004
Aug 21, 2004
523
524
525
526
527
528
529
530
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++;
*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++;
May 22, 2013
May 22, 2013
531
break;
Aug 21, 2004
Aug 21, 2004
532
533
534
535
536
537
538
539
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++;
*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++;
May 22, 2013
May 22, 2013
540
break;
Aug 21, 2004
Aug 21, 2004
541
542
543
}
}
}
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
/*
* 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
* lookup table. Also, this will only update position information once per
* call; the non-table version always checks the arguments for each sample,
* in case the user has called Mix_SetPanning() or whatnot again while this
* callback is running.
*/
static void _Eff_position_table_s8(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Sint8 *ptr = (Sint8 *) stream;
Uint32 *p;
int i;
Nov 30, 2001
Nov 30, 2001
560
561
Sint8 *l = ((Sint8 *) _Eff_volume_table) + (256 * args->left_u8);
Sint8 *r = ((Sint8 *) _Eff_volume_table) + (256 * args->right_u8);
562
563
Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8);
Aug 21, 2004
Aug 21, 2004
564
if (args->room_angle == 180) {
May 22, 2013
May 22, 2013
565
566
567
Sint8 *temp = l;
l = r;
r = temp;
Aug 21, 2004
Aug 21, 2004
568
569
}
570
571
while (len % sizeof (Uint32) != 0) {
Feb 21, 2003
Feb 21, 2003
572
573
574
575
576
577
*ptr = d[l[*ptr]];
ptr++;
if (args->channels > 1) {
*ptr = d[r[*ptr]];
ptr++;
}
578
579
580
581
582
583
len -= args->channels;
}
p = (Uint32 *) ptr;
for (i = 0; i < len; i += sizeof (Uint32)) {
Feb 7, 2002
Feb 7, 2002
584
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
Jul 21, 2007
Jul 21, 2007
585
586
587
588
*p = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
(d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
(d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) |
(d[r[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ;
589
#else
Jul 21, 2007
Jul 21, 2007
590
591
592
593
*p = (d[r[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
(d[l[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
(d[r[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) |
(d[l[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ;
594
#endif
Jul 21, 2007
Jul 21, 2007
595
++p;
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
}
}
/* !!! FIXME : Optimize the code for 16-bit samples? */
static void _Eff_position_u16lsb(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Uint16 *ptr = (Uint16 *) stream;
int i;
for (i = 0; i < len; i += sizeof (Uint16) * 2) {
Feb 21, 2003
Feb 21, 2003
611
612
Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
May 22, 2013
May 22, 2013
613
Dec 27, 2002
Dec 27, 2002
614
615
616
617
618
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);
May 22, 2013
May 22, 2013
619
620
621
622
623
624
625
626
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);
}
Aug 21, 2004
Aug 21, 2004
627
628
629
630
631
632
633
634
635
636
637
638
639
}
}
static void _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Uint16 *ptr = (Uint16 *) stream;
int i;
for (i = 0; i < len; i += sizeof (Uint16) * 4) {
Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
May 22, 2013
May 22, 2013
640
Aug 21, 2004
Aug 21, 2004
641
642
643
644
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);
Jun 23, 2006
Jun 23, 2006
645
Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
Aug 21, 2004
Aug 21, 2004
646
* args->distance_f) + 32768);
Jun 23, 2006
Jun 23, 2006
647
Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
Aug 21, 2004
Aug 21, 2004
648
649
* args->distance_f) + 32768);
May 22, 2013
May 22, 2013
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
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;
}
Aug 21, 2004
Aug 21, 2004
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
}
}
static void _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata)
{
volatile position_args *args = (volatile position_args *) udata;
Uint16 *ptr = (Uint16 *) stream;
int i;
for (i = 0; i < len; i += sizeof (Uint16) * 6) {
Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768);
Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768);
Jun 23, 2006
Jun 23, 2006
691
Aug 21, 2004
Aug 21, 2004
692
693
694
695
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);
Jun 23, 2006
Jun 23, 2006
696
Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
Aug 21, 2004
Aug 21, 2004
697
* args->distance_f) + 32768);
Jun 23, 2006
Jun 23, 2006
698
Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
Aug 21, 2004
Aug 21, 2004
699
* args->distance_f) + 32768);
Jun 23, 2006
Jun 23, 2006
700
Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
Aug 21, 2004
Aug 21, 2004
701
* args->distance_f) + 32768);
Jun 23, 2006
Jun 23, 2006
702
Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
Aug 21, 2004
Aug 21, 2004
703
704
* args->distance_f) + 32768);
May 22, 2013
May 22, 2013
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
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;
}
739
740
741
742
743
744
745
746
747
748
}
}
static void _Eff_position_s16lsb(int chan, void *stream, int len, void *udata)
{
/* 16 signed bits (lsb) * 2 channels. */
volatile position_args *args = (volatile position_args *) udata;
Sint16 *ptr = (Sint16 *) stream;
int i;
Aug 21, 2004
Aug 21, 2004
749
750
#if 0
if (len % (sizeof(Sint16) * 2)) {
May 22, 2013
May 22, 2013
751
752
fprintf(stderr,"Not an even number of frames! len=%d\n", len);
return;
Aug 21, 2004
Aug 21, 2004
753
754
755
}
#endif
756
for (i = 0; i < len; i += sizeof (Sint16) * 2) {
Nov 10, 2003
Nov 10, 2003
757
Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
758
args->left_f) * args->distance_f);
Nov 10, 2003
Nov 10, 2003
759
Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
760
args->right_f) * args->distance_f);
May 22, 2013
May 22, 2013
761
762
763
764
765
766
767
768
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);
}
Aug 21, 2004
Aug 21, 2004
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
}
}
static void _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata)
{
/* 16 signed bits (lsb) * 4 channels. */
volatile position_args *args = (volatile position_args *) udata;
Sint16 *ptr = (Sint16 *) stream;
int i;
for (i = 0; i < len; i += sizeof (Sint16) * 4) {
Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
args->left_f) * args->distance_f);
Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
args->right_f) * args->distance_f);
Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
args->left_rear_f) * args->distance_f);
Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
args->right_rear_f) * args->distance_f);
May 22, 2013
May 22, 2013
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
switch (args->room_angle) {
case 0:
*(ptr++) = (Sint16) SDL_SwapLE16(swapl);
*(ptr++) = (Sint16) SDL_SwapLE16(swapr);
*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
break;
case 90:
*(ptr++) = (Sint16) SDL_SwapLE16(swapr);
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapl);
*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
break;
case 180:
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapl);
break;
case 270:
*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapl);
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapr);
break;
}
Aug 21, 2004
Aug 21, 2004
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
}
}
static void _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata)
{
/* 16 signed bits (lsb) * 6 channels. */
volatile position_args *args = (volatile position_args *) udata;
Sint16 *ptr = (Sint16 *) stream;
int i;
for (i = 0; i < len; i += sizeof (Sint16) * 6) {
Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
args->left_f) * args->distance_f);
Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
args->right_f) * args->distance_f);
Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
args->left_rear_f) * args->distance_f);
Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+3))) *
args->right_rear_f) * args->distance_f);
Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+4))) *
args->center_f) * args->distance_f);
Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+5))) *
args->lfe_f) * args->distance_f);
May 22, 2013
May 22, 2013
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
switch (args->room_angle) {
case 0:
*(ptr++) = (Sint16) SDL_SwapLE16(swapl);
*(ptr++) = (Sint16) SDL_SwapLE16(swapr);
*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapce);
*(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
break;
case 90:
*(ptr++) = (Sint16) SDL_SwapLE16(swapr);
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapl);
*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapr)/2 + (Sint16) SDL_SwapLE16(swaprr)/2;
*(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
break;
case 180:
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapl);
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
*(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
break;
case 270:
*(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapl);
*(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapr);
*(ptr++) = (Sint16) SDL_SwapLE16(swapl)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
*(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
break;
}
870
871
872
873
874
875
876
877
878
879
880
}
}
static void _Eff_position_u16msb(int chan, void *stream, int len, void *udata)
{
/* 16 signed bits (lsb) * 2 channels. */
volatile position_args *args = (volatile position_args *) udata;
Uint16 *ptr = (Uint16 *) stream;
int i;
for (i = 0; i < len; i += sizeof (Sint16) * 2) {
Feb 21, 2003
Feb 21, 2003
881
882
Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
May 22, 2013
May 22, 2013
883
Dec 27, 2002
Dec 27, 2002
884
885
886
887
888
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);
May 22, 2013
May 22, 2013
889
890
891
892
893
894
895
896
if (args->room_angle == 180) {
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
}
else {
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
}
Aug 21, 2004
Aug 21, 2004
897
898
899
900
901
902
903
904
905
906
907
908
909
910
}
}
static void _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata)
{
/* 16 signed bits (lsb) * 4 channels. */
volatile position_args *args = (volatile position_args *) udata;
Uint16 *ptr = (Uint16 *) stream;
int i;
for (i = 0; i < len; i += sizeof (Sint16) * 4) {
Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
May 22, 2013
May 22, 2013
911
Aug 21, 2004
Aug 21, 2004
912
913
914
915
916
917
918
919
920
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);
Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
* args->distance_f) + 32768);
Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
* args->distance_f) + 32768);
May 22, 2013
May 22, 2013
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
switch (args->room_angle) {
case 0:
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
break;
case 90:
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
break;
case 180:
*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
break;
case 270:
*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
break;
}
Aug 21, 2004
Aug 21, 2004
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
}
}
static void _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata)
{
/* 16 signed bits (lsb) * 6 channels. */
volatile position_args *args = (volatile position_args *) udata;
Uint16 *ptr = (Uint16 *) stream;
int i;
for (i = 0; i < len; i += sizeof (Sint16) * 6) {
Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768);
Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768);
May 22, 2013
May 22, 2013
963
Aug 21, 2004
Aug 21, 2004
964
965
966
967
968
969
970
971
972
973
974
975
976
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);
Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
* args->distance_f) + 32768);
Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
* args->distance_f) + 32768);
Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
* args->distance_f) + 32768);
Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
* args->distance_f) + 32768);
May 22, 2013
May 22, 2013
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
switch (args->room_angle) {
case 0:
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapce);
*(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
break;
case 90:
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2;
*(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
break;
case 180:
*(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
*(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapr);
*(ptr++) = (Uint16) SDL_SwapBE16(swapl);
*(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
*(ptr++) = (Uint16) SDL_SwapBE16(swapwf);