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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
34 ALboolean DisabledEffects
[MAX_EFFECTS
];
37 static void InitEffectParams(ALeffect
*effect
, ALenum type
);
39 #define LookupEffect(m, k) ((ALeffect*)LookupUIntMapKey(&(m), (k)))
41 AL_API ALvoid AL_APIENTRY
alGenEffects(ALsizei n
, ALuint
*effects
)
46 Context
= GetContextSuspended();
49 if(n
< 0 || IsBadWritePtr((void*)effects
, n
* sizeof(ALuint
)))
50 alSetError(Context
, AL_INVALID_VALUE
);
53 ALCdevice
*device
= Context
->Device
;
58 ALeffect
*effect
= calloc(1, sizeof(ALeffect
));
61 alSetError(Context
, AL_OUT_OF_MEMORY
);
62 alDeleteEffects(i
, effects
);
66 effect
->effect
= ALTHUNK_ADDENTRY(effect
);
67 err
= InsertUIntMapEntry(&device
->EffectMap
, effect
->effect
, effect
);
68 if(err
!= AL_NO_ERROR
)
70 ALTHUNK_REMOVEENTRY(effect
->effect
);
71 memset(effect
, 0, sizeof(ALeffect
));
74 alSetError(Context
, err
);
75 alDeleteEffects(i
, effects
);
79 effects
[i
++] = effect
->effect
;
80 InitEffectParams(effect
, AL_EFFECT_NULL
);
84 ProcessContext(Context
);
87 AL_API ALvoid AL_APIENTRY
alDeleteEffects(ALsizei n
, ALuint
*effects
)
95 Context
= GetContextSuspended();
99 device
= Context
->Device
;
101 alSetError(Context
, AL_INVALID_VALUE
);
105 // Check that all effects are valid
111 if(LookupEffect(device
->EffectMap
, effects
[i
]) == NULL
)
113 alSetError(Context
, AL_INVALID_NAME
);
122 // All effects are valid
125 // Recheck that the effect is valid, because there could be duplicated names
126 if((ALEffect
=LookupEffect(device
->EffectMap
, effects
[i
])) == NULL
)
129 RemoveUIntMapKey(&device
->EffectMap
, ALEffect
->effect
);
130 ALTHUNK_REMOVEENTRY(ALEffect
->effect
);
132 memset(ALEffect
, 0, sizeof(ALeffect
));
137 ProcessContext(Context
);
140 AL_API ALboolean AL_APIENTRY
alIsEffect(ALuint effect
)
145 Context
= GetContextSuspended();
146 if(!Context
) return AL_FALSE
;
148 result
= ((!effect
|| LookupEffect(Context
->Device
->EffectMap
, effect
)) ?
151 ProcessContext(Context
);
156 AL_API ALvoid AL_APIENTRY
alEffecti(ALuint effect
, ALenum param
, ALint iValue
)
162 Context
= GetContextSuspended();
165 Device
= Context
->Device
;
166 if((ALEffect
=LookupEffect(Device
->EffectMap
, effect
)) != NULL
)
168 if(param
== AL_EFFECT_TYPE
)
170 ALboolean isOk
= (iValue
== AL_EFFECT_NULL
||
171 (iValue
== AL_EFFECT_EAXREVERB
&& !DisabledEffects
[EAXREVERB
]) ||
172 (iValue
== AL_EFFECT_REVERB
&& !DisabledEffects
[REVERB
]) ||
173 (iValue
== AL_EFFECT_ECHO
&& !DisabledEffects
[ECHO
]) ||
174 (iValue
== AL_EFFECT_RING_MODULATOR
&& !DisabledEffects
[MODULATOR
]));
177 InitEffectParams(ALEffect
, iValue
);
179 alSetError(Context
, AL_INVALID_VALUE
);
181 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
185 case AL_EAXREVERB_DECAY_HFLIMIT
:
186 if(iValue
>= AL_EAXREVERB_MIN_DECAY_HFLIMIT
&&
187 iValue
<= AL_EAXREVERB_MAX_DECAY_HFLIMIT
)
188 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
190 alSetError(Context
, AL_INVALID_VALUE
);
194 alSetError(Context
, AL_INVALID_ENUM
);
198 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
202 case AL_REVERB_DECAY_HFLIMIT
:
203 if(iValue
>= AL_REVERB_MIN_DECAY_HFLIMIT
&&
204 iValue
<= AL_REVERB_MAX_DECAY_HFLIMIT
)
205 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
207 alSetError(Context
, AL_INVALID_VALUE
);
211 alSetError(Context
, AL_INVALID_ENUM
);
215 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
220 alSetError(Context
, AL_INVALID_ENUM
);
224 else if(ALEffect
->type
== AL_EFFECT_RING_MODULATOR
)
228 case AL_RING_MODULATOR_FREQUENCY
:
229 case AL_RING_MODULATOR_HIGHPASS_CUTOFF
:
230 alEffectf(effect
, param
, (ALfloat
)iValue
);
233 case AL_RING_MODULATOR_WAVEFORM
:
234 if(iValue
>= AL_RING_MODULATOR_MIN_WAVEFORM
&&
235 iValue
<= AL_RING_MODULATOR_MAX_WAVEFORM
)
236 ALEffect
->Modulator
.Waveform
= iValue
;
238 alSetError(Context
, AL_INVALID_VALUE
);
242 alSetError(Context
, AL_INVALID_ENUM
);
247 alSetError(Context
, AL_INVALID_ENUM
);
250 alSetError(Context
, AL_INVALID_NAME
);
252 ProcessContext(Context
);
255 AL_API ALvoid AL_APIENTRY
alEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
261 Context
= GetContextSuspended();
264 Device
= Context
->Device
;
265 if((ALEffect
=LookupEffect(Device
->EffectMap
, effect
)) != NULL
)
267 if(param
== AL_EFFECT_TYPE
)
269 alEffecti(effect
, param
, piValues
[0]);
271 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
275 case AL_EAXREVERB_DECAY_HFLIMIT
:
276 alEffecti(effect
, param
, piValues
[0]);
280 alSetError(Context
, AL_INVALID_ENUM
);
284 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
288 case AL_REVERB_DECAY_HFLIMIT
:
289 alEffecti(effect
, param
, piValues
[0]);
293 alSetError(Context
, AL_INVALID_ENUM
);
297 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
302 alSetError(Context
, AL_INVALID_ENUM
);
306 else if(ALEffect
->type
== AL_EFFECT_RING_MODULATOR
)
310 case AL_RING_MODULATOR_FREQUENCY
:
311 case AL_RING_MODULATOR_HIGHPASS_CUTOFF
:
312 case AL_RING_MODULATOR_WAVEFORM
:
313 alEffecti(effect
, param
, piValues
[0]);
317 alSetError(Context
, AL_INVALID_ENUM
);
322 alSetError(Context
, AL_INVALID_ENUM
);
325 alSetError(Context
, AL_INVALID_NAME
);
327 ProcessContext(Context
);
330 AL_API ALvoid AL_APIENTRY
alEffectf(ALuint effect
, ALenum param
, ALfloat flValue
)
336 Context
= GetContextSuspended();
339 Device
= Context
->Device
;
340 if((ALEffect
=LookupEffect(Device
->EffectMap
, effect
)) != NULL
)
342 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
346 case AL_EAXREVERB_DENSITY
:
347 if(flValue
>= AL_EAXREVERB_MIN_DENSITY
&&
348 flValue
<= AL_EAXREVERB_MAX_DENSITY
)
349 ALEffect
->Reverb
.Density
= flValue
;
351 alSetError(Context
, AL_INVALID_VALUE
);
354 case AL_EAXREVERB_DIFFUSION
:
355 if(flValue
>= AL_EAXREVERB_MIN_DIFFUSION
&&
356 flValue
<= AL_EAXREVERB_MAX_DIFFUSION
)
357 ALEffect
->Reverb
.Diffusion
= flValue
;
359 alSetError(Context
, AL_INVALID_VALUE
);
362 case AL_EAXREVERB_GAIN
:
363 if(flValue
>= AL_EAXREVERB_MIN_GAIN
&&
364 flValue
<= AL_EAXREVERB_MAX_GAIN
)
365 ALEffect
->Reverb
.Gain
= flValue
;
367 alSetError(Context
, AL_INVALID_VALUE
);
370 case AL_EAXREVERB_GAINHF
:
371 if(flValue
>= AL_EAXREVERB_MIN_GAINHF
&&
372 flValue
<= AL_EAXREVERB_MAX_GAIN
)
373 ALEffect
->Reverb
.GainHF
= flValue
;
375 alSetError(Context
, AL_INVALID_VALUE
);
378 case AL_EAXREVERB_GAINLF
:
379 if(flValue
>= AL_EAXREVERB_MIN_GAINLF
&&
380 flValue
<= AL_EAXREVERB_MAX_GAINLF
)
381 ALEffect
->Reverb
.GainLF
= flValue
;
383 alSetError(Context
, AL_INVALID_VALUE
);
386 case AL_EAXREVERB_DECAY_TIME
:
387 if(flValue
>= AL_EAXREVERB_MIN_DECAY_TIME
&&
388 flValue
<= AL_EAXREVERB_MAX_DECAY_TIME
)
389 ALEffect
->Reverb
.DecayTime
= flValue
;
391 alSetError(Context
, AL_INVALID_VALUE
);
394 case AL_EAXREVERB_DECAY_HFRATIO
:
395 if(flValue
>= AL_EAXREVERB_MIN_DECAY_HFRATIO
&&
396 flValue
<= AL_EAXREVERB_MAX_DECAY_HFRATIO
)
397 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
399 alSetError(Context
, AL_INVALID_VALUE
);
402 case AL_EAXREVERB_DECAY_LFRATIO
:
403 if(flValue
>= AL_EAXREVERB_MIN_DECAY_LFRATIO
&&
404 flValue
<= AL_EAXREVERB_MAX_DECAY_LFRATIO
)
405 ALEffect
->Reverb
.DecayLFRatio
= flValue
;
407 alSetError(Context
, AL_INVALID_VALUE
);
410 case AL_EAXREVERB_REFLECTIONS_GAIN
:
411 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_GAIN
&&
412 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_GAIN
)
413 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
415 alSetError(Context
, AL_INVALID_VALUE
);
418 case AL_EAXREVERB_REFLECTIONS_DELAY
:
419 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_DELAY
&&
420 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_DELAY
)
421 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
423 alSetError(Context
, AL_INVALID_VALUE
);
426 case AL_EAXREVERB_LATE_REVERB_GAIN
:
427 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_GAIN
&&
428 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_GAIN
)
429 ALEffect
->Reverb
.LateReverbGain
= flValue
;
431 alSetError(Context
, AL_INVALID_VALUE
);
434 case AL_EAXREVERB_LATE_REVERB_DELAY
:
435 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_DELAY
&&
436 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_DELAY
)
437 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
439 alSetError(Context
, AL_INVALID_VALUE
);
442 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
443 if(flValue
>= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF
&&
444 flValue
<= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF
)
445 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
447 alSetError(Context
, AL_INVALID_VALUE
);
450 case AL_EAXREVERB_ECHO_TIME
:
451 if(flValue
>= AL_EAXREVERB_MIN_ECHO_TIME
&&
452 flValue
<= AL_EAXREVERB_MAX_ECHO_TIME
)
453 ALEffect
->Reverb
.EchoTime
= flValue
;
455 alSetError(Context
, AL_INVALID_VALUE
);
458 case AL_EAXREVERB_ECHO_DEPTH
:
459 if(flValue
>= AL_EAXREVERB_MIN_ECHO_DEPTH
&&
460 flValue
<= AL_EAXREVERB_MAX_ECHO_DEPTH
)
461 ALEffect
->Reverb
.EchoDepth
= flValue
;
463 alSetError(Context
, AL_INVALID_VALUE
);
466 case AL_EAXREVERB_MODULATION_TIME
:
467 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_TIME
&&
468 flValue
<= AL_EAXREVERB_MAX_MODULATION_TIME
)
469 ALEffect
->Reverb
.ModulationTime
= flValue
;
471 alSetError(Context
, AL_INVALID_VALUE
);
474 case AL_EAXREVERB_MODULATION_DEPTH
:
475 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_DEPTH
&&
476 flValue
<= AL_EAXREVERB_MAX_MODULATION_DEPTH
)
477 ALEffect
->Reverb
.ModulationDepth
= flValue
;
479 alSetError(Context
, AL_INVALID_VALUE
);
482 case AL_EAXREVERB_HFREFERENCE
:
483 if(flValue
>= AL_EAXREVERB_MIN_HFREFERENCE
&&
484 flValue
<= AL_EAXREVERB_MAX_HFREFERENCE
)
485 ALEffect
->Reverb
.HFReference
= flValue
;
487 alSetError(Context
, AL_INVALID_VALUE
);
490 case AL_EAXREVERB_LFREFERENCE
:
491 if(flValue
>= AL_EAXREVERB_MIN_LFREFERENCE
&&
492 flValue
<= AL_EAXREVERB_MAX_LFREFERENCE
)
493 ALEffect
->Reverb
.LFReference
= flValue
;
495 alSetError(Context
, AL_INVALID_VALUE
);
498 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
499 if(flValue
>= 0.0f
&& flValue
<= 10.0f
)
500 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
502 alSetError(Context
, AL_INVALID_VALUE
);
506 alSetError(Context
, AL_INVALID_ENUM
);
510 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
514 case AL_REVERB_DENSITY
:
515 if(flValue
>= AL_REVERB_MIN_DENSITY
&&
516 flValue
<= AL_REVERB_MAX_DENSITY
)
517 ALEffect
->Reverb
.Density
= flValue
;
519 alSetError(Context
, AL_INVALID_VALUE
);
522 case AL_REVERB_DIFFUSION
:
523 if(flValue
>= AL_REVERB_MIN_DIFFUSION
&&
524 flValue
<= AL_REVERB_MAX_DIFFUSION
)
525 ALEffect
->Reverb
.Diffusion
= flValue
;
527 alSetError(Context
, AL_INVALID_VALUE
);
531 if(flValue
>= AL_REVERB_MIN_GAIN
&&
532 flValue
<= AL_REVERB_MAX_GAIN
)
533 ALEffect
->Reverb
.Gain
= flValue
;
535 alSetError(Context
, AL_INVALID_VALUE
);
538 case AL_REVERB_GAINHF
:
539 if(flValue
>= AL_REVERB_MIN_GAINHF
&&
540 flValue
<= AL_REVERB_MAX_GAINHF
)
541 ALEffect
->Reverb
.GainHF
= flValue
;
543 alSetError(Context
, AL_INVALID_VALUE
);
546 case AL_REVERB_DECAY_TIME
:
547 if(flValue
>= AL_REVERB_MIN_DECAY_TIME
&&
548 flValue
<= AL_REVERB_MAX_DECAY_TIME
)
549 ALEffect
->Reverb
.DecayTime
= flValue
;
551 alSetError(Context
, AL_INVALID_VALUE
);
554 case AL_REVERB_DECAY_HFRATIO
:
555 if(flValue
>= AL_REVERB_MIN_DECAY_HFRATIO
&&
556 flValue
<= AL_REVERB_MAX_DECAY_HFRATIO
)
557 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
559 alSetError(Context
, AL_INVALID_VALUE
);
562 case AL_REVERB_REFLECTIONS_GAIN
:
563 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_GAIN
&&
564 flValue
<= AL_REVERB_MAX_REFLECTIONS_GAIN
)
565 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
567 alSetError(Context
, AL_INVALID_VALUE
);
570 case AL_REVERB_REFLECTIONS_DELAY
:
571 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_DELAY
&&
572 flValue
<= AL_REVERB_MAX_REFLECTIONS_DELAY
)
573 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
575 alSetError(Context
, AL_INVALID_VALUE
);
578 case AL_REVERB_LATE_REVERB_GAIN
:
579 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_GAIN
&&
580 flValue
<= AL_REVERB_MAX_LATE_REVERB_GAIN
)
581 ALEffect
->Reverb
.LateReverbGain
= flValue
;
583 alSetError(Context
, AL_INVALID_VALUE
);
586 case AL_REVERB_LATE_REVERB_DELAY
:
587 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_DELAY
&&
588 flValue
<= AL_REVERB_MAX_LATE_REVERB_DELAY
)
589 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
591 alSetError(Context
, AL_INVALID_VALUE
);
594 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
595 if(flValue
>= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF
&&
596 flValue
<= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF
)
597 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
599 alSetError(Context
, AL_INVALID_VALUE
);
602 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
603 if(flValue
>= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR
&&
604 flValue
<= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR
)
605 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
607 alSetError(Context
, AL_INVALID_VALUE
);
611 alSetError(Context
, AL_INVALID_ENUM
);
615 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
620 if(flValue
>= AL_ECHO_MIN_DELAY
&& flValue
<= AL_ECHO_MAX_DELAY
)
621 ALEffect
->Echo
.Delay
= flValue
;
623 alSetError(Context
, AL_INVALID_VALUE
);
626 case AL_ECHO_LRDELAY
:
627 if(flValue
>= AL_ECHO_MIN_LRDELAY
&& flValue
<= AL_ECHO_MAX_LRDELAY
)
628 ALEffect
->Echo
.LRDelay
= flValue
;
630 alSetError(Context
, AL_INVALID_VALUE
);
633 case AL_ECHO_DAMPING
:
634 if(flValue
>= AL_ECHO_MIN_DAMPING
&& flValue
<= AL_ECHO_MAX_DAMPING
)
635 ALEffect
->Echo
.Damping
= flValue
;
637 alSetError(Context
, AL_INVALID_VALUE
);
640 case AL_ECHO_FEEDBACK
:
641 if(flValue
>= AL_ECHO_MIN_FEEDBACK
&& flValue
<= AL_ECHO_MAX_FEEDBACK
)
642 ALEffect
->Echo
.Feedback
= flValue
;
644 alSetError(Context
, AL_INVALID_VALUE
);
648 if(flValue
>= AL_ECHO_MIN_SPREAD
&& flValue
<= AL_ECHO_MAX_SPREAD
)
649 ALEffect
->Echo
.Spread
= flValue
;
651 alSetError(Context
, AL_INVALID_VALUE
);
655 alSetError(Context
, AL_INVALID_ENUM
);
659 else if(ALEffect
->type
== AL_EFFECT_RING_MODULATOR
)
663 case AL_RING_MODULATOR_FREQUENCY
:
664 if(flValue
>= AL_RING_MODULATOR_MIN_FREQUENCY
&&
665 flValue
<= AL_RING_MODULATOR_MAX_FREQUENCY
)
666 ALEffect
->Modulator
.Frequency
= flValue
;
668 alSetError(Context
, AL_INVALID_VALUE
);
671 case AL_RING_MODULATOR_HIGHPASS_CUTOFF
:
672 if(flValue
>= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF
&&
673 flValue
<= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF
)
674 ALEffect
->Modulator
.HighPassCutoff
= flValue
;
676 alSetError(Context
, AL_INVALID_VALUE
);
680 alSetError(Context
, AL_INVALID_ENUM
);
685 alSetError(Context
, AL_INVALID_ENUM
);
688 alSetError(Context
, AL_INVALID_NAME
);
690 ProcessContext(Context
);
693 AL_API ALvoid AL_APIENTRY
alEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
699 Context
= GetContextSuspended();
702 Device
= Context
->Device
;
703 if((ALEffect
=LookupEffect(Device
->EffectMap
, effect
)) != NULL
)
705 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
709 case AL_EAXREVERB_DENSITY
:
710 case AL_EAXREVERB_DIFFUSION
:
711 case AL_EAXREVERB_GAIN
:
712 case AL_EAXREVERB_GAINHF
:
713 case AL_EAXREVERB_GAINLF
:
714 case AL_EAXREVERB_DECAY_TIME
:
715 case AL_EAXREVERB_DECAY_HFRATIO
:
716 case AL_EAXREVERB_DECAY_LFRATIO
:
717 case AL_EAXREVERB_REFLECTIONS_GAIN
:
718 case AL_EAXREVERB_REFLECTIONS_DELAY
:
719 case AL_EAXREVERB_LATE_REVERB_GAIN
:
720 case AL_EAXREVERB_LATE_REVERB_DELAY
:
721 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
722 case AL_EAXREVERB_ECHO_TIME
:
723 case AL_EAXREVERB_ECHO_DEPTH
:
724 case AL_EAXREVERB_MODULATION_TIME
:
725 case AL_EAXREVERB_MODULATION_DEPTH
:
726 case AL_EAXREVERB_HFREFERENCE
:
727 case AL_EAXREVERB_LFREFERENCE
:
728 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
729 alEffectf(effect
, param
, pflValues
[0]);
732 case AL_EAXREVERB_REFLECTIONS_PAN
:
733 if(!isnan(pflValues
[0]) && !isnan(pflValues
[1]) && !isnan(pflValues
[2]))
735 ALEffect
->Reverb
.ReflectionsPan
[0] = pflValues
[0];
736 ALEffect
->Reverb
.ReflectionsPan
[1] = pflValues
[1];
737 ALEffect
->Reverb
.ReflectionsPan
[2] = pflValues
[2];
740 alSetError(Context
, AL_INVALID_VALUE
);
742 case AL_EAXREVERB_LATE_REVERB_PAN
:
743 if(!isnan(pflValues
[0]) && !isnan(pflValues
[1]) && !isnan(pflValues
[2]))
745 ALEffect
->Reverb
.LateReverbPan
[0] = pflValues
[0];
746 ALEffect
->Reverb
.LateReverbPan
[1] = pflValues
[1];
747 ALEffect
->Reverb
.LateReverbPan
[2] = pflValues
[2];
750 alSetError(Context
, AL_INVALID_VALUE
);
754 alSetError(Context
, AL_INVALID_ENUM
);
758 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
762 case AL_REVERB_DENSITY
:
763 case AL_REVERB_DIFFUSION
:
765 case AL_REVERB_GAINHF
:
766 case AL_REVERB_DECAY_TIME
:
767 case AL_REVERB_DECAY_HFRATIO
:
768 case AL_REVERB_REFLECTIONS_GAIN
:
769 case AL_REVERB_REFLECTIONS_DELAY
:
770 case AL_REVERB_LATE_REVERB_GAIN
:
771 case AL_REVERB_LATE_REVERB_DELAY
:
772 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
773 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
774 alEffectf(effect
, param
, pflValues
[0]);
778 alSetError(Context
, AL_INVALID_ENUM
);
782 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
787 case AL_ECHO_LRDELAY
:
788 case AL_ECHO_DAMPING
:
789 case AL_ECHO_FEEDBACK
:
791 alEffectf(effect
, param
, pflValues
[0]);
795 alSetError(Context
, AL_INVALID_ENUM
);
799 else if(ALEffect
->type
== AL_EFFECT_RING_MODULATOR
)
803 case AL_RING_MODULATOR_FREQUENCY
:
804 case AL_RING_MODULATOR_HIGHPASS_CUTOFF
:
805 alEffectf(effect
, param
, pflValues
[0]);
809 alSetError(Context
, AL_INVALID_ENUM
);
814 alSetError(Context
, AL_INVALID_ENUM
);
817 alSetError(Context
, AL_INVALID_NAME
);
819 ProcessContext(Context
);
822 AL_API ALvoid AL_APIENTRY
alGetEffecti(ALuint effect
, ALenum param
, ALint
*piValue
)
828 Context
= GetContextSuspended();
831 Device
= Context
->Device
;
832 if((ALEffect
=LookupEffect(Device
->EffectMap
, effect
)) != NULL
)
834 if(param
== AL_EFFECT_TYPE
)
836 *piValue
= ALEffect
->type
;
838 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
842 case AL_EAXREVERB_DECAY_HFLIMIT
:
843 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
847 alSetError(Context
, AL_INVALID_ENUM
);
851 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
855 case AL_REVERB_DECAY_HFLIMIT
:
856 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
860 alSetError(Context
, AL_INVALID_ENUM
);
864 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
869 alSetError(Context
, AL_INVALID_ENUM
);
873 else if(ALEffect
->type
== AL_EFFECT_RING_MODULATOR
)
877 case AL_RING_MODULATOR_FREQUENCY
:
878 *piValue
= (ALint
)ALEffect
->Modulator
.Frequency
;
880 case AL_RING_MODULATOR_HIGHPASS_CUTOFF
:
881 *piValue
= (ALint
)ALEffect
->Modulator
.HighPassCutoff
;
883 case AL_RING_MODULATOR_WAVEFORM
:
884 *piValue
= ALEffect
->Modulator
.Waveform
;
888 alSetError(Context
, AL_INVALID_ENUM
);
893 alSetError(Context
, AL_INVALID_ENUM
);
896 alSetError(Context
, AL_INVALID_NAME
);
898 ProcessContext(Context
);
901 AL_API ALvoid AL_APIENTRY
alGetEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
907 Context
= GetContextSuspended();
910 Device
= Context
->Device
;
911 if((ALEffect
=LookupEffect(Device
->EffectMap
, effect
)) != NULL
)
913 if(param
== AL_EFFECT_TYPE
)
915 alGetEffecti(effect
, param
, piValues
);
917 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
921 case AL_EAXREVERB_DECAY_HFLIMIT
:
922 alGetEffecti(effect
, param
, piValues
);
926 alSetError(Context
, AL_INVALID_ENUM
);
930 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
934 case AL_REVERB_DECAY_HFLIMIT
:
935 alGetEffecti(effect
, param
, piValues
);
939 alSetError(Context
, AL_INVALID_ENUM
);
943 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
948 alSetError(Context
, AL_INVALID_ENUM
);
952 else if(ALEffect
->type
== AL_EFFECT_RING_MODULATOR
)
956 case AL_RING_MODULATOR_FREQUENCY
:
957 case AL_RING_MODULATOR_HIGHPASS_CUTOFF
:
958 case AL_RING_MODULATOR_WAVEFORM
:
959 alGetEffecti(effect
, param
, piValues
);
963 alSetError(Context
, AL_INVALID_ENUM
);
968 alSetError(Context
, AL_INVALID_ENUM
);
971 alSetError(Context
, AL_INVALID_NAME
);
973 ProcessContext(Context
);
976 AL_API ALvoid AL_APIENTRY
alGetEffectf(ALuint effect
, ALenum param
, ALfloat
*pflValue
)
982 Context
= GetContextSuspended();
985 Device
= Context
->Device
;
986 if((ALEffect
=LookupEffect(Device
->EffectMap
, effect
)) != NULL
)
988 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
992 case AL_EAXREVERB_DENSITY
:
993 *pflValue
= ALEffect
->Reverb
.Density
;
996 case AL_EAXREVERB_DIFFUSION
:
997 *pflValue
= ALEffect
->Reverb
.Diffusion
;
1000 case AL_EAXREVERB_GAIN
:
1001 *pflValue
= ALEffect
->Reverb
.Gain
;
1004 case AL_EAXREVERB_GAINHF
:
1005 *pflValue
= ALEffect
->Reverb
.GainHF
;
1008 case AL_EAXREVERB_GAINLF
:
1009 *pflValue
= ALEffect
->Reverb
.GainLF
;
1012 case AL_EAXREVERB_DECAY_TIME
:
1013 *pflValue
= ALEffect
->Reverb
.DecayTime
;
1016 case AL_EAXREVERB_DECAY_HFRATIO
:
1017 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
1020 case AL_EAXREVERB_DECAY_LFRATIO
:
1021 *pflValue
= ALEffect
->Reverb
.DecayLFRatio
;
1024 case AL_EAXREVERB_REFLECTIONS_GAIN
:
1025 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
1028 case AL_EAXREVERB_REFLECTIONS_DELAY
:
1029 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
1032 case AL_EAXREVERB_LATE_REVERB_GAIN
:
1033 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
1036 case AL_EAXREVERB_LATE_REVERB_DELAY
:
1037 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
1040 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
1041 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
1044 case AL_EAXREVERB_ECHO_TIME
:
1045 *pflValue
= ALEffect
->Reverb
.EchoTime
;
1048 case AL_EAXREVERB_ECHO_DEPTH
:
1049 *pflValue
= ALEffect
->Reverb
.EchoDepth
;
1052 case AL_EAXREVERB_MODULATION_TIME
:
1053 *pflValue
= ALEffect
->Reverb
.ModulationTime
;
1056 case AL_EAXREVERB_MODULATION_DEPTH
:
1057 *pflValue
= ALEffect
->Reverb
.ModulationDepth
;
1060 case AL_EAXREVERB_HFREFERENCE
:
1061 *pflValue
= ALEffect
->Reverb
.HFReference
;
1064 case AL_EAXREVERB_LFREFERENCE
:
1065 *pflValue
= ALEffect
->Reverb
.LFReference
;
1068 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
1069 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
1073 alSetError(Context
, AL_INVALID_ENUM
);
1077 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
1081 case AL_REVERB_DENSITY
:
1082 *pflValue
= ALEffect
->Reverb
.Density
;
1085 case AL_REVERB_DIFFUSION
:
1086 *pflValue
= ALEffect
->Reverb
.Diffusion
;
1089 case AL_REVERB_GAIN
:
1090 *pflValue
= ALEffect
->Reverb
.Gain
;
1093 case AL_REVERB_GAINHF
:
1094 *pflValue
= ALEffect
->Reverb
.GainHF
;
1097 case AL_REVERB_DECAY_TIME
:
1098 *pflValue
= ALEffect
->Reverb
.DecayTime
;
1101 case AL_REVERB_DECAY_HFRATIO
:
1102 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
1105 case AL_REVERB_REFLECTIONS_GAIN
:
1106 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
1109 case AL_REVERB_REFLECTIONS_DELAY
:
1110 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
1113 case AL_REVERB_LATE_REVERB_GAIN
:
1114 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
1117 case AL_REVERB_LATE_REVERB_DELAY
:
1118 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
1121 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1122 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
1125 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1126 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
1130 alSetError(Context
, AL_INVALID_ENUM
);
1134 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1139 *pflValue
= ALEffect
->Echo
.Delay
;
1142 case AL_ECHO_LRDELAY
:
1143 *pflValue
= ALEffect
->Echo
.LRDelay
;
1146 case AL_ECHO_DAMPING
:
1147 *pflValue
= ALEffect
->Echo
.Damping
;
1150 case AL_ECHO_FEEDBACK
:
1151 *pflValue
= ALEffect
->Echo
.Feedback
;
1154 case AL_ECHO_SPREAD
:
1155 *pflValue
= ALEffect
->Echo
.Spread
;
1159 alSetError(Context
, AL_INVALID_ENUM
);
1163 else if(ALEffect
->type
== AL_EFFECT_RING_MODULATOR
)
1167 case AL_RING_MODULATOR_FREQUENCY
:
1168 *pflValue
= ALEffect
->Modulator
.Frequency
;
1170 case AL_RING_MODULATOR_HIGHPASS_CUTOFF
:
1171 *pflValue
= ALEffect
->Modulator
.HighPassCutoff
;
1175 alSetError(Context
, AL_INVALID_ENUM
);
1180 alSetError(Context
, AL_INVALID_ENUM
);
1183 alSetError(Context
, AL_INVALID_NAME
);
1185 ProcessContext(Context
);
1188 AL_API ALvoid AL_APIENTRY
alGetEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
1190 ALCcontext
*Context
;
1194 Context
= GetContextSuspended();
1195 if(!Context
) return;
1197 Device
= Context
->Device
;
1198 if((ALEffect
=LookupEffect(Device
->EffectMap
, effect
)) != NULL
)
1200 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
1204 case AL_EAXREVERB_DENSITY
:
1205 case AL_EAXREVERB_DIFFUSION
:
1206 case AL_EAXREVERB_GAIN
:
1207 case AL_EAXREVERB_GAINHF
:
1208 case AL_EAXREVERB_GAINLF
:
1209 case AL_EAXREVERB_DECAY_TIME
:
1210 case AL_EAXREVERB_DECAY_HFRATIO
:
1211 case AL_EAXREVERB_DECAY_LFRATIO
:
1212 case AL_EAXREVERB_REFLECTIONS_GAIN
:
1213 case AL_EAXREVERB_REFLECTIONS_DELAY
:
1214 case AL_EAXREVERB_LATE_REVERB_GAIN
:
1215 case AL_EAXREVERB_LATE_REVERB_DELAY
:
1216 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
1217 case AL_EAXREVERB_ECHO_TIME
:
1218 case AL_EAXREVERB_ECHO_DEPTH
:
1219 case AL_EAXREVERB_MODULATION_TIME
:
1220 case AL_EAXREVERB_MODULATION_DEPTH
:
1221 case AL_EAXREVERB_HFREFERENCE
:
1222 case AL_EAXREVERB_LFREFERENCE
:
1223 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
1224 alGetEffectf(effect
, param
, pflValues
);
1227 case AL_EAXREVERB_REFLECTIONS_PAN
:
1228 pflValues
[0] = ALEffect
->Reverb
.ReflectionsPan
[0];
1229 pflValues
[1] = ALEffect
->Reverb
.ReflectionsPan
[1];
1230 pflValues
[2] = ALEffect
->Reverb
.ReflectionsPan
[2];
1232 case AL_EAXREVERB_LATE_REVERB_PAN
:
1233 pflValues
[0] = ALEffect
->Reverb
.LateReverbPan
[0];
1234 pflValues
[1] = ALEffect
->Reverb
.LateReverbPan
[1];
1235 pflValues
[2] = ALEffect
->Reverb
.LateReverbPan
[2];
1239 alSetError(Context
, AL_INVALID_ENUM
);
1243 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
1247 case AL_REVERB_DENSITY
:
1248 case AL_REVERB_DIFFUSION
:
1249 case AL_REVERB_GAIN
:
1250 case AL_REVERB_GAINHF
:
1251 case AL_REVERB_DECAY_TIME
:
1252 case AL_REVERB_DECAY_HFRATIO
:
1253 case AL_REVERB_REFLECTIONS_GAIN
:
1254 case AL_REVERB_REFLECTIONS_DELAY
:
1255 case AL_REVERB_LATE_REVERB_GAIN
:
1256 case AL_REVERB_LATE_REVERB_DELAY
:
1257 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1258 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1259 alGetEffectf(effect
, param
, pflValues
);
1263 alSetError(Context
, AL_INVALID_ENUM
);
1267 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1272 case AL_ECHO_LRDELAY
:
1273 case AL_ECHO_DAMPING
:
1274 case AL_ECHO_FEEDBACK
:
1275 case AL_ECHO_SPREAD
:
1276 alGetEffectf(effect
, param
, pflValues
);
1280 alSetError(Context
, AL_INVALID_ENUM
);
1284 else if(ALEffect
->type
== AL_EFFECT_RING_MODULATOR
)
1288 case AL_RING_MODULATOR_FREQUENCY
:
1289 case AL_RING_MODULATOR_HIGHPASS_CUTOFF
:
1290 alGetEffectf(effect
, param
, pflValues
);
1294 alSetError(Context
, AL_INVALID_ENUM
);
1299 alSetError(Context
, AL_INVALID_ENUM
);
1302 alSetError(Context
, AL_INVALID_NAME
);
1304 ProcessContext(Context
);
1308 ALvoid
ReleaseALEffects(ALCdevice
*device
)
1311 for(i
= 0;i
< device
->EffectMap
.size
;i
++)
1313 ALeffect
*temp
= device
->EffectMap
.array
[i
].value
;
1314 device
->EffectMap
.array
[i
].value
= NULL
;
1316 // Release effect structure
1317 ALTHUNK_REMOVEENTRY(temp
->effect
);
1318 memset(temp
, 0, sizeof(ALeffect
));
1324 static void InitEffectParams(ALeffect
*effect
, ALenum type
)
1326 effect
->type
= type
;
1329 /* NOTE: Standard reverb and EAX reverb use the same defaults for the
1330 * shared parameters, and EAX's additional parameters default to
1331 * values assumed by standard reverb.
1333 case AL_EFFECT_EAXREVERB
:
1334 case AL_EFFECT_REVERB
:
1335 effect
->Reverb
.Density
= AL_EAXREVERB_DEFAULT_DENSITY
;
1336 effect
->Reverb
.Diffusion
= AL_EAXREVERB_DEFAULT_DIFFUSION
;
1337 effect
->Reverb
.Gain
= AL_EAXREVERB_DEFAULT_GAIN
;
1338 effect
->Reverb
.GainHF
= AL_EAXREVERB_DEFAULT_GAINHF
;
1339 effect
->Reverb
.GainLF
= AL_EAXREVERB_DEFAULT_GAINLF
;
1340 effect
->Reverb
.DecayTime
= AL_EAXREVERB_DEFAULT_DECAY_TIME
;
1341 effect
->Reverb
.DecayHFRatio
= AL_EAXREVERB_DEFAULT_DECAY_HFRATIO
;
1342 effect
->Reverb
.DecayLFRatio
= AL_EAXREVERB_DEFAULT_DECAY_LFRATIO
;
1343 effect
->Reverb
.ReflectionsGain
= AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN
;
1344 effect
->Reverb
.ReflectionsDelay
= AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY
;
1345 effect
->Reverb
.ReflectionsPan
[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1346 effect
->Reverb
.ReflectionsPan
[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1347 effect
->Reverb
.ReflectionsPan
[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1348 effect
->Reverb
.LateReverbGain
= AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN
;
1349 effect
->Reverb
.LateReverbDelay
= AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY
;
1350 effect
->Reverb
.LateReverbPan
[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1351 effect
->Reverb
.LateReverbPan
[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1352 effect
->Reverb
.LateReverbPan
[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1353 effect
->Reverb
.EchoTime
= AL_EAXREVERB_DEFAULT_ECHO_TIME
;
1354 effect
->Reverb
.EchoDepth
= AL_EAXREVERB_DEFAULT_ECHO_DEPTH
;
1355 effect
->Reverb
.ModulationTime
= AL_EAXREVERB_DEFAULT_MODULATION_TIME
;
1356 effect
->Reverb
.ModulationDepth
= AL_EAXREVERB_DEFAULT_MODULATION_DEPTH
;
1357 effect
->Reverb
.AirAbsorptionGainHF
= AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF
;
1358 effect
->Reverb
.HFReference
= AL_EAXREVERB_DEFAULT_HFREFERENCE
;
1359 effect
->Reverb
.LFReference
= AL_EAXREVERB_DEFAULT_LFREFERENCE
;
1360 effect
->Reverb
.RoomRolloffFactor
= AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR
;
1361 effect
->Reverb
.DecayHFLimit
= AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT
;
1363 case AL_EFFECT_ECHO
:
1364 effect
->Echo
.Delay
= AL_ECHO_DEFAULT_DELAY
;
1365 effect
->Echo
.LRDelay
= AL_ECHO_DEFAULT_LRDELAY
;
1366 effect
->Echo
.Damping
= AL_ECHO_DEFAULT_DAMPING
;
1367 effect
->Echo
.Feedback
= AL_ECHO_DEFAULT_FEEDBACK
;
1368 effect
->Echo
.Spread
= AL_ECHO_DEFAULT_SPREAD
;
1370 case AL_EFFECT_RING_MODULATOR
:
1371 effect
->Modulator
.Frequency
= AL_RING_MODULATOR_DEFAULT_FREQUENCY
;
1372 effect
->Modulator
.HighPassCutoff
= AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF
;
1373 effect
->Modulator
.Waveform
= AL_RING_MODULATOR_DEFAULT_WAVEFORM
;