Implement opening and closing devices in the router
[openal-soft.git] / OpenAL32 / alEffect.c
blob6761e661c841333b39ea95a7c3a5711adbbfa343
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 = al_calloc(16, sizeof(ALeffect));
64 ALenum err = AL_OUT_OF_MEMORY;
65 if(!effect || (err=InitEffect(effect)) != AL_NO_ERROR)
67 al_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 al_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 al_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.values[i];
379 device->EffectMap.values[i] = NULL;
381 // Release effect structure
382 FreeThunkEntry(temp->id);
383 memset(temp, 0, sizeof(ALeffect));
384 al_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_CHORUS:
454 effect->Props.Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM;
455 effect->Props.Chorus.Phase = AL_CHORUS_DEFAULT_PHASE;
456 effect->Props.Chorus.Rate = AL_CHORUS_DEFAULT_RATE;
457 effect->Props.Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH;
458 effect->Props.Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK;
459 effect->Props.Chorus.Delay = AL_CHORUS_DEFAULT_DELAY;
460 SET_VTABLE1(ALchorus, effect);
461 break;
462 case AL_EFFECT_COMPRESSOR:
463 effect->Props.Compressor.OnOff = AL_COMPRESSOR_DEFAULT_ONOFF;
464 SET_VTABLE1(ALcompressor, effect);
465 break;
466 case AL_EFFECT_DISTORTION:
467 effect->Props.Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE;
468 effect->Props.Distortion.Gain = AL_DISTORTION_DEFAULT_GAIN;
469 effect->Props.Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF;
470 effect->Props.Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER;
471 effect->Props.Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH;
472 SET_VTABLE1(ALdistortion, effect);
473 break;
474 case AL_EFFECT_ECHO:
475 effect->Props.Echo.Delay = AL_ECHO_DEFAULT_DELAY;
476 effect->Props.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY;
477 effect->Props.Echo.Damping = AL_ECHO_DEFAULT_DAMPING;
478 effect->Props.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK;
479 effect->Props.Echo.Spread = AL_ECHO_DEFAULT_SPREAD;
480 SET_VTABLE1(ALecho, effect);
481 break;
482 case AL_EFFECT_EQUALIZER:
483 effect->Props.Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF;
484 effect->Props.Equalizer.LowGain = AL_EQUALIZER_DEFAULT_LOW_GAIN;
485 effect->Props.Equalizer.Mid1Center = AL_EQUALIZER_DEFAULT_MID1_CENTER;
486 effect->Props.Equalizer.Mid1Gain = AL_EQUALIZER_DEFAULT_MID1_GAIN;
487 effect->Props.Equalizer.Mid1Width = AL_EQUALIZER_DEFAULT_MID1_WIDTH;
488 effect->Props.Equalizer.Mid2Center = AL_EQUALIZER_DEFAULT_MID2_CENTER;
489 effect->Props.Equalizer.Mid2Gain = AL_EQUALIZER_DEFAULT_MID2_GAIN;
490 effect->Props.Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH;
491 effect->Props.Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF;
492 effect->Props.Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN;
493 SET_VTABLE1(ALequalizer, effect);
494 break;
495 case AL_EFFECT_FLANGER:
496 effect->Props.Flanger.Waveform = AL_FLANGER_DEFAULT_WAVEFORM;
497 effect->Props.Flanger.Phase = AL_FLANGER_DEFAULT_PHASE;
498 effect->Props.Flanger.Rate = AL_FLANGER_DEFAULT_RATE;
499 effect->Props.Flanger.Depth = AL_FLANGER_DEFAULT_DEPTH;
500 effect->Props.Flanger.Feedback = AL_FLANGER_DEFAULT_FEEDBACK;
501 effect->Props.Flanger.Delay = AL_FLANGER_DEFAULT_DELAY;
502 SET_VTABLE1(ALflanger, effect);
503 break;
504 case AL_EFFECT_RING_MODULATOR:
505 effect->Props.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
506 effect->Props.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
507 effect->Props.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
508 SET_VTABLE1(ALmodulator, effect);
509 break;
510 case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT:
511 case AL_EFFECT_DEDICATED_DIALOGUE:
512 effect->Props.Dedicated.Gain = 1.0f;
513 SET_VTABLE1(ALdedicated, effect);
514 break;
515 default:
516 SET_VTABLE1(ALnull, effect);
517 break;
519 effect->type = type;
523 #include "AL/efx-presets.h"
525 #define DECL(x) { #x, EFX_REVERB_PRESET_##x }
526 static const struct {
527 const char name[32];
528 EFXEAXREVERBPROPERTIES props;
529 } reverblist[] = {
530 DECL(GENERIC),
531 DECL(PADDEDCELL),
532 DECL(ROOM),
533 DECL(BATHROOM),
534 DECL(LIVINGROOM),
535 DECL(STONEROOM),
536 DECL(AUDITORIUM),
537 DECL(CONCERTHALL),
538 DECL(CAVE),
539 DECL(ARENA),
540 DECL(HANGAR),
541 DECL(CARPETEDHALLWAY),
542 DECL(HALLWAY),
543 DECL(STONECORRIDOR),
544 DECL(ALLEY),
545 DECL(FOREST),
546 DECL(CITY),
547 DECL(MOUNTAINS),
548 DECL(QUARRY),
549 DECL(PLAIN),
550 DECL(PARKINGLOT),
551 DECL(SEWERPIPE),
552 DECL(UNDERWATER),
553 DECL(DRUGGED),
554 DECL(DIZZY),
555 DECL(PSYCHOTIC),
557 DECL(CASTLE_SMALLROOM),
558 DECL(CASTLE_SHORTPASSAGE),
559 DECL(CASTLE_MEDIUMROOM),
560 DECL(CASTLE_LARGEROOM),
561 DECL(CASTLE_LONGPASSAGE),
562 DECL(CASTLE_HALL),
563 DECL(CASTLE_CUPBOARD),
564 DECL(CASTLE_COURTYARD),
565 DECL(CASTLE_ALCOVE),
567 DECL(FACTORY_SMALLROOM),
568 DECL(FACTORY_SHORTPASSAGE),
569 DECL(FACTORY_MEDIUMROOM),
570 DECL(FACTORY_LARGEROOM),
571 DECL(FACTORY_LONGPASSAGE),
572 DECL(FACTORY_HALL),
573 DECL(FACTORY_CUPBOARD),
574 DECL(FACTORY_COURTYARD),
575 DECL(FACTORY_ALCOVE),
577 DECL(ICEPALACE_SMALLROOM),
578 DECL(ICEPALACE_SHORTPASSAGE),
579 DECL(ICEPALACE_MEDIUMROOM),
580 DECL(ICEPALACE_LARGEROOM),
581 DECL(ICEPALACE_LONGPASSAGE),
582 DECL(ICEPALACE_HALL),
583 DECL(ICEPALACE_CUPBOARD),
584 DECL(ICEPALACE_COURTYARD),
585 DECL(ICEPALACE_ALCOVE),
587 DECL(SPACESTATION_SMALLROOM),
588 DECL(SPACESTATION_SHORTPASSAGE),
589 DECL(SPACESTATION_MEDIUMROOM),
590 DECL(SPACESTATION_LARGEROOM),
591 DECL(SPACESTATION_LONGPASSAGE),
592 DECL(SPACESTATION_HALL),
593 DECL(SPACESTATION_CUPBOARD),
594 DECL(SPACESTATION_ALCOVE),
596 DECL(WOODEN_SMALLROOM),
597 DECL(WOODEN_SHORTPASSAGE),
598 DECL(WOODEN_MEDIUMROOM),
599 DECL(WOODEN_LARGEROOM),
600 DECL(WOODEN_LONGPASSAGE),
601 DECL(WOODEN_HALL),
602 DECL(WOODEN_CUPBOARD),
603 DECL(WOODEN_COURTYARD),
604 DECL(WOODEN_ALCOVE),
606 DECL(SPORT_EMPTYSTADIUM),
607 DECL(SPORT_SQUASHCOURT),
608 DECL(SPORT_SMALLSWIMMINGPOOL),
609 DECL(SPORT_LARGESWIMMINGPOOL),
610 DECL(SPORT_GYMNASIUM),
611 DECL(SPORT_FULLSTADIUM),
612 DECL(SPORT_STADIUMTANNOY),
614 DECL(PREFAB_WORKSHOP),
615 DECL(PREFAB_SCHOOLROOM),
616 DECL(PREFAB_PRACTISEROOM),
617 DECL(PREFAB_OUTHOUSE),
618 DECL(PREFAB_CARAVAN),
620 DECL(DOME_TOMB),
621 DECL(PIPE_SMALL),
622 DECL(DOME_SAINTPAULS),
623 DECL(PIPE_LONGTHIN),
624 DECL(PIPE_LARGE),
625 DECL(PIPE_RESONANT),
627 DECL(OUTDOORS_BACKYARD),
628 DECL(OUTDOORS_ROLLINGPLAINS),
629 DECL(OUTDOORS_DEEPCANYON),
630 DECL(OUTDOORS_CREEK),
631 DECL(OUTDOORS_VALLEY),
633 DECL(MOOD_HEAVEN),
634 DECL(MOOD_HELL),
635 DECL(MOOD_MEMORY),
637 DECL(DRIVING_COMMENTATOR),
638 DECL(DRIVING_PITGARAGE),
639 DECL(DRIVING_INCAR_RACER),
640 DECL(DRIVING_INCAR_SPORTS),
641 DECL(DRIVING_INCAR_LUXURY),
642 DECL(DRIVING_FULLGRANDSTAND),
643 DECL(DRIVING_EMPTYGRANDSTAND),
644 DECL(DRIVING_TUNNEL),
646 DECL(CITY_STREETS),
647 DECL(CITY_SUBWAY),
648 DECL(CITY_MUSEUM),
649 DECL(CITY_LIBRARY),
650 DECL(CITY_UNDERPASS),
651 DECL(CITY_ABANDONED),
653 DECL(DUSTYROOM),
654 DECL(CHAPEL),
655 DECL(SMALLWATERROOM),
657 #undef DECL
659 ALvoid LoadReverbPreset(const char *name, ALeffect *effect)
661 size_t i;
663 if(strcasecmp(name, "NONE") == 0)
665 InitEffectParams(effect, AL_EFFECT_NULL);
666 TRACE("Loading reverb '%s'\n", "NONE");
667 return;
670 if(!DisabledEffects[AL__EAXREVERB])
671 InitEffectParams(effect, AL_EFFECT_EAXREVERB);
672 else if(!DisabledEffects[AL__REVERB])
673 InitEffectParams(effect, AL_EFFECT_REVERB);
674 else
675 InitEffectParams(effect, AL_EFFECT_NULL);
676 for(i = 0;i < COUNTOF(reverblist);i++)
678 const EFXEAXREVERBPROPERTIES *props;
680 if(strcasecmp(name, reverblist[i].name) != 0)
681 continue;
683 TRACE("Loading reverb '%s'\n", reverblist[i].name);
684 props = &reverblist[i].props;
685 effect->Props.Reverb.Density = props->flDensity;
686 effect->Props.Reverb.Diffusion = props->flDiffusion;
687 effect->Props.Reverb.Gain = props->flGain;
688 effect->Props.Reverb.GainHF = props->flGainHF;
689 effect->Props.Reverb.GainLF = props->flGainLF;
690 effect->Props.Reverb.DecayTime = props->flDecayTime;
691 effect->Props.Reverb.DecayHFRatio = props->flDecayHFRatio;
692 effect->Props.Reverb.DecayLFRatio = props->flDecayLFRatio;
693 effect->Props.Reverb.ReflectionsGain = props->flReflectionsGain;
694 effect->Props.Reverb.ReflectionsDelay = props->flReflectionsDelay;
695 effect->Props.Reverb.ReflectionsPan[0] = props->flReflectionsPan[0];
696 effect->Props.Reverb.ReflectionsPan[1] = props->flReflectionsPan[1];
697 effect->Props.Reverb.ReflectionsPan[2] = props->flReflectionsPan[2];
698 effect->Props.Reverb.LateReverbGain = props->flLateReverbGain;
699 effect->Props.Reverb.LateReverbDelay = props->flLateReverbDelay;
700 effect->Props.Reverb.LateReverbPan[0] = props->flLateReverbPan[0];
701 effect->Props.Reverb.LateReverbPan[1] = props->flLateReverbPan[1];
702 effect->Props.Reverb.LateReverbPan[2] = props->flLateReverbPan[2];
703 effect->Props.Reverb.EchoTime = props->flEchoTime;
704 effect->Props.Reverb.EchoDepth = props->flEchoDepth;
705 effect->Props.Reverb.ModulationTime = props->flModulationTime;
706 effect->Props.Reverb.ModulationDepth = props->flModulationDepth;
707 effect->Props.Reverb.AirAbsorptionGainHF = props->flAirAbsorptionGainHF;
708 effect->Props.Reverb.HFReference = props->flHFReference;
709 effect->Props.Reverb.LFReference = props->flLFReference;
710 effect->Props.Reverb.RoomRolloffFactor = props->flRoomRolloffFactor;
711 effect->Props.Reverb.DecayHFLimit = props->iDecayHFLimit;
712 return;
715 WARN("Reverb preset '%s' not found\n", name);