Skip to content

Latest commit

 

History

History
1619 lines (1471 loc) · 59.6 KB

effect_position.c

File metadata and controls

1619 lines (1471 loc) · 59.6 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#define __MIX_INTERNAL_EFFECT__
#include "effects_internal.h"
/* profile code:
#include <sys/time.h>
#include <unistd.h>
struct timeval tv1;
struct timeval tv2;
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
137
138
139
140
141
142
143
144
/* must adjust the sample so that 0 is the center */
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
*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) {
Dec 27, 2002
Dec 27, 2002
145
/* must adjust the sample so that 0 is the center */
Feb 21, 2003
Feb 21, 2003
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
149
ptr++;
*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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
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 */
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
*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))
* args->right_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
*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))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
*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))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* 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 */
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->center_f) * args->distance_f) + 128);
ptr++;
*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))
* args->right_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f/2) + 128)
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f/2) + 128);
ptr++;
*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))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f/2) + 128)
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f/2) + 128);
ptr++;
*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))
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->right_f) * args->distance_f) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_f) * args->distance_f/2) + 128)
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* args->left_rear_f) * args->distance_f/2) + 128);
ptr++;
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
* 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
371
372
373
374
if (args->room_angle == 180) {
Uint8 *temp = l;
l = r;
r = temp;
}
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
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++;
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;
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;
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;
}
}
}
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++;
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++;
*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;
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++;
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++;
*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;
}
}
}
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
565
566
567
568
569
if (args->room_angle == 180) {
Sint8 *temp = l;
l = r;
r = temp;
}
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);
Dec 27, 2002
Dec 27, 2002
613
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);
Aug 21, 2004
Aug 21, 2004
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
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 _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);
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
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
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
* 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;
}
}
}
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
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
* 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;
}
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
751
752
753
754
755
#if 0
if (len % (sizeof(Sint16) * 2)) {
fprintf(stderr,"Not an even number of frames! len=%d\n", len);
return;
}
#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);
Aug 21, 2004
Aug 21, 2004
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
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
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
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
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 _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);
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;
}
}
}
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);
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);
Dec 27, 2002
Dec 27, 2002
883
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);
Aug 21, 2004
Aug 21, 2004
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
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
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
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);
}
}
}
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);
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);
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;
}
}
}
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);
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);
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);