Ignore the listening angle for the wet path sound cones
[openal-soft.git] / OpenAL32 / alEffect.c
blob5a0360918375908c438e689bc8375bbf7cca62ec
1 /**
2 * OpenAL cross platform audio library
3 * Copyright (C) 1999-2007 by authors.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
21 #include "config.h"
23 #include <stdlib.h>
24 #include <math.h>
25 #include <float.h>
27 #include "AL/al.h"
28 #include "AL/alc.h"
29 #include "alMain.h"
30 #include "alEffect.h"
31 #include "alThunk.h"
32 #include "alError.h"
35 ALboolean DisabledEffects[MAX_EFFECTS];
37 extern inline void LockEffectsRead(ALCdevice *device);
38 extern inline void UnlockEffectsRead(ALCdevice *device);
39 extern inline void LockEffectsWrite(ALCdevice *device);
40 extern inline void UnlockEffectsWrite(ALCdevice *device);
41 extern inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id);
42 extern inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id);
43 extern inline ALboolean IsReverbEffect(ALenum type);
45 static void InitEffectParams(ALeffect *effect, ALenum type);
48 AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
50 ALCdevice *device;
51 ALCcontext *context;
52 ALsizei cur;
54 context = GetContextRef();
55 if(!context) return;
57 if(!(n >= 0))
58 SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
60 device = context->Device;
61 for(cur = 0;cur < n;cur++)
63 ALeffect *effect = calloc(1, sizeof(ALeffect));
64 ALenum err = AL_OUT_OF_MEMORY;
65 if(!effect || (err=InitEffect(effect)) != AL_NO_ERROR)
67 free(effect);
68 alDeleteEffects(cur, effects);
69 SET_ERROR_AND_GOTO(context, err, done);
72 err = NewThunkEntry(&effect->id);
73 if(err == AL_NO_ERROR)
74 err = InsertUIntMapEntry(&device->EffectMap, effect->id, effect);
75 if(err != AL_NO_ERROR)
77 FreeThunkEntry(effect->id);
78 memset(effect, 0, sizeof(ALeffect));
79 free(effect);
81 alDeleteEffects(cur, effects);
82 SET_ERROR_AND_GOTO(context, err, done);
85 effects[cur] = effect->id;
88 done:
89 ALCcontext_DecRef(context);
92 AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects)
94 ALCdevice *device;
95 ALCcontext *context;
96 ALeffect *effect;
97 ALsizei i;
99 context = GetContextRef();
100 if(!context) return;
102 device = context->Device;
103 LockEffectsWrite(device);
104 if(!(n >= 0))
105 SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
106 for(i = 0;i < n;i++)
108 if(effects[i] && LookupEffect(device, effects[i]) == NULL)
109 SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
111 for(i = 0;i < n;i++)
113 if((effect=RemoveEffect(device, effects[i])) == NULL)
114 continue;
115 FreeThunkEntry(effect->id);
117 memset(effect, 0, sizeof(*effect));
118 free(effect);
121 done:
122 UnlockEffectsWrite(device);
123 ALCcontext_DecRef(context);
126 AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
128 ALCcontext *Context;
129 ALboolean result;
131 Context = GetContextRef();
132 if(!Context) return AL_FALSE;
134 LockEffectsRead(Context->Device);
135 result = ((!effect || LookupEffect(Context->Device, effect)) ?
136 AL_TRUE : AL_FALSE);
137 UnlockEffectsRead(Context->Device);
139 ALCcontext_DecRef(Context);
141 return result;
144 AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value)
146 ALCcontext *Context;
147 ALCdevice *Device;
148 ALeffect *ALEffect;
150 Context = GetContextRef();
151 if(!Context) return;
153 Device = Context->Device;
154 LockEffectsWrite(Device);
155 if((ALEffect=LookupEffect(Device, effect)) == NULL)
156 alSetError(Context, AL_INVALID_NAME);
157 else
159 if(param == AL_EFFECT_TYPE)
161 ALboolean isOk = (value == AL_EFFECT_NULL);
162 ALint i;
163 for(i = 0;!isOk && EffectList[i].val;i++)
165 if(value == EffectList[i].val &&
166 !DisabledEffects[EffectList[i].type])
167 isOk = AL_TRUE;
170 if(isOk)
171 InitEffectParams(ALEffect, value);
172 else
173 alSetError(Context, AL_INVALID_VALUE);
175 else
177 /* Call the appropriate handler */
178 V(ALEffect,setParami)(Context, param, value);
181 UnlockEffectsWrite(Device);
183 ALCcontext_DecRef(Context);
186 AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *values)
188 ALCcontext *Context;
189 ALCdevice *Device;
190 ALeffect *ALEffect;
192 switch(param)
194 case AL_EFFECT_TYPE:
195 alEffecti(effect, param, values[0]);
196 return;
199 Context = GetContextRef();
200 if(!Context) return;
202 Device = Context->Device;
203 LockEffectsWrite(Device);
204 if((ALEffect=LookupEffect(Device, effect)) == NULL)
205 alSetError(Context, AL_INVALID_NAME);
206 else
208 /* Call the appropriate handler */
209 V(ALEffect,setParamiv)(Context, param, values);
211 UnlockEffectsWrite(Device);
213 ALCcontext_DecRef(Context);
216 AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value)
218 ALCcontext *Context;
219 ALCdevice *Device;
220 ALeffect *ALEffect;
222 Context = GetContextRef();
223 if(!Context) return;
225 Device = Context->Device;
226 LockEffectsWrite(Device);
227 if((ALEffect=LookupEffect(Device, effect)) == NULL)
228 alSetError(Context, AL_INVALID_NAME);
229 else
231 /* Call the appropriate handler */
232 V(ALEffect,setParamf)(Context, param, value);
234 UnlockEffectsWrite(Device);
236 ALCcontext_DecRef(Context);
239 AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *values)
241 ALCcontext *Context;
242 ALCdevice *Device;
243 ALeffect *ALEffect;
245 Context = GetContextRef();
246 if(!Context) return;
248 Device = Context->Device;
249 LockEffectsWrite(Device);
250 if((ALEffect=LookupEffect(Device, effect)) == NULL)
251 alSetError(Context, AL_INVALID_NAME);
252 else
254 /* Call the appropriate handler */
255 V(ALEffect,setParamfv)(Context, param, values);
257 UnlockEffectsWrite(Device);
259 ALCcontext_DecRef(Context);
262 AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value)
264 ALCcontext *Context;
265 ALCdevice *Device;
266 ALeffect *ALEffect;
268 Context = GetContextRef();
269 if(!Context) return;
271 Device = Context->Device;
272 LockEffectsRead(Device);
273 if((ALEffect=LookupEffect(Device, effect)) == NULL)
274 alSetError(Context, AL_INVALID_NAME);
275 else
277 if(param == AL_EFFECT_TYPE)
278 *value = ALEffect->type;
279 else
281 /* Call the appropriate handler */
282 V(ALEffect,getParami)(Context, param, value);
285 UnlockEffectsRead(Device);
287 ALCcontext_DecRef(Context);
290 AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *values)
292 ALCcontext *Context;
293 ALCdevice *Device;
294 ALeffect *ALEffect;
296 switch(param)
298 case AL_EFFECT_TYPE:
299 alGetEffecti(effect, param, values);
300 return;
303 Context = GetContextRef();
304 if(!Context) return;
306 Device = Context->Device;
307 LockEffectsRead(Device);
308 if((ALEffect=LookupEffect(Device, effect)) == NULL)
309 alSetError(Context, AL_INVALID_NAME);
310 else
312 /* Call the appropriate handler */
313 V(ALEffect,getParamiv)(Context, param, values);
315 UnlockEffectsRead(Device);
317 ALCcontext_DecRef(Context);
320 AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *value)
322 ALCcontext *Context;
323 ALCdevice *Device;
324 ALeffect *ALEffect;
326 Context = GetContextRef();
327 if(!Context) return;
329 Device = Context->Device;
330 LockEffectsRead(Device);
331 if((ALEffect=LookupEffect(Device, effect)) == NULL)
332 alSetError(Context, AL_INVALID_NAME);
333 else
335 /* Call the appropriate handler */
336 V(ALEffect,getParamf)(Context, param, value);
338 UnlockEffectsRead(Device);
340 ALCcontext_DecRef(Context);
343 AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *values)
345 ALCcontext *Context;
346 ALCdevice *Device;
347 ALeffect *ALEffect;
349 Context = GetContextRef();
350 if(!Context) return;
352 Device = Context->Device;
353 LockEffectsRead(Device);
354 if((ALEffect=LookupEffect(Device, effect)) == NULL)
355 alSetError(Context, AL_INVALID_NAME);
356 else
358 /* Call the appropriate handler */
359 V(ALEffect,getParamfv)(Context, param, values);
361 UnlockEffectsRead(Device);
363 ALCcontext_DecRef(Context);
367 ALenum InitEffect(ALeffect *effect)
369 InitEffectParams(effect, AL_EFFECT_NULL);
370 return AL_NO_ERROR;
373 ALvoid ReleaseALEffects(ALCdevice *device)
375 ALsizei i;
376 for(i = 0;i < device->EffectMap.size;i++)
378 ALeffect *temp = device->EffectMap.array[i].value;
379 device->EffectMap.array[i].value = NULL;
381 // Release effect structure
382 FreeThunkEntry(temp->id);
383 memset(temp, 0, sizeof(ALeffect));
384 free(temp);
389 static void InitEffectParams(ALeffect *effect, ALenum type)
391 switch(type)
393 case AL_EFFECT_EAXREVERB:
394 effect->Props.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY;
395 effect->Props.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION;
396 effect->Props.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN;
397 effect->Props.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF;
398 effect->Props.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF;
399 effect->Props.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME;
400 effect->Props.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO;
401 effect->Props.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO;
402 effect->Props.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN;
403 effect->Props.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY;
404 effect->Props.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
405 effect->Props.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
406 effect->Props.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
407 effect->Props.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN;
408 effect->Props.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY;
409 effect->Props.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
410 effect->Props.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
411 effect->Props.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
412 effect->Props.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME;
413 effect->Props.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH;
414 effect->Props.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME;
415 effect->Props.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH;
416 effect->Props.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
417 effect->Props.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE;
418 effect->Props.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE;
419 effect->Props.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
420 effect->Props.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT;
421 SET_VTABLE1(ALeaxreverb, effect);
422 break;
423 case AL_EFFECT_REVERB:
424 effect->Props.Reverb.Density = AL_REVERB_DEFAULT_DENSITY;
425 effect->Props.Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION;
426 effect->Props.Reverb.Gain = AL_REVERB_DEFAULT_GAIN;
427 effect->Props.Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF;
428 effect->Props.Reverb.GainLF = 1.0f;
429 effect->Props.Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME;
430 effect->Props.Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO;
431 effect->Props.Reverb.DecayLFRatio = 1.0f;
432 effect->Props.Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN;
433 effect->Props.Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY;
434 effect->Props.Reverb.ReflectionsPan[0] = 0.0f;
435 effect->Props.Reverb.ReflectionsPan[1] = 0.0f;
436 effect->Props.Reverb.ReflectionsPan[2] = 0.0f;
437 effect->Props.Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN;
438 effect->Props.Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY;
439 effect->Props.Reverb.LateReverbPan[0] = 0.0f;
440 effect->Props.Reverb.LateReverbPan[1] = 0.0f;
441 effect->Props.Reverb.LateReverbPan[2] = 0.0f;
442 effect->Props.Reverb.EchoTime = 0.25f;
443 effect->Props.Reverb.EchoDepth = 0.0f;
444 effect->Props.Reverb.ModulationTime = 0.25f;
445 effect->Props.Reverb.ModulationDepth = 0.0f;
446 effect->Props.Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
447 effect->Props.Reverb.HFReference = 5000.0f;
448 effect->Props.Reverb.LFReference = 250.0f;
449 effect->Props.Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
450 effect->Props.Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT;
451 SET_VTABLE1(ALreverb, effect);
452 break;
453 case AL_EFFECT_AUTOWAH:
454 effect->Props.Autowah.AttackTime = AL_AUTOWAH_DEFAULT_ATTACK_TIME;
455 effect->Props.Autowah.PeakGain = AL_AUTOWAH_DEFAULT_PEAK_GAIN;
456 effect->Props.Autowah.ReleaseTime = AL_AUTOWAH_DEFAULT_RELEASE_TIME;
457 effect->Props.Autowah.Resonance = AL_AUTOWAH_DEFAULT_RESONANCE;
458 SET_VTABLE1(ALautowah, effect);
459 break;
460 case AL_EFFECT_CHORUS:
461 effect->Props.Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM;
462 effect->Props.Chorus.Phase = AL_CHORUS_DEFAULT_PHASE;
463 effect->Props.Chorus.Rate = AL_CHORUS_DEFAULT_RATE;
464 effect->Props.Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH;
465 effect->Props.Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK;
466 effect->Props.Chorus.Delay = AL_CHORUS_DEFAULT_DELAY;
467 SET_VTABLE1(ALchorus, effect);
468 break;
469 case AL_EFFECT_COMPRESSOR:
470 effect->Props.Compressor.OnOff = AL_COMPRESSOR_DEFAULT_ONOFF;
471 SET_VTABLE1(ALcompressor, effect);
472 break;
473 case AL_EFFECT_DISTORTION:
474 effect->Props.Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE;
475 effect->Props.Distortion.Gain = AL_DISTORTION_DEFAULT_GAIN;
476 effect->Props.Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF;
477 effect->Props.Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER;
478 effect->Props.Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH;
479 SET_VTABLE1(ALdistortion, effect);
480 break;
481 case AL_EFFECT_ECHO:
482 effect->Props.Echo.Delay = AL_ECHO_DEFAULT_DELAY;
483 effect->Props.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY;
484 effect->Props.Echo.Damping = AL_ECHO_DEFAULT_DAMPING;
485 effect->Props.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK;
486 effect->Props.Echo.Spread = AL_ECHO_DEFAULT_SPREAD;
487 SET_VTABLE1(ALecho, effect);
488 break;
489 case AL_EFFECT_EQUALIZER:
490 effect->Props.Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF;
491 effect->Props.Equalizer.LowGain = AL_EQUALIZER_DEFAULT_LOW_GAIN;
492 effect->Props.Equalizer.Mid1Center = AL_EQUALIZER_DEFAULT_MID1_CENTER;
493 effect->Props.Equalizer.Mid1Gain = AL_EQUALIZER_DEFAULT_MID1_GAIN;
494 effect->Props.Equalizer.Mid1Width = AL_EQUALIZER_DEFAULT_MID1_WIDTH;
495 effect->Props.Equalizer.Mid2Center = AL_EQUALIZER_DEFAULT_MID2_CENTER;
496 effect->Props.Equalizer.Mid2Gain = AL_EQUALIZER_DEFAULT_MID2_GAIN;
497 effect->Props.Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH;
498 effect->Props.Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF;
499 effect->Props.Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN;
500 SET_VTABLE1(ALequalizer, effect);
501 break;
502 case AL_EFFECT_FLANGER:
503 effect->Props.Flanger.Waveform = AL_FLANGER_DEFAULT_WAVEFORM;
504 effect->Props.Flanger.Phase = AL_FLANGER_DEFAULT_PHASE;
505 effect->Props.Flanger.Rate = AL_FLANGER_DEFAULT_RATE;
506 effect->Props.Flanger.Depth = AL_FLANGER_DEFAULT_DEPTH;
507 effect->Props.Flanger.Feedback = AL_FLANGER_DEFAULT_FEEDBACK;
508 effect->Props.Flanger.Delay = AL_FLANGER_DEFAULT_DELAY;
509 SET_VTABLE1(ALflanger, effect);
510 break;
511 case AL_EFFECT_RING_MODULATOR:
512 effect->Props.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
513 effect->Props.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
514 effect->Props.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
515 SET_VTABLE1(ALmodulator, effect);
516 break;
517 case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT:
518 case AL_EFFECT_DEDICATED_DIALOGUE:
519 effect->Props.Dedicated.Gain = 1.0f;
520 SET_VTABLE1(ALdedicated, effect);
521 break;
522 default:
523 SET_VTABLE1(ALnull, effect);
524 break;
526 effect->type = type;
530 #include "AL/efx-presets.h"
532 #define DECL(x) { #x, EFX_REVERB_PRESET_##x }
533 static const struct {
534 const char name[32];
535 EFXEAXREVERBPROPERTIES props;
536 } reverblist[] = {
537 DECL(GENERIC),
538 DECL(PADDEDCELL),
539 DECL(ROOM),
540 DECL(BATHROOM),
541 DECL(LIVINGROOM),
542 DECL(STONEROOM),
543 DECL(AUDITORIUM),
544 DECL(CONCERTHALL),
545 DECL(CAVE),
546 DECL(ARENA),
547 DECL(HANGAR),
548 DECL(CARPETEDHALLWAY),
549 DECL(HALLWAY),
550 DECL(STONECORRIDOR),
551 DECL(ALLEY),
552 DECL(FOREST),
553 DECL(CITY),
554 DECL(MOUNTAINS),
555 DECL(QUARRY),
556 DECL(PLAIN),
557 DECL(PARKINGLOT),
558 DECL(SEWERPIPE),
559 DECL(UNDERWATER),
560 DECL(DRUGGED),
561 DECL(DIZZY),
562 DECL(PSYCHOTIC),
564 DECL(CASTLE_SMALLROOM),
565 DECL(CASTLE_SHORTPASSAGE),
566 DECL(CASTLE_MEDIUMROOM),
567 DECL(CASTLE_LARGEROOM),
568 DECL(CASTLE_LONGPASSAGE),
569 DECL(CASTLE_HALL),
570 DECL(CASTLE_CUPBOARD),
571 DECL(CASTLE_COURTYARD),
572 DECL(CASTLE_ALCOVE),
574 DECL(FACTORY_SMALLROOM),
575 DECL(FACTORY_SHORTPASSAGE),
576 DECL(FACTORY_MEDIUMROOM),
577 DECL(FACTORY_LARGEROOM),
578 DECL(FACTORY_LONGPASSAGE),
579 DECL(FACTORY_HALL),
580 DECL(FACTORY_CUPBOARD),
581 DECL(FACTORY_COURTYARD),
582 DECL(FACTORY_ALCOVE),
584 DECL(ICEPALACE_SMALLROOM),
585 DECL(ICEPALACE_SHORTPASSAGE),
586 DECL(ICEPALACE_MEDIUMROOM),
587 DECL(ICEPALACE_LARGEROOM),
588 DECL(ICEPALACE_LONGPASSAGE),
589 DECL(ICEPALACE_HALL),
590 DECL(ICEPALACE_CUPBOARD),
591 DECL(ICEPALACE_COURTYARD),
592 DECL(ICEPALACE_ALCOVE),
594 DECL(SPACESTATION_SMALLROOM),
595 DECL(SPACESTATION_SHORTPASSAGE),
596 DECL(SPACESTATION_MEDIUMROOM),
597 DECL(SPACESTATION_LARGEROOM),
598 DECL(SPACESTATION_LONGPASSAGE),
599 DECL(SPACESTATION_HALL),
600 DECL(SPACESTATION_CUPBOARD),
601 DECL(SPACESTATION_ALCOVE),
603 DECL(WOODEN_SMALLROOM),
604 DECL(WOODEN_SHORTPASSAGE),
605 DECL(WOODEN_MEDIUMROOM),
606 DECL(WOODEN_LARGEROOM),
607 DECL(WOODEN_LONGPASSAGE),
608 DECL(WOODEN_HALL),
609 DECL(WOODEN_CUPBOARD),
610 DECL(WOODEN_COURTYARD),
611 DECL(WOODEN_ALCOVE),
613 DECL(SPORT_EMPTYSTADIUM),
614 DECL(SPORT_SQUASHCOURT),
615 DECL(SPORT_SMALLSWIMMINGPOOL),
616 DECL(SPORT_LARGESWIMMINGPOOL),
617 DECL(SPORT_GYMNASIUM),
618 DECL(SPORT_FULLSTADIUM),
619 DECL(SPORT_STADIUMTANNOY),
621 DECL(PREFAB_WORKSHOP),
622 DECL(PREFAB_SCHOOLROOM),
623 DECL(PREFAB_PRACTISEROOM),
624 DECL(PREFAB_OUTHOUSE),
625 DECL(PREFAB_CARAVAN),
627 DECL(DOME_TOMB),
628 DECL(PIPE_SMALL),
629 DECL(DOME_SAINTPAULS),
630 DECL(PIPE_LONGTHIN),
631 DECL(PIPE_LARGE),
632 DECL(PIPE_RESONANT),
634 DECL(OUTDOORS_BACKYARD),
635 DECL(OUTDOORS_ROLLINGPLAINS),
636 DECL(OUTDOORS_DEEPCANYON),
637 DECL(OUTDOORS_CREEK),
638 DECL(OUTDOORS_VALLEY),
640 DECL(MOOD_HEAVEN),
641 DECL(MOOD_HELL),
642 DECL(MOOD_MEMORY),
644 DECL(DRIVING_COMMENTATOR),
645 DECL(DRIVING_PITGARAGE),
646 DECL(DRIVING_INCAR_RACER),
647 DECL(DRIVING_INCAR_SPORTS),
648 DECL(DRIVING_INCAR_LUXURY),
649 DECL(DRIVING_FULLGRANDSTAND),
650 DECL(DRIVING_EMPTYGRANDSTAND),
651 DECL(DRIVING_TUNNEL),
653 DECL(CITY_STREETS),
654 DECL(CITY_SUBWAY),
655 DECL(CITY_MUSEUM),
656 DECL(CITY_LIBRARY),
657 DECL(CITY_UNDERPASS),
658 DECL(CITY_ABANDONED),
660 DECL(DUSTYROOM),
661 DECL(CHAPEL),
662 DECL(SMALLWATERROOM),
664 #undef DECL
666 ALvoid LoadReverbPreset(const char *name, ALeffect *effect)
668 size_t i;
670 if(strcasecmp(name, "NONE") == 0)
672 InitEffectParams(effect, AL_EFFECT_NULL);
673 TRACE("Loading reverb '%s'\n", "NONE");
674 return;
677 if(!DisabledEffects[EAXREVERB])
678 InitEffectParams(effect, AL_EFFECT_EAXREVERB);
679 else if(!DisabledEffects[REVERB])
680 InitEffectParams(effect, AL_EFFECT_REVERB);
681 else
682 InitEffectParams(effect, AL_EFFECT_NULL);
683 for(i = 0;i < COUNTOF(reverblist);i++)
685 const EFXEAXREVERBPROPERTIES *props;
687 if(strcasecmp(name, reverblist[i].name) != 0)
688 continue;
690 TRACE("Loading reverb '%s'\n", reverblist[i].name);
691 props = &reverblist[i].props;
692 effect->Props.Reverb.Density = props->flDensity;
693 effect->Props.Reverb.Diffusion = props->flDiffusion;
694 effect->Props.Reverb.Gain = props->flGain;
695 effect->Props.Reverb.GainHF = props->flGainHF;
696 effect->Props.Reverb.GainLF = props->flGainLF;
697 effect->Props.Reverb.DecayTime = props->flDecayTime;
698 effect->Props.Reverb.DecayHFRatio = props->flDecayHFRatio;
699 effect->Props.Reverb.DecayLFRatio = props->flDecayLFRatio;
700 effect->Props.Reverb.ReflectionsGain = props->flReflectionsGain;
701 effect->Props.Reverb.ReflectionsDelay = props->flReflectionsDelay;
702 effect->Props.Reverb.ReflectionsPan[0] = props->flReflectionsPan[0];
703 effect->Props.Reverb.ReflectionsPan[1] = props->flReflectionsPan[1];
704 effect->Props.Reverb.ReflectionsPan[2] = props->flReflectionsPan[2];
705 effect->Props.Reverb.LateReverbGain = props->flLateReverbGain;
706 effect->Props.Reverb.LateReverbDelay = props->flLateReverbDelay;
707 effect->Props.Reverb.LateReverbPan[0] = props->flLateReverbPan[0];
708 effect->Props.Reverb.LateReverbPan[1] = props->flLateReverbPan[1];
709 effect->Props.Reverb.LateReverbPan[2] = props->flLateReverbPan[2];
710 effect->Props.Reverb.EchoTime = props->flEchoTime;
711 effect->Props.Reverb.EchoDepth = props->flEchoDepth;
712 effect->Props.Reverb.ModulationTime = props->flModulationTime;
713 effect->Props.Reverb.ModulationDepth = props->flModulationDepth;
714 effect->Props.Reverb.AirAbsorptionGainHF = props->flAirAbsorptionGainHF;
715 effect->Props.Reverb.HFReference = props->flHFReference;
716 effect->Props.Reverb.LFReference = props->flLFReference;
717 effect->Props.Reverb.RoomRolloffFactor = props->flRoomRolloffFactor;
718 effect->Props.Reverb.DecayHFLimit = props->iDecayHFLimit;
719 return;
722 WARN("Reverb preset '%s' not found\n", name);