Skip to content

Latest commit

 

History

History
2048 lines (1881 loc) · 78.3 KB

effect_position.c

File metadata and controls

2048 lines (1881 loc) · 78.3 KB
 
Dec 31, 2011
Dec 31, 2011
2
SDL_mixer: An audio mixer library based on the SDL library
Jan 2, 2017
Jan 2, 2017
3
Copyright (C) 1997-2017 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
#include "SDL.h"
Feb 7, 2002
Feb 7, 2002
34
#include "SDL_endian.h"
Jan 29, 2016
Jan 29, 2016
35
36
#include "SDL_mixer.h"
#include "mixer.h"
37
38
39
40
41
42
43
44
45
#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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
66
67
68
69
70
71
72
73
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;
74
75
volatile float distance_f;
volatile Uint8 distance_u8;
Aug 21, 2004
Aug 21, 2004
76
volatile Sint16 room_angle;
77
78
79
80
81
82
83
84
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
85
86
87
88
void _Eff_PositionDeinit(void)
{
int i;
for (i = 0; i < position_channels; i++) {
Jan 13, 2012
Jan 13, 2012
89
SDL_free(pos_args_array[i]);
Jul 15, 2007
Jul 15, 2007
90
91
}
Feb 4, 2008
Feb 4, 2008
92
93
position_channels = 0;
Jan 13, 2012
Jan 13, 2012
94
SDL_free(pos_args_global);
Jul 15, 2007
Jul 15, 2007
95
pos_args_global = NULL;
Jan 13, 2012
Jan 13, 2012
96
SDL_free(pos_args_array);
Jul 15, 2007
Jul 15, 2007
97
98
99
100
pos_args_array = NULL;
}
101
102
103
104
105
/* 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
106
SDL_free(pos_args_global);
107
108
109
110
111
pos_args_global = NULL;
}
}
else if (pos_args_array[channel] != NULL) {
Jan 13, 2012
Jan 13, 2012
112
SDL_free(pos_args_array[channel]);
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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
130
131
*ptr = (Uint8) (((float) *ptr) * args->distance_f);
ptr++;
132
133
134
len--;
}
Oct 10, 2009
Oct 10, 2009
135
if (args->room_angle == 180)
136
for (i = 0; i < len; i += sizeof (Uint8) * 2) {
Aug 21, 2004
Aug 21, 2004
137
/* must adjust the sample so that 0 is the center */
May 22, 2013
May 22, 2013
138
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
139
140
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
141
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
142
143
144
145
* args->left_f) * args->distance_f) + 128);
ptr++;
}
else for (i = 0; i < len; i += sizeof (Uint8) * 2) {
Dec 27, 2002
Dec 27, 2002
146
/* must adjust the sample so that 0 is the center */
May 22, 2013
May 22, 2013
147
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Dec 27, 2002
Dec 27, 2002
148
* args->left_f) * args->distance_f) + 128);
Feb 21, 2003
Feb 21, 2003
149
ptr++;
May 22, 2013
May 22, 2013
150
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Dec 27, 2002
Dec 27, 2002
151
* args->right_f) * args->distance_f) + 128);
Feb 21, 2003
Feb 21, 2003
152
ptr++;
153
154
}
}
Aug 21, 2004
Aug 21, 2004
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
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
175
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
176
177
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
178
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
179
180
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
181
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
182
183
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
184
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
185
186
187
188
189
190
* 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
191
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
192
193
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
194
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
195
196
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
197
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
198
199
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
200
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
201
202
203
204
205
206
* 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
207
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
208
209
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
210
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
211
212
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
213
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
214
215
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
216
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
217
218
219
220
221
222
* 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
223
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
224
225
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
226
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
227
228
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
229
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
230
231
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
232
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
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
* 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
259
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
260
261
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
262
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
263
264
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
265
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
266
267
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
268
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
269
270
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
271
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
272
273
* args->center_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
274
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
275
276
277
278
279
280
* 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
281
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
282
283
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
284
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
285
286
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
287
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
288
289
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
290
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
291
292
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
293
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
294
* args->right_rear_f) * args->distance_f/2) + 128)
May 22, 2013
May 22, 2013
295
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
296
297
* args->right_f) * args->distance_f/2) + 128);
ptr++;
May 22, 2013
May 22, 2013
298
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
299
300
301
302
303
304
* 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
305
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
306
307
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
308
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
309
310
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
311
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
312
313
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
314
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
315
316
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
317
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
318
* args->right_rear_f) * args->distance_f/2) + 128)
May 22, 2013
May 22, 2013
319
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
320
321
* args->left_rear_f) * args->distance_f/2) + 128);
ptr++;
May 22, 2013
May 22, 2013
322
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
323
324
325
326
327
328
* 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
329
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
330
331
* args->left_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
332
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
333
334
* args->left_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
335
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
336
337
* args->right_rear_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
338
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
339
340
* args->right_f) * args->distance_f) + 128);
ptr++;
May 22, 2013
May 22, 2013
341
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
342
* args->left_f) * args->distance_f/2) + 128)
May 22, 2013
May 22, 2013
343
+ (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
344
345
* args->left_rear_f) * args->distance_f/2) + 128);
ptr++;
May 22, 2013
May 22, 2013
346
*ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
Aug 21, 2004
Aug 21, 2004
347
348
349
350
* args->lfe_f) * args->distance_f) + 128);
ptr++;
}
}
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
/*
* 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
371
if (args->room_angle == 180) {
May 22, 2013
May 22, 2013
372
373
374
Uint8 *temp = l;
l = r;
r = temp;
Aug 21, 2004
Aug 21, 2004
375
}
376
377
378
379
380
381
/*
* 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
382
383
384
385
386
387
*ptr = d[l[*ptr]];
ptr++;
if (args->channels > 1) {
*ptr = d[r[*ptr]];
ptr++;
}
388
389
390
391
392
393
len -= args->channels;
}
p = (Uint32 *) ptr;
for (i = 0; i < len; i += sizeof (Uint32)) {
Feb 7, 2002
Feb 7, 2002
394
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
Jul 21, 2007
Jul 21, 2007
395
396
397
398
*p = (d[l[(*p & 0xFF000000) >> 24]] << 24) |
(d[r[(*p & 0x00FF0000) >> 16]] << 16) |
(d[l[(*p & 0x0000FF00) >> 8]] << 8) |
(d[r[(*p & 0x000000FF) ]] ) ;
399
#else
Jul 21, 2007
Jul 21, 2007
400
401
402
403
*p = (d[r[(*p & 0xFF000000) >> 24]] << 24) |
(d[l[(*p & 0x00FF0000) >> 16]] << 16) |
(d[r[(*p & 0x0000FF00) >> 8]] << 8) |
(d[l[(*p & 0x000000FF) ]] ) ;
404
#endif
Jul 21, 2007
Jul 21, 2007
405
++p;
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
}
}
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
422
423
*ptr = (Sint8) (((float) *ptr) * args->distance_f);
ptr++;
424
425
426
len--;
}
Aug 21, 2004
Aug 21, 2004
427
428
429
430
431
432
433
434
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
435
for (i = 0; i < len; i += sizeof (Sint8) * 2) {
Feb 21, 2003
Feb 21, 2003
436
437
438
439
*ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
ptr++;
*ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
ptr++;
440
441
}
}
Aug 21, 2004
Aug 21, 2004
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
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
466
break;
Aug 21, 2004
Aug 21, 2004
467
468
469
470
471
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
472
break;
Aug 21, 2004
Aug 21, 2004
473
474
475
476
477
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
478
break;
Aug 21, 2004
Aug 21, 2004
479
480
481
482
483
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
484
break;
Aug 21, 2004
Aug 21, 2004
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
}
}
}
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
514
break;
Aug 21, 2004
Aug 21, 2004
515
516
517
518
519
520
521
522
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
523
break;
Aug 21, 2004
Aug 21, 2004
524
525
526
527
528
529
530
531
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
532
break;
Aug 21, 2004
Aug 21, 2004
533
534
535
536
537
538
539
540
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
541
break;
Aug 21, 2004
Aug 21, 2004
542
543
544
}
}
}
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
/*
* 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
561
562
Sint8 *l = ((Sint8 *) _Eff_volume_table) + (256 * args->left_u8);
Sint8 *r = ((Sint8 *) _Eff_volume_table) + (256 * args->right_u8);
563
564
Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8);
Aug 21, 2004
Aug 21, 2004
565
if (args->room_angle == 180) {
May 22, 2013
May 22, 2013
566
567
568
Sint8 *temp = l;
l = r;
r = temp;
Aug 21, 2004
Aug 21, 2004
569
570
}
571
572
while (len % sizeof (Uint32) != 0) {
Feb 21, 2003
Feb 21, 2003
573
574
575
576
577
578
*ptr = d[l[*ptr]];
ptr++;
if (args->channels > 1) {
*ptr = d[r[*ptr]];
ptr++;
}
579
580
581
582
583
584
len -= args->channels;
}
p = (Uint32 *) ptr;
for (i = 0; i < len; i += sizeof (Uint32)) {
Feb 7, 2002
Feb 7, 2002
585
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
Jul 21, 2007
Jul 21, 2007
586
587
588
589
*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]] ) ;
590
#else
Jul 21, 2007
Jul 21, 2007
591
592
593
594
*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]] ) ;
595
#endif
Jul 21, 2007
Jul 21, 2007
596
++p;
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
}
}
/* !!! 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
612
613
Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
May 22, 2013
May 22, 2013
614
Dec 27, 2002
Dec 27, 2002
615
616
617
618
619
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
620
621
622
623
624
625
626
627
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
628
629
630
631
632
633
634
635
636
637
638
639
640
}
}
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
641
Aug 21, 2004
Aug 21, 2004
642
643
644
645
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
646
Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
Aug 21, 2004
Aug 21, 2004
647
* args->distance_f) + 32768);
Jun 23, 2006
Jun 23, 2006
648
Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
Aug 21, 2004
Aug 21, 2004
649
650
* args->distance_f) + 32768);
May 22, 2013
May 22, 2013
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
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
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
}
}
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
692
Aug 21, 2004
Aug 21, 2004
693
694
695
696
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
697
Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
Aug 21, 2004
Aug 21, 2004
698
* args->distance_f) + 32768);
Jun 23, 2006
Jun 23, 2006
699
Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
Aug 21, 2004
Aug 21, 2004
700
* args->distance_f) + 32768);
Jun 23, 2006
Jun 23, 2006
701
Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
Aug 21, 2004
Aug 21, 2004
702
* args->distance_f) + 32768);
Jun 23, 2006
Jun 23, 2006
703
Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
Aug 21, 2004
Aug 21, 2004
704
705
* args->distance_f) + 32768);
May 22, 2013
May 22, 2013
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
739
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;
}
740
741
742
743
744
745
746
747
748
749
}
}
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
750
751
#if 0
if (len % (sizeof(Sint16) * 2)) {
May 22, 2013
May 22, 2013
752
753
fprintf(stderr,"Not an even number of frames! len=%d\n", len);
return;
Aug 21, 2004
Aug 21, 2004
754
755
756
}
#endif
757
for (i = 0; i < len; i += sizeof (Sint16) * 2) {
Nov 10, 2003
Nov 10, 2003
758
Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
759
args->left_f) * args->distance_f);
Nov 10, 2003
Nov 10, 2003
760
Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
761
args->right_f) * args->distance_f);
May 22, 2013
May 22, 2013
762
763
764
765
766
767
768
769
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
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
}
}
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
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
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
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
}
}
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
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
870
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;
}
871
872
873
874
875
876
877
878
879
880
881
}
}
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
882
883
Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
May 22, 2013
May 22, 2013
884
Dec 27, 2002
Dec 27, 2002
885
886
887
888
889
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
890
891
892
893
894
895
896
897
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
898
899
900
901
902
903
904
905
906
907
908
909
910
911
}
}
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
912
Aug 21, 2004
Aug 21, 2004
913
914
915
916
917
918
919
920
921
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
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
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
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
}
}
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
964
Aug 21, 2004
Aug 21, 2004
965
966
967
968
969
970
971
972
973
974
975
976
977
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
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;