Reorder some cmake checks
[openal-soft.git] / OpenAL32 / alEffect.c
blob0bfe11b9c087501bf0255439a5687edbf4d785db
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 struct ALeffect *LookupEffect(ALCdevice *device, ALuint id);
38 extern inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id);
39 extern inline ALboolean IsReverbEffect(ALenum type);
41 static void InitEffectParams(ALeffect *effect, ALenum type);
44 AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
46 ALCdevice *device;
47 ALCcontext *context;
48 ALsizei cur;
50 context = GetContextRef();
51 if(!context) return;
53 if(!(n >= 0))
54 SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
56 device = context->Device;
57 for(cur = 0;cur < n;cur++)
59 ALeffect *effect = calloc(1, sizeof(ALeffect));
60 ALenum err = AL_OUT_OF_MEMORY;
61 if(!effect || (err=InitEffect(effect)) != AL_NO_ERROR)
63 free(effect);
64 alDeleteEffects(cur, effects);
65 SET_ERROR_AND_GOTO(context, err, done);
68 err = NewThunkEntry(&effect->id);
69 if(err == AL_NO_ERROR)
70 err = InsertUIntMapEntry(&device->EffectMap, effect->id, effect);
71 if(err != AL_NO_ERROR)
73 FreeThunkEntry(effect->id);
74 memset(effect, 0, sizeof(ALeffect));
75 free(effect);
77 alDeleteEffects(cur, effects);
78 SET_ERROR_AND_GOTO(context, err, done);
81 effects[cur] = effect->id;
84 done:
85 ALCcontext_DecRef(context);
88 AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects)
90 ALCdevice *device;
91 ALCcontext *context;
92 ALeffect *effect;
93 ALsizei i;
95 context = GetContextRef();
96 if(!context) return;
98 if(!(n >= 0))
99 SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
101 device = context->Device;
102 for(i = 0;i < n;i++)
104 if(effects[i] && LookupEffect(device, effects[i]) == NULL)
105 SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
107 for(i = 0;i < n;i++)
109 if((effect=RemoveEffect(device, effects[i])) == NULL)
110 continue;
111 FreeThunkEntry(effect->id);
113 memset(effect, 0, sizeof(*effect));
114 free(effect);
117 done:
118 ALCcontext_DecRef(context);
121 AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
123 ALCcontext *Context;
124 ALboolean result;
126 Context = GetContextRef();
127 if(!Context) return AL_FALSE;
129 result = ((!effect || LookupEffect(Context->Device, effect)) ?
130 AL_TRUE : AL_FALSE);
132 ALCcontext_DecRef(Context);
134 return result;
137 AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value)
139 ALCcontext *Context;
140 ALCdevice *Device;
141 ALeffect *ALEffect;
143 Context = GetContextRef();
144 if(!Context) return;
146 Device = Context->Device;
147 if((ALEffect=LookupEffect(Device, effect)) == NULL)
148 alSetError(Context, AL_INVALID_NAME);
149 else
151 if(param == AL_EFFECT_TYPE)
153 ALboolean isOk = (value == AL_EFFECT_NULL);
154 ALint i;
155 for(i = 0;!isOk && EffectList[i].val;i++)
157 if(value == EffectList[i].val &&
158 !DisabledEffects[EffectList[i].type])
159 isOk = AL_TRUE;
162 if(isOk)
163 InitEffectParams(ALEffect, value);
164 else
165 alSetError(Context, AL_INVALID_VALUE);
167 else
169 /* Call the appropriate handler */
170 V(ALEffect,setParami)(Context, param, value);
174 ALCcontext_DecRef(Context);
177 AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *values)
179 ALCcontext *Context;
180 ALCdevice *Device;
181 ALeffect *ALEffect;
183 switch(param)
185 case AL_EFFECT_TYPE:
186 alEffecti(effect, param, values[0]);
187 return;
190 Context = GetContextRef();
191 if(!Context) return;
193 Device = Context->Device;
194 if((ALEffect=LookupEffect(Device, effect)) == NULL)
195 alSetError(Context, AL_INVALID_NAME);
196 else
198 /* Call the appropriate handler */
199 V(ALEffect,setParamiv)(Context, param, values);
202 ALCcontext_DecRef(Context);
205 AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value)
207 ALCcontext *Context;
208 ALCdevice *Device;
209 ALeffect *ALEffect;
211 Context = GetContextRef();
212 if(!Context) return;
214 Device = Context->Device;
215 if((ALEffect=LookupEffect(Device, effect)) == NULL)
216 alSetError(Context, AL_INVALID_NAME);
217 else
219 /* Call the appropriate handler */
220 V(ALEffect,setParamf)(Context, param, value);
223 ALCcontext_DecRef(Context);
226 AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *values)
228 ALCcontext *Context;
229 ALCdevice *Device;
230 ALeffect *ALEffect;
232 Context = GetContextRef();
233 if(!Context) return;
235 Device = Context->Device;
236 if((ALEffect=LookupEffect(Device, effect)) == NULL)
237 alSetError(Context, AL_INVALID_NAME);
238 else
240 /* Call the appropriate handler */
241 V(ALEffect,setParamfv)(Context, param, values);
244 ALCcontext_DecRef(Context);
247 AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value)
249 ALCcontext *Context;
250 ALCdevice *Device;
251 ALeffect *ALEffect;
253 Context = GetContextRef();
254 if(!Context) return;
256 Device = Context->Device;
257 if((ALEffect=LookupEffect(Device, effect)) == NULL)
258 alSetError(Context, AL_INVALID_NAME);
259 else
261 if(param == AL_EFFECT_TYPE)
262 *value = ALEffect->type;
263 else
265 /* Call the appropriate handler */
266 V(ALEffect,getParami)(Context, param, value);
270 ALCcontext_DecRef(Context);
273 AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *values)
275 ALCcontext *Context;
276 ALCdevice *Device;
277 ALeffect *ALEffect;
279 switch(param)
281 case AL_EFFECT_TYPE:
282 alGetEffecti(effect, param, values);
283 return;
286 Context = GetContextRef();
287 if(!Context) return;
289 Device = Context->Device;
290 if((ALEffect=LookupEffect(Device, effect)) == NULL)
291 alSetError(Context, AL_INVALID_NAME);
292 else
294 /* Call the appropriate handler */
295 V(ALEffect,getParamiv)(Context, param, values);
298 ALCcontext_DecRef(Context);
301 AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *value)
303 ALCcontext *Context;
304 ALCdevice *Device;
305 ALeffect *ALEffect;
307 Context = GetContextRef();
308 if(!Context) return;
310 Device = Context->Device;
311 if((ALEffect=LookupEffect(Device, effect)) == NULL)
312 alSetError(Context, AL_INVALID_NAME);
313 else
315 /* Call the appropriate handler */
316 V(ALEffect,getParamf)(Context, param, value);
319 ALCcontext_DecRef(Context);
322 AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *values)
324 ALCcontext *Context;
325 ALCdevice *Device;
326 ALeffect *ALEffect;
328 Context = GetContextRef();
329 if(!Context) return;
331 Device = Context->Device;
332 if((ALEffect=LookupEffect(Device, effect)) == NULL)
333 alSetError(Context, AL_INVALID_NAME);
334 else
336 /* Call the appropriate handler */
337 V(ALEffect,getParamfv)(Context, param, values);
340 ALCcontext_DecRef(Context);
344 ALenum InitEffect(ALeffect *effect)
346 InitEffectParams(effect, AL_EFFECT_NULL);
347 return AL_NO_ERROR;
350 ALvoid ReleaseALEffects(ALCdevice *device)
352 ALsizei i;
353 for(i = 0;i < device->EffectMap.size;i++)
355 ALeffect *temp = device->EffectMap.array[i].value;
356 device->EffectMap.array[i].value = NULL;
358 // Release effect structure
359 FreeThunkEntry(temp->id);
360 memset(temp, 0, sizeof(ALeffect));
361 free(temp);
366 static void InitEffectParams(ALeffect *effect, ALenum type)
368 switch(type)
370 case AL_EFFECT_EAXREVERB:
371 effect->Props.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY;
372 effect->Props.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION;
373 effect->Props.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN;
374 effect->Props.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF;
375 effect->Props.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF;
376 effect->Props.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME;
377 effect->Props.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO;
378 effect->Props.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO;
379 effect->Props.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN;
380 effect->Props.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY;
381 effect->Props.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
382 effect->Props.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
383 effect->Props.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
384 effect->Props.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN;
385 effect->Props.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY;
386 effect->Props.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
387 effect->Props.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
388 effect->Props.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
389 effect->Props.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME;
390 effect->Props.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH;
391 effect->Props.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME;
392 effect->Props.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH;
393 effect->Props.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
394 effect->Props.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE;
395 effect->Props.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE;
396 effect->Props.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
397 effect->Props.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT;
398 SET_VTABLE1(ALeaxreverb, effect);
399 break;
400 case AL_EFFECT_REVERB:
401 effect->Props.Reverb.Density = AL_REVERB_DEFAULT_DENSITY;
402 effect->Props.Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION;
403 effect->Props.Reverb.Gain = AL_REVERB_DEFAULT_GAIN;
404 effect->Props.Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF;
405 effect->Props.Reverb.GainLF = 1.0f;
406 effect->Props.Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME;
407 effect->Props.Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO;
408 effect->Props.Reverb.DecayLFRatio = 1.0f;
409 effect->Props.Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN;
410 effect->Props.Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY;
411 effect->Props.Reverb.ReflectionsPan[0] = 0.0f;
412 effect->Props.Reverb.ReflectionsPan[1] = 0.0f;
413 effect->Props.Reverb.ReflectionsPan[2] = 0.0f;
414 effect->Props.Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN;
415 effect->Props.Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY;
416 effect->Props.Reverb.LateReverbPan[0] = 0.0f;
417 effect->Props.Reverb.LateReverbPan[1] = 0.0f;
418 effect->Props.Reverb.LateReverbPan[2] = 0.0f;
419 effect->Props.Reverb.EchoTime = 0.25f;
420 effect->Props.Reverb.EchoDepth = 0.0f;
421 effect->Props.Reverb.ModulationTime = 0.25f;
422 effect->Props.Reverb.ModulationDepth = 0.0f;
423 effect->Props.Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
424 effect->Props.Reverb.HFReference = 5000.0f;
425 effect->Props.Reverb.LFReference = 250.0f;
426 effect->Props.Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
427 effect->Props.Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT;
428 SET_VTABLE1(ALreverb, effect);
429 break;
430 case AL_EFFECT_AUTOWAH:
431 effect->Props.Autowah.AttackTime = AL_AUTOWAH_DEFAULT_ATTACK_TIME;
432 effect->Props.Autowah.PeakGain = AL_AUTOWAH_DEFAULT_PEAK_GAIN;
433 effect->Props.Autowah.ReleaseTime = AL_AUTOWAH_DEFAULT_RELEASE_TIME;
434 effect->Props.Autowah.Resonance = AL_AUTOWAH_DEFAULT_RESONANCE;
435 SET_VTABLE1(ALautowah, effect);
436 break;
437 case AL_EFFECT_CHORUS:
438 effect->Props.Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM;
439 effect->Props.Chorus.Phase = AL_CHORUS_DEFAULT_PHASE;
440 effect->Props.Chorus.Rate = AL_CHORUS_DEFAULT_RATE;
441 effect->Props.Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH;
442 effect->Props.Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK;
443 effect->Props.Chorus.Delay = AL_CHORUS_DEFAULT_DELAY;
444 SET_VTABLE1(ALchorus, effect);
445 break;
446 case AL_EFFECT_COMPRESSOR:
447 effect->Props.Compressor.OnOff = AL_COMPRESSOR_DEFAULT_ONOFF;
448 SET_VTABLE1(ALcompressor, effect);
449 break;
450 case AL_EFFECT_DISTORTION:
451 effect->Props.Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE;
452 effect->Props.Distortion.Gain = AL_DISTORTION_DEFAULT_GAIN;
453 effect->Props.Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF;
454 effect->Props.Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER;
455 effect->Props.Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH;
456 SET_VTABLE1(ALdistortion, effect);
457 break;
458 case AL_EFFECT_ECHO:
459 effect->Props.Echo.Delay = AL_ECHO_DEFAULT_DELAY;
460 effect->Props.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY;
461 effect->Props.Echo.Damping = AL_ECHO_DEFAULT_DAMPING;
462 effect->Props.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK;
463 effect->Props.Echo.Spread = AL_ECHO_DEFAULT_SPREAD;
464 SET_VTABLE1(ALecho, effect);
465 break;
466 case AL_EFFECT_EQUALIZER:
467 effect->Props.Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF;
468 effect->Props.Equalizer.LowGain = AL_EQUALIZER_DEFAULT_LOW_GAIN;
469 effect->Props.Equalizer.Mid1Center = AL_EQUALIZER_DEFAULT_MID1_CENTER;
470 effect->Props.Equalizer.Mid1Gain = AL_EQUALIZER_DEFAULT_MID1_GAIN;
471 effect->Props.Equalizer.Mid1Width = AL_EQUALIZER_DEFAULT_MID1_WIDTH;
472 effect->Props.Equalizer.Mid2Center = AL_EQUALIZER_DEFAULT_MID2_CENTER;
473 effect->Props.Equalizer.Mid2Gain = AL_EQUALIZER_DEFAULT_MID2_GAIN;
474 effect->Props.Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH;
475 effect->Props.Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF;
476 effect->Props.Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN;
477 SET_VTABLE1(ALequalizer, effect);
478 break;
479 case AL_EFFECT_FLANGER:
480 effect->Props.Flanger.Waveform = AL_FLANGER_DEFAULT_WAVEFORM;
481 effect->Props.Flanger.Phase = AL_FLANGER_DEFAULT_PHASE;
482 effect->Props.Flanger.Rate = AL_FLANGER_DEFAULT_RATE;
483 effect->Props.Flanger.Depth = AL_FLANGER_DEFAULT_DEPTH;
484 effect->Props.Flanger.Feedback = AL_FLANGER_DEFAULT_FEEDBACK;
485 effect->Props.Flanger.Delay = AL_FLANGER_DEFAULT_DELAY;
486 SET_VTABLE1(ALflanger, effect);
487 break;
488 case AL_EFFECT_RING_MODULATOR:
489 effect->Props.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
490 effect->Props.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
491 effect->Props.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
492 SET_VTABLE1(ALmodulator, effect);
493 break;
494 case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT:
495 case AL_EFFECT_DEDICATED_DIALOGUE:
496 effect->Props.Dedicated.Gain = 1.0f;
497 SET_VTABLE1(ALdedicated, effect);
498 break;
499 default:
500 SET_VTABLE1(ALnull, effect);
501 break;
503 effect->type = type;
507 #include "AL/efx-presets.h"
509 #define DECL(x) { #x, EFX_REVERB_PRESET_##x }
510 static const struct {
511 const char name[32];
512 EFXEAXREVERBPROPERTIES props;
513 } reverblist[] = {
514 DECL(GENERIC),
515 DECL(PADDEDCELL),
516 DECL(ROOM),
517 DECL(BATHROOM),
518 DECL(LIVINGROOM),
519 DECL(STONEROOM),
520 DECL(AUDITORIUM),
521 DECL(CONCERTHALL),
522 DECL(CAVE),
523 DECL(ARENA),
524 DECL(HANGAR),
525 DECL(CARPETEDHALLWAY),
526 DECL(HALLWAY),
527 DECL(STONECORRIDOR),
528 DECL(ALLEY),
529 DECL(FOREST),
530 DECL(CITY),
531 DECL(MOUNTAINS),
532 DECL(QUARRY),
533 DECL(PLAIN),
534 DECL(PARKINGLOT),
535 DECL(SEWERPIPE),
536 DECL(UNDERWATER),
537 DECL(DRUGGED),
538 DECL(DIZZY),
539 DECL(PSYCHOTIC),
541 DECL(CASTLE_SMALLROOM),
542 DECL(CASTLE_SHORTPASSAGE),
543 DECL(CASTLE_MEDIUMROOM),
544 DECL(CASTLE_LARGEROOM),
545 DECL(CASTLE_LONGPASSAGE),
546 DECL(CASTLE_HALL),
547 DECL(CASTLE_CUPBOARD),
548 DECL(CASTLE_COURTYARD),
549 DECL(CASTLE_ALCOVE),
551 DECL(FACTORY_SMALLROOM),
552 DECL(FACTORY_SHORTPASSAGE),
553 DECL(FACTORY_MEDIUMROOM),
554 DECL(FACTORY_LARGEROOM),
555 DECL(FACTORY_LONGPASSAGE),
556 DECL(FACTORY_HALL),
557 DECL(FACTORY_CUPBOARD),
558 DECL(FACTORY_COURTYARD),
559 DECL(FACTORY_ALCOVE),
561 DECL(ICEPALACE_SMALLROOM),
562 DECL(ICEPALACE_SHORTPASSAGE),
563 DECL(ICEPALACE_MEDIUMROOM),
564 DECL(ICEPALACE_LARGEROOM),
565 DECL(ICEPALACE_LONGPASSAGE),
566 DECL(ICEPALACE_HALL),
567 DECL(ICEPALACE_CUPBOARD),
568 DECL(ICEPALACE_COURTYARD),
569 DECL(ICEPALACE_ALCOVE),
571 DECL(SPACESTATION_SMALLROOM),
572 DECL(SPACESTATION_SHORTPASSAGE),
573 DECL(SPACESTATION_MEDIUMROOM),
574 DECL(SPACESTATION_LARGEROOM),
575 DECL(SPACESTATION_LONGPASSAGE),
576 DECL(SPACESTATION_HALL),
577 DECL(SPACESTATION_CUPBOARD),
578 DECL(SPACESTATION_ALCOVE),
580 DECL(WOODEN_SMALLROOM),
581 DECL(WOODEN_SHORTPASSAGE),
582 DECL(WOODEN_MEDIUMROOM),
583 DECL(WOODEN_LARGEROOM),
584 DECL(WOODEN_LONGPASSAGE),
585 DECL(WOODEN_HALL),
586 DECL(WOODEN_CUPBOARD),
587 DECL(WOODEN_COURTYARD),
588 DECL(WOODEN_ALCOVE),
590 DECL(SPORT_EMPTYSTADIUM),
591 DECL(SPORT_SQUASHCOURT),
592 DECL(SPORT_SMALLSWIMMINGPOOL),
593 DECL(SPORT_LARGESWIMMINGPOOL),
594 DECL(SPORT_GYMNASIUM),
595 DECL(SPORT_FULLSTADIUM),
596 DECL(SPORT_STADIUMTANNOY),
598 DECL(PREFAB_WORKSHOP),
599 DECL(PREFAB_SCHOOLROOM),
600 DECL(PREFAB_PRACTISEROOM),
601 DECL(PREFAB_OUTHOUSE),
602 DECL(PREFAB_CARAVAN),
604 DECL(DOME_TOMB),
605 DECL(PIPE_SMALL),
606 DECL(DOME_SAINTPAULS),
607 DECL(PIPE_LONGTHIN),
608 DECL(PIPE_LARGE),
609 DECL(PIPE_RESONANT),
611 DECL(OUTDOORS_BACKYARD),
612 DECL(OUTDOORS_ROLLINGPLAINS),
613 DECL(OUTDOORS_DEEPCANYON),
614 DECL(OUTDOORS_CREEK),
615 DECL(OUTDOORS_VALLEY),
617 DECL(MOOD_HEAVEN),
618 DECL(MOOD_HELL),
619 DECL(MOOD_MEMORY),
621 DECL(DRIVING_COMMENTATOR),
622 DECL(DRIVING_PITGARAGE),
623 DECL(DRIVING_INCAR_RACER),
624 DECL(DRIVING_INCAR_SPORTS),
625 DECL(DRIVING_INCAR_LUXURY),
626 DECL(DRIVING_FULLGRANDSTAND),
627 DECL(DRIVING_EMPTYGRANDSTAND),
628 DECL(DRIVING_TUNNEL),
630 DECL(CITY_STREETS),
631 DECL(CITY_SUBWAY),
632 DECL(CITY_MUSEUM),
633 DECL(CITY_LIBRARY),
634 DECL(CITY_UNDERPASS),
635 DECL(CITY_ABANDONED),
637 DECL(DUSTYROOM),
638 DECL(CHAPEL),
639 DECL(SMALLWATERROOM),
641 #undef DECL
643 ALvoid LoadReverbPreset(const char *name, ALeffect *effect)
645 size_t i;
647 if(strcasecmp(name, "NONE") == 0)
649 InitEffectParams(effect, AL_EFFECT_NULL);
650 TRACE("Loading reverb '%s'\n", "NONE");
651 return;
654 if(!DisabledEffects[EAXREVERB])
655 InitEffectParams(effect, AL_EFFECT_EAXREVERB);
656 else if(!DisabledEffects[REVERB])
657 InitEffectParams(effect, AL_EFFECT_REVERB);
658 else
659 InitEffectParams(effect, AL_EFFECT_NULL);
660 for(i = 0;i < COUNTOF(reverblist);i++)
662 const EFXEAXREVERBPROPERTIES *props;
664 if(strcasecmp(name, reverblist[i].name) != 0)
665 continue;
667 TRACE("Loading reverb '%s'\n", reverblist[i].name);
668 props = &reverblist[i].props;
669 effect->Props.Reverb.Density = props->flDensity;
670 effect->Props.Reverb.Diffusion = props->flDiffusion;
671 effect->Props.Reverb.Gain = props->flGain;
672 effect->Props.Reverb.GainHF = props->flGainHF;
673 effect->Props.Reverb.GainLF = props->flGainLF;
674 effect->Props.Reverb.DecayTime = props->flDecayTime;
675 effect->Props.Reverb.DecayHFRatio = props->flDecayHFRatio;
676 effect->Props.Reverb.DecayLFRatio = props->flDecayLFRatio;
677 effect->Props.Reverb.ReflectionsGain = props->flReflectionsGain;
678 effect->Props.Reverb.ReflectionsDelay = props->flReflectionsDelay;
679 effect->Props.Reverb.ReflectionsPan[0] = props->flReflectionsPan[0];
680 effect->Props.Reverb.ReflectionsPan[1] = props->flReflectionsPan[1];
681 effect->Props.Reverb.ReflectionsPan[2] = props->flReflectionsPan[2];
682 effect->Props.Reverb.LateReverbGain = props->flLateReverbGain;
683 effect->Props.Reverb.LateReverbDelay = props->flLateReverbDelay;
684 effect->Props.Reverb.LateReverbPan[0] = props->flLateReverbPan[0];
685 effect->Props.Reverb.LateReverbPan[1] = props->flLateReverbPan[1];
686 effect->Props.Reverb.LateReverbPan[2] = props->flLateReverbPan[2];
687 effect->Props.Reverb.EchoTime = props->flEchoTime;
688 effect->Props.Reverb.EchoDepth = props->flEchoDepth;
689 effect->Props.Reverb.ModulationTime = props->flModulationTime;
690 effect->Props.Reverb.ModulationDepth = props->flModulationDepth;
691 effect->Props.Reverb.AirAbsorptionGainHF = props->flAirAbsorptionGainHF;
692 effect->Props.Reverb.HFReference = props->flHFReference;
693 effect->Props.Reverb.LFReference = props->flLFReference;
694 effect->Props.Reverb.RoomRolloffFactor = props->flRoomRolloffFactor;
695 effect->Props.Reverb.DecayHFLimit = props->iDecayHFLimit;
696 return;
699 WARN("Reverb preset '%s' not found\n", name);