forked from kcat/dsoal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverb.c
636 lines (540 loc) · 25.4 KB
/
reverb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
/* EAX reverb interface
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define CONST_VTABLE
#include <stdarg.h>
#include <string.h>
#include "windows.h"
#include "dsound.h"
#include "dsound_private.h"
#include "eax-presets.h"
static void ApplyReverbParams(ALuint effect, const EAXREVERBPROPERTIES *props)
{
/* FIXME: Need to validate property values... Ignore? Clamp? Error? */
alEffectf(effect, AL_EAXREVERB_DENSITY,
clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f)
);
alEffectf(effect, AL_EAXREVERB_DIFFUSION, props->flEnvironmentDiffusion);
alEffectf(effect, AL_EAXREVERB_GAIN, mB_to_gain((float)props->lRoom));
alEffectf(effect, AL_EAXREVERB_GAINHF, mB_to_gain((float)props->lRoomHF));
alEffectf(effect, AL_EAXREVERB_GAINLF, mB_to_gain((float)props->lRoomLF));
alEffectf(effect, AL_EAXREVERB_DECAY_TIME, props->flDecayTime);
alEffectf(effect, AL_EAXREVERB_DECAY_HFRATIO, props->flDecayHFRatio);
alEffectf(effect, AL_EAXREVERB_DECAY_LFRATIO, props->flDecayLFRatio);
/* NOTE: Imprecision can cause some converted volume levels to land outside
* EFX's gain limits (e.g. EAX's +1000mB volume limit gets converted to
* 3.162something, while EFX defines the limit as 3.16; close enough for
* practical uses, but still technically an error).
*/
alEffectf(effect, AL_EAXREVERB_REFLECTIONS_GAIN,
clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN,
AL_EAXREVERB_MAX_REFLECTIONS_GAIN)
);
alEffectf(effect, AL_EAXREVERB_REFLECTIONS_DELAY, props->flReflectionsDelay);
alEffectfv(effect, AL_EAXREVERB_REFLECTIONS_PAN, &props->vReflectionsPan.x);
alEffectf(effect, AL_EAXREVERB_LATE_REVERB_GAIN,
clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN,
AL_EAXREVERB_MAX_LATE_REVERB_GAIN)
);
alEffectf(effect, AL_EAXREVERB_LATE_REVERB_DELAY, props->flReverbDelay);
alEffectfv(effect, AL_EAXREVERB_LATE_REVERB_PAN, &props->vReverbPan.x);
alEffectf(effect, AL_EAXREVERB_ECHO_TIME, props->flEchoTime);
alEffectf(effect, AL_EAXREVERB_ECHO_DEPTH, props->flEchoDepth);
alEffectf(effect, AL_EAXREVERB_MODULATION_TIME, props->flModulationTime);
alEffectf(effect, AL_EAXREVERB_MODULATION_DEPTH, props->flModulationDepth);
alEffectf(effect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF,
clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF,
AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF)
);
alEffectf(effect, AL_EAXREVERB_HFREFERENCE, props->flHFReference);
alEffectf(effect, AL_EAXREVERB_LFREFERENCE, props->flLFReference);
alEffectf(effect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor);
alEffecti(effect, AL_EAXREVERB_DECAY_HFLIMIT,
(props->dwFlags&EAX30LISTENERFLAGS_DECAYHFLIMIT) ?
AL_TRUE : AL_FALSE);
checkALError();
}
static void RescaleEnvSize(EAXREVERBPROPERTIES *props, float newsize)
{
float scale = newsize / props->flEnvironmentSize;
props->flEnvironmentSize = newsize;
if((props->dwFlags&EAX30LISTENERFLAGS_DECAYTIMESCALE))
{
props->flDecayTime *= scale;
props->flDecayTime = clampF(props->flDecayTime, 0.1f, 20.0f);
}
if((props->dwFlags&EAX30LISTENERFLAGS_REFLECTIONSSCALE))
{
props->lReflections -= gain_to_mB(scale);
props->lReflections = clampI(props->lReflections, -10000, 1000);
}
if((props->dwFlags&EAX30LISTENERFLAGS_REFLECTIONSDELAYSCALE))
{
props->flReflectionsDelay *= scale;
props->flReflectionsDelay = clampF(props->flReflectionsDelay, 0.0f, 0.3f);
}
if((props->dwFlags&EAX30LISTENERFLAGS_REVERBSCALE))
{
LONG diff = gain_to_mB(scale);
/* This is scaled by an extra 1/3rd if decay time isn't also scaled, to
* account for the (lack of) change on the send's initial decay.
*/
if(!(props->dwFlags&EAX30LISTENERFLAGS_DECAYTIMESCALE))
diff = diff * 3 / 2;
props->lReverb -= diff;
props->lReverb = clampI(props->lReverb, -10000, 2000);
}
if((props->dwFlags&EAX30LISTENERFLAGS_REVERBDELAYSCALE))
{
props->flReverbDelay *= scale;
props->flReverbDelay = clampF(props->flReverbDelay, 0.0f, 0.1f);
}
if((props->dwFlags&EAX30LISTENERFLAGS_ECHOTIMESCALE))
{
props->flEchoTime *= scale;
props->flEchoTime = clampF(props->flEchoTime, 0.075f, 0.25f);
}
if((props->dwFlags&EAX30LISTENERFLAGS_MODTIMESCALE))
{
props->flModulationTime *= scale;
props->flModulationTime = clampF(props->flModulationTime, 0.04f, 4.0f);
}
}
HRESULT EAXReverb_Set(DSPrimary *prim, LONG idx, DWORD propid, void *pPropData, ULONG cbPropData)
{
switch(propid)
{
case EAXREVERB_NONE: /* not setting any property, just applying */
return DS_OK;
case EAXREVERB_ALLPARAMETERS:
if(cbPropData >= sizeof(EAXREVERBPROPERTIES))
{
union {
const void *v;
const EAXREVERBPROPERTIES *props;
} data = { pPropData };
TRACE("Parameters:\n\tEnvironment: %lu\n\tEnvSize: %f\n\tEnvDiffusion: %f\n\t"
"Room: %ld\n\tRoom HF: %ld\n\tRoom LF: %ld\n\tDecay Time: %f\n\t"
"Decay HF Ratio: %f\n\tDecay LF Ratio: %f\n\tReflections: %ld\n\t"
"Reflections Delay: %f\n\tReflections Pan: { %f, %f, %f }\n\tReverb: %ld\n\t"
"Reverb Delay: %f\n\tReverb Pan: { %f, %f, %f }\n\tEcho Time: %f\n\t"
"Echo Depth: %f\n\tMod Time: %f\n\tMod Depth: %f\n\tAir Absorption: %f\n\t"
"HF Reference: %f\n\tLF Reference: %f\n\tRoom Rolloff: %f\n\tFlags: 0x%02lx\n",
data.props->dwEnvironment, data.props->flEnvironmentSize,
data.props->flEnvironmentDiffusion, data.props->lRoom, data.props->lRoomHF,
data.props->lRoomLF, data.props->flDecayTime, data.props->flDecayHFRatio,
data.props->flDecayLFRatio, data.props->lReflections,
data.props->flReflectionsDelay, data.props->vReflectionsPan.x,
data.props->vReflectionsPan.y, data.props->vReflectionsPan.z, data.props->lReverb,
data.props->flReverbDelay, data.props->vReverbPan.x, data.props->vReverbPan.y,
data.props->vReverbPan.z, data.props->flEchoTime, data.props->flEchoDepth,
data.props->flModulationTime, data.props->flModulationDepth,
data.props->flAirAbsorptionHF, data.props->flHFReference,
data.props->flLFReference, data.props->flRoomRolloffFactor, data.props->dwFlags
);
ApplyReverbParams(prim->effect[idx], data.props);
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ENVIRONMENT:
if(cbPropData >= sizeof(DWORD))
{
union { const void *v; const DWORD *dw; } data = { pPropData };
TRACE("Environment: %lu\n", *data.dw);
if(*data.dw < EAX_ENVIRONMENT_UNDEFINED)
{
prim->deferred.fxslot[idx].fx.reverb = EnvironmentDefaults[*data.dw];
ApplyReverbParams(prim->effect[idx], &EnvironmentDefaults[*data.dw]);
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ENVIRONMENTSIZE:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Environment Size: %f\n", *data.fl);
RescaleEnvSize(&prim->deferred.fxslot[idx].fx.reverb, clampF(*data.fl, 1.0f, 100.0f));
ApplyReverbParams(prim->effect[idx], &prim->deferred.fxslot[idx].fx.reverb);
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ENVIRONMENTDIFFUSION:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Environment Diffusion: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flEnvironmentDiffusion = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_DIFFUSION,
prim->deferred.fxslot[idx].fx.reverb.flEnvironmentDiffusion);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ROOM:
if(cbPropData >= sizeof(long))
{
union { const void *v; const long *l; } data = { pPropData };
TRACE("Room: %ld\n", *data.l);
prim->deferred.fxslot[idx].fx.reverb.lRoom = *data.l;
alEffectf(prim->effect[idx], AL_EAXREVERB_GAIN,
mB_to_gain((float)prim->deferred.fxslot[idx].fx.reverb.lRoom));
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ROOMHF:
if(cbPropData >= sizeof(long))
{
union { const void *v; const long *l; } data = { pPropData };
TRACE("Room HF: %ld\n", *data.l);
prim->deferred.fxslot[idx].fx.reverb.lRoomHF = *data.l;
alEffectf(prim->effect[idx], AL_EAXREVERB_GAINHF,
mB_to_gain((float)prim->deferred.fxslot[idx].fx.reverb.lRoomHF));
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ROOMLF:
if(cbPropData >= sizeof(long))
{
union { const void *v; const long *l; } data = { pPropData };
TRACE("Room LF: %ld\n", *data.l);
prim->deferred.fxslot[idx].fx.reverb.lRoomLF = *data.l;
alEffectf(prim->effect[idx], AL_EAXREVERB_GAINLF,
mB_to_gain((float)prim->deferred.fxslot[idx].fx.reverb.lRoomLF));
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_DECAYTIME:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Decay Time: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flDecayTime = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_DECAY_TIME,
prim->deferred.fxslot[idx].fx.reverb.flDecayTime);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_DECAYHFRATIO:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Decay HF Ratio: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flDecayHFRatio = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_DECAY_HFRATIO,
prim->deferred.fxslot[idx].fx.reverb.flDecayHFRatio);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_DECAYLFRATIO:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Decay LF Ratio: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flDecayLFRatio = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_DECAY_LFRATIO,
prim->deferred.fxslot[idx].fx.reverb.flDecayLFRatio);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_REFLECTIONS:
if(cbPropData >= sizeof(long))
{
union { const void *v; const long *l; } data = { pPropData };
TRACE("Reflections: %ld\n", *data.l);
prim->deferred.fxslot[idx].fx.reverb.lReflections = *data.l;
alEffectf(prim->effect[idx], AL_EAXREVERB_REFLECTIONS_GAIN,
mB_to_gain((float)prim->deferred.fxslot[idx].fx.reverb.lReflections));
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_REFLECTIONSDELAY:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Reflections Delay: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flReflectionsDelay = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_REFLECTIONS_DELAY,
prim->deferred.fxslot[idx].fx.reverb.flReflectionsDelay);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_REFLECTIONSPAN:
if(cbPropData >= sizeof(EAXVECTOR))
{
union { const void *v; const EAXVECTOR *vec; } data = { pPropData };
TRACE("Reflections Pan: { %f, %f, %f }\n", data.vec->x, data.vec->y, data.vec->z);
prim->deferred.fxslot[idx].fx.reverb.vReflectionsPan = *data.vec;
alEffectfv(prim->effect[idx], AL_EAXREVERB_REFLECTIONS_PAN,
&prim->deferred.fxslot[idx].fx.reverb.vReflectionsPan.x);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_REVERB:
if(cbPropData >= sizeof(long))
{
union { const void *v; const long *l; } data = { pPropData };
TRACE("Reverb: %ld\n", *data.l);
prim->deferred.fxslot[idx].fx.reverb.lReverb = *data.l;
alEffectf(prim->effect[idx], AL_EAXREVERB_LATE_REVERB_GAIN,
mB_to_gain((float)prim->deferred.fxslot[idx].fx.reverb.lReverb));
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_REVERBDELAY:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Reverb Delay: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flReverbDelay = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_LATE_REVERB_DELAY,
prim->deferred.fxslot[idx].fx.reverb.flReverbDelay);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_REVERBPAN:
if(cbPropData >= sizeof(EAXVECTOR))
{
union { const void *v; const EAXVECTOR *vec; } data = { pPropData };
TRACE("Reverb Pan: { %f, %f, %f }\n", data.vec->x, data.vec->y, data.vec->z);
prim->deferred.fxslot[idx].fx.reverb.vReverbPan = *data.vec;
alEffectfv(prim->effect[idx], AL_EAXREVERB_LATE_REVERB_PAN,
&prim->deferred.fxslot[idx].fx.reverb.vReverbPan.x);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ECHOTIME:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Echo Time: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flEchoTime = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_ECHO_TIME,
prim->deferred.fxslot[idx].fx.reverb.flEchoTime);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ECHODEPTH:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Echo Depth: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flEchoDepth = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_ECHO_DEPTH,
prim->deferred.fxslot[idx].fx.reverb.flEchoDepth);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_MODULATIONTIME:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Modulation Time: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flModulationTime = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_MODULATION_TIME,
prim->deferred.fxslot[idx].fx.reverb.flModulationTime);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_MODULATIONDEPTH:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Modulation Depth: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flModulationDepth = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_MODULATION_DEPTH,
prim->deferred.fxslot[idx].fx.reverb.flModulationDepth);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_AIRABSORPTIONHF:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Air Absorption HF: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flAirAbsorptionHF = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_AIR_ABSORPTION_GAINHF,
mB_to_gain(prim->deferred.fxslot[idx].fx.reverb.flAirAbsorptionHF));
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_HFREFERENCE:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("HF Reference: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flHFReference = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_HFREFERENCE,
prim->deferred.fxslot[idx].fx.reverb.flHFReference);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_LFREFERENCE:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("LF Reference: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flLFReference = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_LFREFERENCE,
prim->deferred.fxslot[idx].fx.reverb.flLFReference);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_ROOMROLLOFFFACTOR:
if(cbPropData >= sizeof(float))
{
union { const void *v; const float *fl; } data = { pPropData };
TRACE("Room Rolloff Factor: %f\n", *data.fl);
prim->deferred.fxslot[idx].fx.reverb.flRoomRolloffFactor = *data.fl;
alEffectf(prim->effect[idx], AL_EAXREVERB_ROOM_ROLLOFF_FACTOR,
prim->deferred.fxslot[idx].fx.reverb.flRoomRolloffFactor);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
case EAXREVERB_FLAGS:
if(cbPropData >= sizeof(DWORD))
{
union { const void *v; const DWORD *dw; } data = { pPropData };
TRACE("Flags: %lu\n", *data.dw);
prim->deferred.fxslot[idx].fx.reverb.dwFlags = *data.dw;
alEffecti(prim->effect[idx], AL_EAXREVERB_DECAY_HFLIMIT,
(prim->deferred.fxslot[idx].fx.reverb.dwFlags&EAX30LISTENERFLAGS_DECAYHFLIMIT) ?
AL_TRUE : AL_FALSE
);
checkALError();
FXSLOT_SET_DIRTY(prim->dirty.bit, idx, FXSLOT_EFFECT_BIT);
return DS_OK;
}
return DSERR_INVALIDPARAM;
}
FIXME("Unhandled propid: 0x%08lx\n", propid);
return E_PROP_ID_UNSUPPORTED;
}
#define GET_PROP(src, T) do { \
if(cbPropData >= sizeof(T)) \
{ \
union { void *v; T *props; } data = { pPropData }; \
*data.props = src; \
*pcbReturned = sizeof(T); \
return DS_OK; \
} \
return DSERR_INVALIDPARAM; \
} while(0)
HRESULT EAXReverb_Get(DSPrimary *prim, DWORD idx, DWORD propid, void *pPropData, ULONG cbPropData, ULONG *pcbReturned)
{
switch(propid)
{
case EAXREVERB_NONE:
*pcbReturned = 0;
return DS_OK;
case EAXREVERB_ALLPARAMETERS:
GET_PROP(prim->current.fxslot[idx].fx.reverb, EAXREVERBPROPERTIES);
case EAXREVERB_ENVIRONMENT:
GET_PROP(prim->current.fxslot[idx].fx.reverb.dwEnvironment, DWORD);
case EAXREVERB_ENVIRONMENTSIZE:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flEnvironmentSize, float);
case EAXREVERB_ENVIRONMENTDIFFUSION:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flEnvironmentDiffusion, float);
case EAXREVERB_ROOM:
GET_PROP(prim->current.fxslot[idx].fx.reverb.lRoom, long);
case EAXREVERB_ROOMHF:
GET_PROP(prim->current.fxslot[idx].fx.reverb.lRoomHF, long);
case EAXREVERB_ROOMLF:
GET_PROP(prim->current.fxslot[idx].fx.reverb.lRoomLF, long);
case EAXREVERB_DECAYTIME:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flDecayTime, float);
case EAXREVERB_DECAYHFRATIO:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flDecayHFRatio, float);
case EAXREVERB_DECAYLFRATIO:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flDecayLFRatio, float);
case EAXREVERB_REFLECTIONS:
GET_PROP(prim->current.fxslot[idx].fx.reverb.lReflections, long);
case EAXREVERB_REFLECTIONSDELAY:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flReflectionsDelay, float);
case EAXREVERB_REFLECTIONSPAN:
GET_PROP(prim->current.fxslot[idx].fx.reverb.vReflectionsPan, EAXVECTOR);
case EAXREVERB_REVERB:
GET_PROP(prim->current.fxslot[idx].fx.reverb.lReverb, long);
case EAXREVERB_REVERBDELAY:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flReverbDelay, float);
case EAXREVERB_REVERBPAN:
GET_PROP(prim->current.fxslot[idx].fx.reverb.vReverbPan, EAXVECTOR);
case EAXREVERB_ECHOTIME:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flEchoTime, float);
case EAXREVERB_ECHODEPTH:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flEchoDepth, float);
case EAXREVERB_MODULATIONTIME:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flModulationTime, float);
case EAXREVERB_MODULATIONDEPTH:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flModulationDepth, float);
case EAXREVERB_AIRABSORPTIONHF:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flAirAbsorptionHF, float);
case EAXREVERB_HFREFERENCE:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flHFReference, float);
case EAXREVERB_LFREFERENCE:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flLFReference, float);
case EAXREVERB_ROOMROLLOFFFACTOR:
GET_PROP(prim->current.fxslot[idx].fx.reverb.flRoomRolloffFactor, float);
case EAXREVERB_FLAGS:
GET_PROP(prim->current.fxslot[idx].fx.reverb.dwFlags, DWORD);
}
FIXME("Unhandled propid: 0x%08lx\n", propid);
return E_PROP_ID_UNSUPPORTED;
}