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
34 extern inline void LockEffectList(ALCdevice
*device
);
35 extern inline void UnlockEffectList(ALCdevice
*device
);
36 extern inline ALboolean
IsReverbEffect(ALenum type
);
38 const struct EffectList EffectList
[EFFECTLIST_SIZE
] = {
39 { "eaxreverb", EAXREVERB_EFFECT
, AL_EFFECT_EAXREVERB
},
40 { "reverb", REVERB_EFFECT
, AL_EFFECT_REVERB
},
41 { "chorus", CHORUS_EFFECT
, AL_EFFECT_CHORUS
},
42 { "compressor", COMPRESSOR_EFFECT
, AL_EFFECT_COMPRESSOR
},
43 { "distortion", DISTORTION_EFFECT
, AL_EFFECT_DISTORTION
},
44 { "echo", ECHO_EFFECT
, AL_EFFECT_ECHO
},
45 { "equalizer", EQUALIZER_EFFECT
, AL_EFFECT_EQUALIZER
},
46 { "flanger", FLANGER_EFFECT
, AL_EFFECT_FLANGER
},
47 { "modulator", MODULATOR_EFFECT
, AL_EFFECT_RING_MODULATOR
},
48 { "pshifter", PSHIFTER_EFFECT
, AL_EFFECT_PITCH_SHIFTER
},
49 { "dedicated", DEDICATED_EFFECT
, AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT
},
50 { "dedicated", DEDICATED_EFFECT
, AL_EFFECT_DEDICATED_DIALOGUE
},
53 ALboolean DisabledEffects
[MAX_EFFECTS
];
55 static ALeffect
*AllocEffect(ALCcontext
*context
);
56 static void FreeEffect(ALCdevice
*device
, ALeffect
*effect
);
57 static void InitEffectParams(ALeffect
*effect
, ALenum type
);
59 static inline ALeffect
*LookupEffect(ALCdevice
*device
, ALuint id
)
61 EffectSubList
*sublist
;
62 ALuint lidx
= (id
-1) >> 6;
63 ALsizei slidx
= (id
-1) & 0x3f;
65 if(UNLIKELY(lidx
>= VECTOR_SIZE(device
->EffectList
)))
67 sublist
= &VECTOR_ELEM(device
->EffectList
, lidx
);
68 if(UNLIKELY(sublist
->FreeMask
& (U64(1)<<slidx
)))
70 return sublist
->Effects
+ slidx
;
74 AL_API ALvoid AL_APIENTRY
alGenEffects(ALsizei n
, ALuint
*effects
)
79 context
= GetContextRef();
83 alSetError(context
, AL_INVALID_VALUE
, "Generating %d effects", n
);
84 else for(cur
= 0;cur
< n
;cur
++)
86 ALeffect
*effect
= AllocEffect(context
);
89 alDeleteEffects(cur
, effects
);
92 effects
[cur
] = effect
->id
;
95 ALCcontext_DecRef(context
);
98 AL_API ALvoid AL_APIENTRY
alDeleteEffects(ALsizei n
, const ALuint
*effects
)
105 context
= GetContextRef();
108 device
= context
->Device
;
109 LockEffectList(device
);
111 SETERR_GOTO(context
, AL_INVALID_VALUE
, done
, "Deleting %d effects", n
);
114 if(effects
[i
] && LookupEffect(device
, effects
[i
]) == NULL
)
115 SETERR_GOTO(context
, AL_INVALID_NAME
, done
, "Invalid effect ID %u", effects
[i
]);
119 if((effect
=LookupEffect(device
, effects
[i
])) != NULL
)
120 FreeEffect(device
, effect
);
124 UnlockEffectList(device
);
125 ALCcontext_DecRef(context
);
128 AL_API ALboolean AL_APIENTRY
alIsEffect(ALuint effect
)
133 Context
= GetContextRef();
134 if(!Context
) return AL_FALSE
;
136 LockEffectList(Context
->Device
);
137 result
= ((!effect
|| LookupEffect(Context
->Device
, effect
)) ?
139 UnlockEffectList(Context
->Device
);
141 ALCcontext_DecRef(Context
);
146 AL_API ALvoid AL_APIENTRY
alEffecti(ALuint effect
, ALenum param
, ALint value
)
152 Context
= GetContextRef();
155 Device
= Context
->Device
;
156 LockEffectList(Device
);
157 if((ALEffect
=LookupEffect(Device
, effect
)) == NULL
)
158 alSetError(Context
, AL_INVALID_NAME
, "Invalid effect ID %u", effect
);
161 if(param
== AL_EFFECT_TYPE
)
163 ALboolean isOk
= (value
== AL_EFFECT_NULL
);
165 for(i
= 0;!isOk
&& i
< EFFECTLIST_SIZE
;i
++)
167 if(value
== EffectList
[i
].val
&&
168 !DisabledEffects
[EffectList
[i
].type
])
173 InitEffectParams(ALEffect
, value
);
175 alSetError(Context
, AL_INVALID_VALUE
, "Effect type 0x%04x not supported", value
);
179 /* Call the appropriate handler */
180 ALeffect_setParami(ALEffect
, Context
, param
, value
);
183 UnlockEffectList(Device
);
185 ALCcontext_DecRef(Context
);
188 AL_API ALvoid AL_APIENTRY
alEffectiv(ALuint effect
, ALenum param
, const ALint
*values
)
197 alEffecti(effect
, param
, values
[0]);
201 Context
= GetContextRef();
204 Device
= Context
->Device
;
205 LockEffectList(Device
);
206 if((ALEffect
=LookupEffect(Device
, effect
)) == NULL
)
207 alSetError(Context
, AL_INVALID_NAME
, "Invalid effect ID %u", effect
);
210 /* Call the appropriate handler */
211 ALeffect_setParamiv(ALEffect
, Context
, param
, values
);
213 UnlockEffectList(Device
);
215 ALCcontext_DecRef(Context
);
218 AL_API ALvoid AL_APIENTRY
alEffectf(ALuint effect
, ALenum param
, ALfloat value
)
224 Context
= GetContextRef();
227 Device
= Context
->Device
;
228 LockEffectList(Device
);
229 if((ALEffect
=LookupEffect(Device
, effect
)) == NULL
)
230 alSetError(Context
, AL_INVALID_NAME
, "Invalid effect ID %u", effect
);
233 /* Call the appropriate handler */
234 ALeffect_setParamf(ALEffect
, Context
, param
, value
);
236 UnlockEffectList(Device
);
238 ALCcontext_DecRef(Context
);
241 AL_API ALvoid AL_APIENTRY
alEffectfv(ALuint effect
, ALenum param
, const ALfloat
*values
)
247 Context
= GetContextRef();
250 Device
= Context
->Device
;
251 LockEffectList(Device
);
252 if((ALEffect
=LookupEffect(Device
, effect
)) == NULL
)
253 alSetError(Context
, AL_INVALID_NAME
, "Invalid effect ID %u", effect
);
256 /* Call the appropriate handler */
257 ALeffect_setParamfv(ALEffect
, Context
, param
, values
);
259 UnlockEffectList(Device
);
261 ALCcontext_DecRef(Context
);
264 AL_API ALvoid AL_APIENTRY
alGetEffecti(ALuint effect
, ALenum param
, ALint
*value
)
270 Context
= GetContextRef();
273 Device
= Context
->Device
;
274 LockEffectList(Device
);
275 if((ALEffect
=LookupEffect(Device
, effect
)) == NULL
)
276 alSetError(Context
, AL_INVALID_NAME
, "Invalid effect ID %u", effect
);
279 if(param
== AL_EFFECT_TYPE
)
280 *value
= ALEffect
->type
;
283 /* Call the appropriate handler */
284 ALeffect_getParami(ALEffect
, Context
, param
, value
);
287 UnlockEffectList(Device
);
289 ALCcontext_DecRef(Context
);
292 AL_API ALvoid AL_APIENTRY
alGetEffectiv(ALuint effect
, ALenum param
, ALint
*values
)
301 alGetEffecti(effect
, param
, values
);
305 Context
= GetContextRef();
308 Device
= Context
->Device
;
309 LockEffectList(Device
);
310 if((ALEffect
=LookupEffect(Device
, effect
)) == NULL
)
311 alSetError(Context
, AL_INVALID_NAME
, "Invalid effect ID %u", effect
);
314 /* Call the appropriate handler */
315 ALeffect_getParamiv(ALEffect
, Context
, param
, values
);
317 UnlockEffectList(Device
);
319 ALCcontext_DecRef(Context
);
322 AL_API ALvoid AL_APIENTRY
alGetEffectf(ALuint effect
, ALenum param
, ALfloat
*value
)
328 Context
= GetContextRef();
331 Device
= Context
->Device
;
332 LockEffectList(Device
);
333 if((ALEffect
=LookupEffect(Device
, effect
)) == NULL
)
334 alSetError(Context
, AL_INVALID_NAME
, "Invalid effect ID %u", effect
);
337 /* Call the appropriate handler */
338 ALeffect_getParamf(ALEffect
, Context
, param
, value
);
340 UnlockEffectList(Device
);
342 ALCcontext_DecRef(Context
);
345 AL_API ALvoid AL_APIENTRY
alGetEffectfv(ALuint effect
, ALenum param
, ALfloat
*values
)
351 Context
= GetContextRef();
354 Device
= Context
->Device
;
355 LockEffectList(Device
);
356 if((ALEffect
=LookupEffect(Device
, effect
)) == NULL
)
357 alSetError(Context
, AL_INVALID_NAME
, "Invalid effect ID %u", effect
);
360 /* Call the appropriate handler */
361 ALeffect_getParamfv(ALEffect
, Context
, param
, values
);
363 UnlockEffectList(Device
);
365 ALCcontext_DecRef(Context
);
369 void InitEffect(ALeffect
*effect
)
371 InitEffectParams(effect
, AL_EFFECT_NULL
);
374 static ALeffect
*AllocEffect(ALCcontext
*context
)
376 ALCdevice
*device
= context
->Device
;
377 EffectSubList
*sublist
, *subend
;
378 ALeffect
*effect
= NULL
;
382 almtx_lock(&device
->EffectLock
);
383 sublist
= VECTOR_BEGIN(device
->EffectList
);
384 subend
= VECTOR_END(device
->EffectList
);
385 for(;sublist
!= subend
;++sublist
)
387 if(sublist
->FreeMask
)
389 slidx
= CTZ64(sublist
->FreeMask
);
390 effect
= sublist
->Effects
+ slidx
;
395 if(UNLIKELY(!effect
))
397 const EffectSubList empty_sublist
= { 0, NULL
};
398 /* Don't allocate so many list entries that the 32-bit ID could
401 if(UNLIKELY(VECTOR_SIZE(device
->EffectList
) >= 1<<25))
403 almtx_unlock(&device
->EffectLock
);
404 alSetError(context
, AL_OUT_OF_MEMORY
, "Too many effects allocated");
407 lidx
= (ALsizei
)VECTOR_SIZE(device
->EffectList
);
408 VECTOR_PUSH_BACK(device
->EffectList
, empty_sublist
);
409 sublist
= &VECTOR_BACK(device
->EffectList
);
410 sublist
->FreeMask
= ~U64(0);
411 sublist
->Effects
= al_calloc(16, sizeof(ALeffect
)*64);
412 if(UNLIKELY(!sublist
->Effects
))
414 VECTOR_POP_BACK(device
->EffectList
);
415 almtx_unlock(&device
->EffectLock
);
416 alSetError(context
, AL_OUT_OF_MEMORY
, "Failed to allocate effect batch");
421 effect
= sublist
->Effects
+ slidx
;
424 memset(effect
, 0, sizeof(*effect
));
425 InitEffectParams(effect
, AL_EFFECT_NULL
);
427 /* Add 1 to avoid effect ID 0. */
428 effect
->id
= ((lidx
<<6) | slidx
) + 1;
430 sublist
->FreeMask
&= ~(U64(1)<<slidx
);
431 almtx_unlock(&device
->EffectLock
);
436 static void FreeEffect(ALCdevice
*device
, ALeffect
*effect
)
438 ALuint id
= effect
->id
- 1;
439 ALsizei lidx
= id
>> 6;
440 ALsizei slidx
= id
& 0x3f;
442 memset(effect
, 0, sizeof(*effect
));
444 VECTOR_ELEM(device
->EffectList
, lidx
).FreeMask
|= U64(1) << slidx
;
447 void ReleaseALEffects(ALCdevice
*device
)
449 EffectSubList
*sublist
= VECTOR_BEGIN(device
->EffectList
);
450 EffectSubList
*subend
= VECTOR_END(device
->EffectList
);
452 for(;sublist
!= subend
;++sublist
)
454 ALuint64 usemask
= ~sublist
->FreeMask
;
457 ALsizei idx
= CTZ64(usemask
);
458 ALeffect
*effect
= sublist
->Effects
+ idx
;
460 memset(effect
, 0, sizeof(*effect
));
463 usemask
&= ~(U64(1) << idx
);
465 sublist
->FreeMask
= ~usemask
;
468 WARN("(%p) Deleted "SZFMT
" Effect%s\n", device
, leftover
, (leftover
==1)?"":"s");
472 static void InitEffectParams(ALeffect
*effect
, ALenum type
)
476 case AL_EFFECT_EAXREVERB
:
477 effect
->Props
.Reverb
.Density
= AL_EAXREVERB_DEFAULT_DENSITY
;
478 effect
->Props
.Reverb
.Diffusion
= AL_EAXREVERB_DEFAULT_DIFFUSION
;
479 effect
->Props
.Reverb
.Gain
= AL_EAXREVERB_DEFAULT_GAIN
;
480 effect
->Props
.Reverb
.GainHF
= AL_EAXREVERB_DEFAULT_GAINHF
;
481 effect
->Props
.Reverb
.GainLF
= AL_EAXREVERB_DEFAULT_GAINLF
;
482 effect
->Props
.Reverb
.DecayTime
= AL_EAXREVERB_DEFAULT_DECAY_TIME
;
483 effect
->Props
.Reverb
.DecayHFRatio
= AL_EAXREVERB_DEFAULT_DECAY_HFRATIO
;
484 effect
->Props
.Reverb
.DecayLFRatio
= AL_EAXREVERB_DEFAULT_DECAY_LFRATIO
;
485 effect
->Props
.Reverb
.ReflectionsGain
= AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN
;
486 effect
->Props
.Reverb
.ReflectionsDelay
= AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY
;
487 effect
->Props
.Reverb
.ReflectionsPan
[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
488 effect
->Props
.Reverb
.ReflectionsPan
[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
489 effect
->Props
.Reverb
.ReflectionsPan
[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
490 effect
->Props
.Reverb
.LateReverbGain
= AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN
;
491 effect
->Props
.Reverb
.LateReverbDelay
= AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY
;
492 effect
->Props
.Reverb
.LateReverbPan
[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
493 effect
->Props
.Reverb
.LateReverbPan
[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
494 effect
->Props
.Reverb
.LateReverbPan
[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
495 effect
->Props
.Reverb
.EchoTime
= AL_EAXREVERB_DEFAULT_ECHO_TIME
;
496 effect
->Props
.Reverb
.EchoDepth
= AL_EAXREVERB_DEFAULT_ECHO_DEPTH
;
497 effect
->Props
.Reverb
.ModulationTime
= AL_EAXREVERB_DEFAULT_MODULATION_TIME
;
498 effect
->Props
.Reverb
.ModulationDepth
= AL_EAXREVERB_DEFAULT_MODULATION_DEPTH
;
499 effect
->Props
.Reverb
.AirAbsorptionGainHF
= AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF
;
500 effect
->Props
.Reverb
.HFReference
= AL_EAXREVERB_DEFAULT_HFREFERENCE
;
501 effect
->Props
.Reverb
.LFReference
= AL_EAXREVERB_DEFAULT_LFREFERENCE
;
502 effect
->Props
.Reverb
.RoomRolloffFactor
= AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR
;
503 effect
->Props
.Reverb
.DecayHFLimit
= AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT
;
504 effect
->vtab
= &ALeaxreverb_vtable
;
506 case AL_EFFECT_REVERB
:
507 effect
->Props
.Reverb
.Density
= AL_REVERB_DEFAULT_DENSITY
;
508 effect
->Props
.Reverb
.Diffusion
= AL_REVERB_DEFAULT_DIFFUSION
;
509 effect
->Props
.Reverb
.Gain
= AL_REVERB_DEFAULT_GAIN
;
510 effect
->Props
.Reverb
.GainHF
= AL_REVERB_DEFAULT_GAINHF
;
511 effect
->Props
.Reverb
.GainLF
= 1.0f
;
512 effect
->Props
.Reverb
.DecayTime
= AL_REVERB_DEFAULT_DECAY_TIME
;
513 effect
->Props
.Reverb
.DecayHFRatio
= AL_REVERB_DEFAULT_DECAY_HFRATIO
;
514 effect
->Props
.Reverb
.DecayLFRatio
= 1.0f
;
515 effect
->Props
.Reverb
.ReflectionsGain
= AL_REVERB_DEFAULT_REFLECTIONS_GAIN
;
516 effect
->Props
.Reverb
.ReflectionsDelay
= AL_REVERB_DEFAULT_REFLECTIONS_DELAY
;
517 effect
->Props
.Reverb
.ReflectionsPan
[0] = 0.0f
;
518 effect
->Props
.Reverb
.ReflectionsPan
[1] = 0.0f
;
519 effect
->Props
.Reverb
.ReflectionsPan
[2] = 0.0f
;
520 effect
->Props
.Reverb
.LateReverbGain
= AL_REVERB_DEFAULT_LATE_REVERB_GAIN
;
521 effect
->Props
.Reverb
.LateReverbDelay
= AL_REVERB_DEFAULT_LATE_REVERB_DELAY
;
522 effect
->Props
.Reverb
.LateReverbPan
[0] = 0.0f
;
523 effect
->Props
.Reverb
.LateReverbPan
[1] = 0.0f
;
524 effect
->Props
.Reverb
.LateReverbPan
[2] = 0.0f
;
525 effect
->Props
.Reverb
.EchoTime
= 0.25f
;
526 effect
->Props
.Reverb
.EchoDepth
= 0.0f
;
527 effect
->Props
.Reverb
.ModulationTime
= 0.25f
;
528 effect
->Props
.Reverb
.ModulationDepth
= 0.0f
;
529 effect
->Props
.Reverb
.AirAbsorptionGainHF
= AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF
;
530 effect
->Props
.Reverb
.HFReference
= 5000.0f
;
531 effect
->Props
.Reverb
.LFReference
= 250.0f
;
532 effect
->Props
.Reverb
.RoomRolloffFactor
= AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR
;
533 effect
->Props
.Reverb
.DecayHFLimit
= AL_REVERB_DEFAULT_DECAY_HFLIMIT
;
534 effect
->vtab
= &ALreverb_vtable
;
536 case AL_EFFECT_CHORUS
:
537 effect
->Props
.Chorus
.Waveform
= AL_CHORUS_DEFAULT_WAVEFORM
;
538 effect
->Props
.Chorus
.Phase
= AL_CHORUS_DEFAULT_PHASE
;
539 effect
->Props
.Chorus
.Rate
= AL_CHORUS_DEFAULT_RATE
;
540 effect
->Props
.Chorus
.Depth
= AL_CHORUS_DEFAULT_DEPTH
;
541 effect
->Props
.Chorus
.Feedback
= AL_CHORUS_DEFAULT_FEEDBACK
;
542 effect
->Props
.Chorus
.Delay
= AL_CHORUS_DEFAULT_DELAY
;
543 effect
->vtab
= &ALchorus_vtable
;
545 case AL_EFFECT_COMPRESSOR
:
546 effect
->Props
.Compressor
.OnOff
= AL_COMPRESSOR_DEFAULT_ONOFF
;
547 effect
->vtab
= &ALcompressor_vtable
;
549 case AL_EFFECT_DISTORTION
:
550 effect
->Props
.Distortion
.Edge
= AL_DISTORTION_DEFAULT_EDGE
;
551 effect
->Props
.Distortion
.Gain
= AL_DISTORTION_DEFAULT_GAIN
;
552 effect
->Props
.Distortion
.LowpassCutoff
= AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF
;
553 effect
->Props
.Distortion
.EQCenter
= AL_DISTORTION_DEFAULT_EQCENTER
;
554 effect
->Props
.Distortion
.EQBandwidth
= AL_DISTORTION_DEFAULT_EQBANDWIDTH
;
555 effect
->vtab
= &ALdistortion_vtable
;
558 effect
->Props
.Echo
.Delay
= AL_ECHO_DEFAULT_DELAY
;
559 effect
->Props
.Echo
.LRDelay
= AL_ECHO_DEFAULT_LRDELAY
;
560 effect
->Props
.Echo
.Damping
= AL_ECHO_DEFAULT_DAMPING
;
561 effect
->Props
.Echo
.Feedback
= AL_ECHO_DEFAULT_FEEDBACK
;
562 effect
->Props
.Echo
.Spread
= AL_ECHO_DEFAULT_SPREAD
;
563 effect
->vtab
= &ALecho_vtable
;
565 case AL_EFFECT_EQUALIZER
:
566 effect
->Props
.Equalizer
.LowCutoff
= AL_EQUALIZER_DEFAULT_LOW_CUTOFF
;
567 effect
->Props
.Equalizer
.LowGain
= AL_EQUALIZER_DEFAULT_LOW_GAIN
;
568 effect
->Props
.Equalizer
.Mid1Center
= AL_EQUALIZER_DEFAULT_MID1_CENTER
;
569 effect
->Props
.Equalizer
.Mid1Gain
= AL_EQUALIZER_DEFAULT_MID1_GAIN
;
570 effect
->Props
.Equalizer
.Mid1Width
= AL_EQUALIZER_DEFAULT_MID1_WIDTH
;
571 effect
->Props
.Equalizer
.Mid2Center
= AL_EQUALIZER_DEFAULT_MID2_CENTER
;
572 effect
->Props
.Equalizer
.Mid2Gain
= AL_EQUALIZER_DEFAULT_MID2_GAIN
;
573 effect
->Props
.Equalizer
.Mid2Width
= AL_EQUALIZER_DEFAULT_MID2_WIDTH
;
574 effect
->Props
.Equalizer
.HighCutoff
= AL_EQUALIZER_DEFAULT_HIGH_CUTOFF
;
575 effect
->Props
.Equalizer
.HighGain
= AL_EQUALIZER_DEFAULT_HIGH_GAIN
;
576 effect
->vtab
= &ALequalizer_vtable
;
578 case AL_EFFECT_FLANGER
:
579 effect
->Props
.Chorus
.Waveform
= AL_FLANGER_DEFAULT_WAVEFORM
;
580 effect
->Props
.Chorus
.Phase
= AL_FLANGER_DEFAULT_PHASE
;
581 effect
->Props
.Chorus
.Rate
= AL_FLANGER_DEFAULT_RATE
;
582 effect
->Props
.Chorus
.Depth
= AL_FLANGER_DEFAULT_DEPTH
;
583 effect
->Props
.Chorus
.Feedback
= AL_FLANGER_DEFAULT_FEEDBACK
;
584 effect
->Props
.Chorus
.Delay
= AL_FLANGER_DEFAULT_DELAY
;
585 effect
->vtab
= &ALflanger_vtable
;
587 case AL_EFFECT_RING_MODULATOR
:
588 effect
->Props
.Modulator
.Frequency
= AL_RING_MODULATOR_DEFAULT_FREQUENCY
;
589 effect
->Props
.Modulator
.HighPassCutoff
= AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF
;
590 effect
->Props
.Modulator
.Waveform
= AL_RING_MODULATOR_DEFAULT_WAVEFORM
;
591 effect
->vtab
= &ALmodulator_vtable
;
593 case AL_EFFECT_PITCH_SHIFTER
:
594 effect
->Props
.Pshifter
.CoarseTune
= AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE
;
595 effect
->Props
.Pshifter
.FineTune
= AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE
;
596 effect
->vtab
= &ALpshifter_vtable
;
598 case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT
:
599 case AL_EFFECT_DEDICATED_DIALOGUE
:
600 effect
->Props
.Dedicated
.Gain
= 1.0f
;
601 effect
->vtab
= &ALdedicated_vtable
;
604 effect
->vtab
= &ALnull_vtable
;
611 #include "AL/efx-presets.h"
613 #define DECL(x) { #x, EFX_REVERB_PRESET_##x }
614 static const struct {
616 EFXEAXREVERBPROPERTIES props
;
629 DECL(CARPETEDHALLWAY
),
645 DECL(CASTLE_SMALLROOM
),
646 DECL(CASTLE_SHORTPASSAGE
),
647 DECL(CASTLE_MEDIUMROOM
),
648 DECL(CASTLE_LARGEROOM
),
649 DECL(CASTLE_LONGPASSAGE
),
651 DECL(CASTLE_CUPBOARD
),
652 DECL(CASTLE_COURTYARD
),
655 DECL(FACTORY_SMALLROOM
),
656 DECL(FACTORY_SHORTPASSAGE
),
657 DECL(FACTORY_MEDIUMROOM
),
658 DECL(FACTORY_LARGEROOM
),
659 DECL(FACTORY_LONGPASSAGE
),
661 DECL(FACTORY_CUPBOARD
),
662 DECL(FACTORY_COURTYARD
),
663 DECL(FACTORY_ALCOVE
),
665 DECL(ICEPALACE_SMALLROOM
),
666 DECL(ICEPALACE_SHORTPASSAGE
),
667 DECL(ICEPALACE_MEDIUMROOM
),
668 DECL(ICEPALACE_LARGEROOM
),
669 DECL(ICEPALACE_LONGPASSAGE
),
670 DECL(ICEPALACE_HALL
),
671 DECL(ICEPALACE_CUPBOARD
),
672 DECL(ICEPALACE_COURTYARD
),
673 DECL(ICEPALACE_ALCOVE
),
675 DECL(SPACESTATION_SMALLROOM
),
676 DECL(SPACESTATION_SHORTPASSAGE
),
677 DECL(SPACESTATION_MEDIUMROOM
),
678 DECL(SPACESTATION_LARGEROOM
),
679 DECL(SPACESTATION_LONGPASSAGE
),
680 DECL(SPACESTATION_HALL
),
681 DECL(SPACESTATION_CUPBOARD
),
682 DECL(SPACESTATION_ALCOVE
),
684 DECL(WOODEN_SMALLROOM
),
685 DECL(WOODEN_SHORTPASSAGE
),
686 DECL(WOODEN_MEDIUMROOM
),
687 DECL(WOODEN_LARGEROOM
),
688 DECL(WOODEN_LONGPASSAGE
),
690 DECL(WOODEN_CUPBOARD
),
691 DECL(WOODEN_COURTYARD
),
694 DECL(SPORT_EMPTYSTADIUM
),
695 DECL(SPORT_SQUASHCOURT
),
696 DECL(SPORT_SMALLSWIMMINGPOOL
),
697 DECL(SPORT_LARGESWIMMINGPOOL
),
698 DECL(SPORT_GYMNASIUM
),
699 DECL(SPORT_FULLSTADIUM
),
700 DECL(SPORT_STADIUMTANNOY
),
702 DECL(PREFAB_WORKSHOP
),
703 DECL(PREFAB_SCHOOLROOM
),
704 DECL(PREFAB_PRACTISEROOM
),
705 DECL(PREFAB_OUTHOUSE
),
706 DECL(PREFAB_CARAVAN
),
710 DECL(DOME_SAINTPAULS
),
715 DECL(OUTDOORS_BACKYARD
),
716 DECL(OUTDOORS_ROLLINGPLAINS
),
717 DECL(OUTDOORS_DEEPCANYON
),
718 DECL(OUTDOORS_CREEK
),
719 DECL(OUTDOORS_VALLEY
),
725 DECL(DRIVING_COMMENTATOR
),
726 DECL(DRIVING_PITGARAGE
),
727 DECL(DRIVING_INCAR_RACER
),
728 DECL(DRIVING_INCAR_SPORTS
),
729 DECL(DRIVING_INCAR_LUXURY
),
730 DECL(DRIVING_FULLGRANDSTAND
),
731 DECL(DRIVING_EMPTYGRANDSTAND
),
732 DECL(DRIVING_TUNNEL
),
738 DECL(CITY_UNDERPASS
),
739 DECL(CITY_ABANDONED
),
743 DECL(SMALLWATERROOM
),
747 void LoadReverbPreset(const char *name
, ALeffect
*effect
)
751 if(strcasecmp(name
, "NONE") == 0)
753 InitEffectParams(effect
, AL_EFFECT_NULL
);
754 TRACE("Loading reverb '%s'\n", "NONE");
758 if(!DisabledEffects
[EAXREVERB_EFFECT
])
759 InitEffectParams(effect
, AL_EFFECT_EAXREVERB
);
760 else if(!DisabledEffects
[REVERB_EFFECT
])
761 InitEffectParams(effect
, AL_EFFECT_REVERB
);
763 InitEffectParams(effect
, AL_EFFECT_NULL
);
764 for(i
= 0;i
< COUNTOF(reverblist
);i
++)
766 const EFXEAXREVERBPROPERTIES
*props
;
768 if(strcasecmp(name
, reverblist
[i
].name
) != 0)
771 TRACE("Loading reverb '%s'\n", reverblist
[i
].name
);
772 props
= &reverblist
[i
].props
;
773 effect
->Props
.Reverb
.Density
= props
->flDensity
;
774 effect
->Props
.Reverb
.Diffusion
= props
->flDiffusion
;
775 effect
->Props
.Reverb
.Gain
= props
->flGain
;
776 effect
->Props
.Reverb
.GainHF
= props
->flGainHF
;
777 effect
->Props
.Reverb
.GainLF
= props
->flGainLF
;
778 effect
->Props
.Reverb
.DecayTime
= props
->flDecayTime
;
779 effect
->Props
.Reverb
.DecayHFRatio
= props
->flDecayHFRatio
;
780 effect
->Props
.Reverb
.DecayLFRatio
= props
->flDecayLFRatio
;
781 effect
->Props
.Reverb
.ReflectionsGain
= props
->flReflectionsGain
;
782 effect
->Props
.Reverb
.ReflectionsDelay
= props
->flReflectionsDelay
;
783 effect
->Props
.Reverb
.ReflectionsPan
[0] = props
->flReflectionsPan
[0];
784 effect
->Props
.Reverb
.ReflectionsPan
[1] = props
->flReflectionsPan
[1];
785 effect
->Props
.Reverb
.ReflectionsPan
[2] = props
->flReflectionsPan
[2];
786 effect
->Props
.Reverb
.LateReverbGain
= props
->flLateReverbGain
;
787 effect
->Props
.Reverb
.LateReverbDelay
= props
->flLateReverbDelay
;
788 effect
->Props
.Reverb
.LateReverbPan
[0] = props
->flLateReverbPan
[0];
789 effect
->Props
.Reverb
.LateReverbPan
[1] = props
->flLateReverbPan
[1];
790 effect
->Props
.Reverb
.LateReverbPan
[2] = props
->flLateReverbPan
[2];
791 effect
->Props
.Reverb
.EchoTime
= props
->flEchoTime
;
792 effect
->Props
.Reverb
.EchoDepth
= props
->flEchoDepth
;
793 effect
->Props
.Reverb
.ModulationTime
= props
->flModulationTime
;
794 effect
->Props
.Reverb
.ModulationDepth
= props
->flModulationDepth
;
795 effect
->Props
.Reverb
.AirAbsorptionGainHF
= props
->flAirAbsorptionGainHF
;
796 effect
->Props
.Reverb
.HFReference
= props
->flHFReference
;
797 effect
->Props
.Reverb
.LFReference
= props
->flLFReference
;
798 effect
->Props
.Reverb
.RoomRolloffFactor
= props
->flRoomRolloffFactor
;
799 effect
->Props
.Reverb
.DecayHFLimit
= props
->iDecayHFLimit
;
803 WARN("Reverb preset '%s' not found\n", name
);