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
33 ALboolean DisabledEffects
[MAX_EFFECTS
];
36 static ALeffect
*g_EffectList
;
37 static ALuint g_EffectCount
;
39 static void InitEffectParams(ALeffect
*effect
, ALenum type
);
42 ALvoid AL_APIENTRY
alGenEffects(ALsizei n
, ALuint
*effects
)
47 Context
= alcGetCurrentContext();
48 SuspendContext(Context
);
52 // Check that enough memory has been allocted in the 'effects' array for n Effects
53 if (!IsBadWritePtr((void*)effects
, n
* sizeof(ALuint
)))
55 ALeffect
**list
= &g_EffectList
;
57 list
= &(*list
)->next
;
62 *list
= calloc(1, sizeof(ALeffect
));
65 // We must have run out or memory
66 alDeleteEffects(i
, effects
);
67 alSetError(AL_OUT_OF_MEMORY
);
71 effects
[i
] = (ALuint
)ALTHUNK_ADDENTRY(*list
);
72 (*list
)->effect
= effects
[i
];
74 InitEffectParams(*list
, AL_EFFECT_NULL
);
78 list
= &(*list
)->next
;
83 ProcessContext(Context
);
86 ALvoid AL_APIENTRY
alDeleteEffects(ALsizei n
, ALuint
*effects
)
92 Context
= alcGetCurrentContext();
93 SuspendContext(Context
);
97 // Check that all effects are valid
98 for (i
= 0; i
< n
; i
++)
100 if (!alIsEffect(effects
[i
]))
102 alSetError(AL_INVALID_NAME
);
109 // All effects are valid
110 for (i
= 0; i
< n
; i
++)
112 // Recheck that the effect is valid, because there could be duplicated names
113 if (effects
[i
] && alIsEffect(effects
[i
]))
117 ALEffect
= ((ALeffect
*)ALTHUNK_LOOKUPENTRY(effects
[i
]));
119 // Remove Source from list of Sources
120 list
= &g_EffectList
;
121 while(*list
&& *list
!= ALEffect
)
122 list
= &(*list
)->next
;
125 *list
= (*list
)->next
;
126 ALTHUNK_REMOVEENTRY(ALEffect
->effect
);
128 memset(ALEffect
, 0, sizeof(ALeffect
));
137 alSetError(AL_INVALID_VALUE
);
139 ProcessContext(Context
);
142 ALboolean AL_APIENTRY
alIsEffect(ALuint effect
)
147 Context
= alcGetCurrentContext();
148 SuspendContext(Context
);
150 list
= &g_EffectList
;
151 while(*list
&& (*list
)->effect
!= effect
)
152 list
= &(*list
)->next
;
154 ProcessContext(Context
);
156 return ((*list
|| !effect
) ? AL_TRUE
: AL_FALSE
);
159 ALvoid AL_APIENTRY
alEffecti(ALuint effect
, ALenum param
, ALint iValue
)
163 Context
= alcGetCurrentContext();
164 SuspendContext(Context
);
166 if (effect
&& alIsEffect(effect
))
168 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
170 if(param
== AL_EFFECT_TYPE
)
172 ALboolean isOk
= (iValue
== AL_EFFECT_NULL
||
173 (iValue
== AL_EFFECT_EAXREVERB
&& !DisabledEffects
[EAXREVERB
]) ||
174 (iValue
== AL_EFFECT_REVERB
&& !DisabledEffects
[REVERB
]) ||
175 (iValue
== AL_EFFECT_ECHO
&& !DisabledEffects
[ECHO
]));
178 InitEffectParams(ALEffect
, iValue
);
180 alSetError(AL_INVALID_VALUE
);
182 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
186 case AL_EAXREVERB_DECAY_HFLIMIT
:
187 if(iValue
>= AL_EAXREVERB_MIN_DECAY_HFLIMIT
&&
188 iValue
<= AL_EAXREVERB_MAX_DECAY_HFLIMIT
)
189 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
191 alSetError(AL_INVALID_VALUE
);
195 alSetError(AL_INVALID_ENUM
);
199 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
203 case AL_REVERB_DECAY_HFLIMIT
:
204 if(iValue
>= AL_REVERB_MIN_DECAY_HFLIMIT
&&
205 iValue
<= AL_REVERB_MAX_DECAY_HFLIMIT
)
206 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
208 alSetError(AL_INVALID_VALUE
);
212 alSetError(AL_INVALID_ENUM
);
216 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
221 alSetError(AL_INVALID_ENUM
);
226 alSetError(AL_INVALID_ENUM
);
229 alSetError(AL_INVALID_NAME
);
231 ProcessContext(Context
);
234 ALvoid AL_APIENTRY
alEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
238 Context
= alcGetCurrentContext();
239 SuspendContext(Context
);
241 if (effect
&& alIsEffect(effect
))
243 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
245 if(param
== AL_EFFECT_TYPE
)
247 alEffecti(effect
, param
, piValues
[0]);
249 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
253 case AL_EAXREVERB_DECAY_HFLIMIT
:
254 alEffecti(effect
, param
, piValues
[0]);
258 alSetError(AL_INVALID_ENUM
);
262 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
266 case AL_REVERB_DECAY_HFLIMIT
:
267 alEffecti(effect
, param
, piValues
[0]);
271 alSetError(AL_INVALID_ENUM
);
275 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
280 alSetError(AL_INVALID_ENUM
);
285 alSetError(AL_INVALID_ENUM
);
288 alSetError(AL_INVALID_NAME
);
290 ProcessContext(Context
);
293 ALvoid AL_APIENTRY
alEffectf(ALuint effect
, ALenum param
, ALfloat flValue
)
297 Context
= alcGetCurrentContext();
298 SuspendContext(Context
);
300 if (effect
&& alIsEffect(effect
))
302 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
304 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
308 case AL_EAXREVERB_DENSITY
:
309 if(flValue
>= AL_EAXREVERB_MIN_DENSITY
&&
310 flValue
<= AL_EAXREVERB_MAX_DENSITY
)
311 ALEffect
->Reverb
.Density
= flValue
;
313 alSetError(AL_INVALID_VALUE
);
316 case AL_EAXREVERB_DIFFUSION
:
317 if(flValue
>= AL_EAXREVERB_MIN_DIFFUSION
&&
318 flValue
<= AL_EAXREVERB_MAX_DIFFUSION
)
319 ALEffect
->Reverb
.Diffusion
= flValue
;
321 alSetError(AL_INVALID_VALUE
);
324 case AL_EAXREVERB_GAIN
:
325 if(flValue
>= AL_EAXREVERB_MIN_GAIN
&&
326 flValue
<= AL_EAXREVERB_MAX_GAIN
)
327 ALEffect
->Reverb
.Gain
= flValue
;
329 alSetError(AL_INVALID_VALUE
);
332 case AL_EAXREVERB_GAINHF
:
333 if(flValue
>= AL_EAXREVERB_MIN_GAINHF
&&
334 flValue
<= AL_EAXREVERB_MAX_GAIN
)
335 ALEffect
->Reverb
.GainHF
= flValue
;
337 alSetError(AL_INVALID_VALUE
);
340 case AL_EAXREVERB_GAINLF
:
341 if(flValue
>= AL_EAXREVERB_MIN_GAINLF
&&
342 flValue
<= AL_EAXREVERB_MAX_GAINLF
)
343 ALEffect
->Reverb
.GainLF
= flValue
;
345 alSetError(AL_INVALID_VALUE
);
348 case AL_EAXREVERB_DECAY_TIME
:
349 if(flValue
>= AL_EAXREVERB_MIN_DECAY_TIME
&&
350 flValue
<= AL_EAXREVERB_MAX_DECAY_TIME
)
351 ALEffect
->Reverb
.DecayTime
= flValue
;
353 alSetError(AL_INVALID_VALUE
);
356 case AL_EAXREVERB_DECAY_HFRATIO
:
357 if(flValue
>= AL_EAXREVERB_MIN_DECAY_HFRATIO
&&
358 flValue
<= AL_EAXREVERB_MAX_DECAY_HFRATIO
)
359 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
361 alSetError(AL_INVALID_VALUE
);
364 case AL_EAXREVERB_DECAY_LFRATIO
:
365 if(flValue
>= AL_EAXREVERB_MIN_DECAY_LFRATIO
&&
366 flValue
<= AL_EAXREVERB_MAX_DECAY_LFRATIO
)
367 ALEffect
->Reverb
.DecayLFRatio
= flValue
;
369 alSetError(AL_INVALID_VALUE
);
372 case AL_EAXREVERB_REFLECTIONS_GAIN
:
373 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_GAIN
&&
374 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_GAIN
)
375 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
377 alSetError(AL_INVALID_VALUE
);
380 case AL_EAXREVERB_REFLECTIONS_DELAY
:
381 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_DELAY
&&
382 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_DELAY
)
383 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
385 alSetError(AL_INVALID_VALUE
);
388 case AL_EAXREVERB_LATE_REVERB_GAIN
:
389 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_GAIN
&&
390 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_GAIN
)
391 ALEffect
->Reverb
.LateReverbGain
= flValue
;
393 alSetError(AL_INVALID_VALUE
);
396 case AL_EAXREVERB_LATE_REVERB_DELAY
:
397 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_DELAY
&&
398 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_DELAY
)
399 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
401 alSetError(AL_INVALID_VALUE
);
404 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
405 if(flValue
>= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF
&&
406 flValue
<= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF
)
407 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
409 alSetError(AL_INVALID_VALUE
);
412 case AL_EAXREVERB_ECHO_TIME
:
413 if(flValue
>= AL_EAXREVERB_MIN_ECHO_TIME
&&
414 flValue
<= AL_EAXREVERB_MAX_ECHO_TIME
)
415 ALEffect
->Reverb
.EchoTime
= flValue
;
417 alSetError(AL_INVALID_VALUE
);
420 case AL_EAXREVERB_ECHO_DEPTH
:
421 if(flValue
>= AL_EAXREVERB_MIN_ECHO_DEPTH
&&
422 flValue
<= AL_EAXREVERB_MAX_ECHO_DEPTH
)
423 ALEffect
->Reverb
.EchoDepth
= flValue
;
425 alSetError(AL_INVALID_VALUE
);
428 case AL_EAXREVERB_MODULATION_TIME
:
429 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_TIME
&&
430 flValue
<= AL_EAXREVERB_MAX_MODULATION_TIME
)
431 ALEffect
->Reverb
.ModulationTime
= flValue
;
433 alSetError(AL_INVALID_VALUE
);
436 case AL_EAXREVERB_MODULATION_DEPTH
:
437 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_DEPTH
&&
438 flValue
<= AL_EAXREVERB_MAX_MODULATION_DEPTH
)
439 ALEffect
->Reverb
.ModulationDepth
= flValue
;
441 alSetError(AL_INVALID_VALUE
);
444 case AL_EAXREVERB_HFREFERENCE
:
445 if(flValue
>= AL_EAXREVERB_MIN_HFREFERENCE
&&
446 flValue
<= AL_EAXREVERB_MAX_HFREFERENCE
)
447 ALEffect
->Reverb
.HFReference
= flValue
;
449 alSetError(AL_INVALID_VALUE
);
452 case AL_EAXREVERB_LFREFERENCE
:
453 if(flValue
>= AL_EAXREVERB_MIN_LFREFERENCE
&&
454 flValue
<= AL_EAXREVERB_MAX_LFREFERENCE
)
455 ALEffect
->Reverb
.LFReference
= flValue
;
457 alSetError(AL_INVALID_VALUE
);
460 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
461 if(flValue
>= 0.0f
&& flValue
<= 10.0f
)
462 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
464 alSetError(AL_INVALID_VALUE
);
468 alSetError(AL_INVALID_ENUM
);
472 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
476 case AL_REVERB_DENSITY
:
477 if(flValue
>= AL_REVERB_MIN_DENSITY
&&
478 flValue
<= AL_REVERB_MAX_DENSITY
)
479 ALEffect
->Reverb
.Density
= flValue
;
481 alSetError(AL_INVALID_VALUE
);
484 case AL_REVERB_DIFFUSION
:
485 if(flValue
>= AL_REVERB_MIN_DIFFUSION
&&
486 flValue
<= AL_REVERB_MAX_DIFFUSION
)
487 ALEffect
->Reverb
.Diffusion
= flValue
;
489 alSetError(AL_INVALID_VALUE
);
493 if(flValue
>= AL_REVERB_MIN_GAIN
&&
494 flValue
<= AL_REVERB_MAX_GAIN
)
495 ALEffect
->Reverb
.Gain
= flValue
;
497 alSetError(AL_INVALID_VALUE
);
500 case AL_REVERB_GAINHF
:
501 if(flValue
>= AL_REVERB_MIN_GAINHF
&&
502 flValue
<= AL_REVERB_MAX_GAINHF
)
503 ALEffect
->Reverb
.GainHF
= flValue
;
505 alSetError(AL_INVALID_VALUE
);
508 case AL_REVERB_DECAY_TIME
:
509 if(flValue
>= AL_REVERB_MIN_DECAY_TIME
&&
510 flValue
<= AL_REVERB_MAX_DECAY_TIME
)
511 ALEffect
->Reverb
.DecayTime
= flValue
;
513 alSetError(AL_INVALID_VALUE
);
516 case AL_REVERB_DECAY_HFRATIO
:
517 if(flValue
>= AL_REVERB_MIN_DECAY_HFRATIO
&&
518 flValue
<= AL_REVERB_MAX_DECAY_HFRATIO
)
519 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
521 alSetError(AL_INVALID_VALUE
);
524 case AL_REVERB_REFLECTIONS_GAIN
:
525 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_GAIN
&&
526 flValue
<= AL_REVERB_MAX_REFLECTIONS_GAIN
)
527 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
529 alSetError(AL_INVALID_VALUE
);
532 case AL_REVERB_REFLECTIONS_DELAY
:
533 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_DELAY
&&
534 flValue
<= AL_REVERB_MAX_REFLECTIONS_DELAY
)
535 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
537 alSetError(AL_INVALID_VALUE
);
540 case AL_REVERB_LATE_REVERB_GAIN
:
541 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_GAIN
&&
542 flValue
<= AL_REVERB_MAX_LATE_REVERB_GAIN
)
543 ALEffect
->Reverb
.LateReverbGain
= flValue
;
545 alSetError(AL_INVALID_VALUE
);
548 case AL_REVERB_LATE_REVERB_DELAY
:
549 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_DELAY
&&
550 flValue
<= AL_REVERB_MAX_LATE_REVERB_DELAY
)
551 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
553 alSetError(AL_INVALID_VALUE
);
556 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
557 if(flValue
>= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF
&&
558 flValue
<= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF
)
559 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
561 alSetError(AL_INVALID_VALUE
);
564 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
565 if(flValue
>= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR
&&
566 flValue
<= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR
)
567 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
569 alSetError(AL_INVALID_VALUE
);
573 alSetError(AL_INVALID_ENUM
);
577 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
582 if(flValue
>= AL_ECHO_MIN_DELAY
&& flValue
<= AL_ECHO_MAX_DELAY
)
583 ALEffect
->Echo
.Delay
= flValue
;
585 alSetError(AL_INVALID_VALUE
);
588 case AL_ECHO_LRDELAY
:
589 if(flValue
>= AL_ECHO_MIN_LRDELAY
&& flValue
<= AL_ECHO_MAX_LRDELAY
)
590 ALEffect
->Echo
.LRDelay
= flValue
;
592 alSetError(AL_INVALID_VALUE
);
595 case AL_ECHO_DAMPING
:
596 if(flValue
>= AL_ECHO_MIN_DAMPING
&& flValue
<= AL_ECHO_MAX_DAMPING
)
597 ALEffect
->Echo
.Damping
= flValue
;
599 alSetError(AL_INVALID_VALUE
);
602 case AL_ECHO_FEEDBACK
:
603 if(flValue
>= AL_ECHO_MIN_FEEDBACK
&& flValue
<= AL_ECHO_MAX_FEEDBACK
)
604 ALEffect
->Echo
.Feedback
= flValue
;
606 alSetError(AL_INVALID_VALUE
);
610 if(flValue
>= AL_ECHO_MIN_SPREAD
&& flValue
<= AL_ECHO_MAX_SPREAD
)
611 ALEffect
->Echo
.Spread
= flValue
;
613 alSetError(AL_INVALID_VALUE
);
617 alSetError(AL_INVALID_ENUM
);
622 alSetError(AL_INVALID_ENUM
);
625 alSetError(AL_INVALID_NAME
);
627 ProcessContext(Context
);
630 ALvoid AL_APIENTRY
alEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
634 Context
= alcGetCurrentContext();
635 SuspendContext(Context
);
637 if (effect
&& alIsEffect(effect
))
639 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
641 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
645 case AL_EAXREVERB_DENSITY
:
646 case AL_EAXREVERB_DIFFUSION
:
647 case AL_EAXREVERB_GAIN
:
648 case AL_EAXREVERB_GAINHF
:
649 case AL_EAXREVERB_GAINLF
:
650 case AL_EAXREVERB_DECAY_TIME
:
651 case AL_EAXREVERB_DECAY_HFRATIO
:
652 case AL_EAXREVERB_DECAY_LFRATIO
:
653 case AL_EAXREVERB_REFLECTIONS_GAIN
:
654 case AL_EAXREVERB_REFLECTIONS_DELAY
:
655 case AL_EAXREVERB_LATE_REVERB_GAIN
:
656 case AL_EAXREVERB_LATE_REVERB_DELAY
:
657 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
658 case AL_EAXREVERB_ECHO_TIME
:
659 case AL_EAXREVERB_ECHO_DEPTH
:
660 case AL_EAXREVERB_MODULATION_TIME
:
661 case AL_EAXREVERB_MODULATION_DEPTH
:
662 case AL_EAXREVERB_HFREFERENCE
:
663 case AL_EAXREVERB_LFREFERENCE
:
664 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
665 alEffectf(effect
, param
, pflValues
[0]);
668 case AL_EAXREVERB_REFLECTIONS_PAN
:
669 ALEffect
->Reverb
.ReflectionsPan
[0] = pflValues
[0];
670 ALEffect
->Reverb
.ReflectionsPan
[1] = pflValues
[1];
671 ALEffect
->Reverb
.ReflectionsPan
[2] = pflValues
[2];
673 case AL_EAXREVERB_LATE_REVERB_PAN
:
674 ALEffect
->Reverb
.LateReverbPan
[0] = pflValues
[0];
675 ALEffect
->Reverb
.LateReverbPan
[1] = pflValues
[1];
676 ALEffect
->Reverb
.LateReverbPan
[2] = pflValues
[2];
680 alSetError(AL_INVALID_ENUM
);
684 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
688 case AL_REVERB_DENSITY
:
689 case AL_REVERB_DIFFUSION
:
691 case AL_REVERB_GAINHF
:
692 case AL_REVERB_DECAY_TIME
:
693 case AL_REVERB_DECAY_HFRATIO
:
694 case AL_REVERB_REFLECTIONS_GAIN
:
695 case AL_REVERB_REFLECTIONS_DELAY
:
696 case AL_REVERB_LATE_REVERB_GAIN
:
697 case AL_REVERB_LATE_REVERB_DELAY
:
698 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
699 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
700 alEffectf(effect
, param
, pflValues
[0]);
704 alSetError(AL_INVALID_ENUM
);
708 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
713 case AL_ECHO_LRDELAY
:
714 case AL_ECHO_DAMPING
:
715 case AL_ECHO_FEEDBACK
:
717 alEffectf(effect
, param
, pflValues
[0]);
721 alSetError(AL_INVALID_ENUM
);
726 alSetError(AL_INVALID_ENUM
);
729 alSetError(AL_INVALID_NAME
);
731 ProcessContext(Context
);
734 ALvoid AL_APIENTRY
alGetEffecti(ALuint effect
, ALenum param
, ALint
*piValue
)
738 Context
= alcGetCurrentContext();
739 SuspendContext(Context
);
741 if (effect
&& alIsEffect(effect
))
743 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
745 if(param
== AL_EFFECT_TYPE
)
747 *piValue
= ALEffect
->type
;
749 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
753 case AL_EAXREVERB_DECAY_HFLIMIT
:
754 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
758 alSetError(AL_INVALID_ENUM
);
762 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
766 case AL_REVERB_DECAY_HFLIMIT
:
767 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
771 alSetError(AL_INVALID_ENUM
);
775 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
780 alSetError(AL_INVALID_ENUM
);
785 alSetError(AL_INVALID_ENUM
);
788 alSetError(AL_INVALID_NAME
);
790 ProcessContext(Context
);
793 ALvoid AL_APIENTRY
alGetEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
797 Context
= alcGetCurrentContext();
798 SuspendContext(Context
);
800 if (effect
&& alIsEffect(effect
))
802 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
804 if(param
== AL_EFFECT_TYPE
)
806 alGetEffecti(effect
, param
, piValues
);
808 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
812 case AL_EAXREVERB_DECAY_HFLIMIT
:
813 alGetEffecti(effect
, param
, piValues
);
817 alSetError(AL_INVALID_ENUM
);
821 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
825 case AL_REVERB_DECAY_HFLIMIT
:
826 alGetEffecti(effect
, param
, piValues
);
830 alSetError(AL_INVALID_ENUM
);
834 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
839 alSetError(AL_INVALID_ENUM
);
844 alSetError(AL_INVALID_ENUM
);
847 alSetError(AL_INVALID_NAME
);
849 ProcessContext(Context
);
852 ALvoid AL_APIENTRY
alGetEffectf(ALuint effect
, ALenum param
, ALfloat
*pflValue
)
856 Context
= alcGetCurrentContext();
857 SuspendContext(Context
);
859 if (effect
&& alIsEffect(effect
))
861 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
863 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
867 case AL_EAXREVERB_DENSITY
:
868 *pflValue
= ALEffect
->Reverb
.Density
;
871 case AL_EAXREVERB_DIFFUSION
:
872 *pflValue
= ALEffect
->Reverb
.Diffusion
;
875 case AL_EAXREVERB_GAIN
:
876 *pflValue
= ALEffect
->Reverb
.Gain
;
879 case AL_EAXREVERB_GAINHF
:
880 *pflValue
= ALEffect
->Reverb
.GainHF
;
883 case AL_EAXREVERB_GAINLF
:
884 *pflValue
= ALEffect
->Reverb
.GainLF
;
887 case AL_EAXREVERB_DECAY_TIME
:
888 *pflValue
= ALEffect
->Reverb
.DecayTime
;
891 case AL_EAXREVERB_DECAY_HFRATIO
:
892 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
895 case AL_EAXREVERB_DECAY_LFRATIO
:
896 *pflValue
= ALEffect
->Reverb
.DecayLFRatio
;
899 case AL_EAXREVERB_REFLECTIONS_GAIN
:
900 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
903 case AL_EAXREVERB_REFLECTIONS_DELAY
:
904 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
907 case AL_EAXREVERB_LATE_REVERB_GAIN
:
908 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
911 case AL_EAXREVERB_LATE_REVERB_DELAY
:
912 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
915 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
916 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
919 case AL_EAXREVERB_ECHO_TIME
:
920 *pflValue
= ALEffect
->Reverb
.EchoTime
;
923 case AL_EAXREVERB_ECHO_DEPTH
:
924 *pflValue
= ALEffect
->Reverb
.EchoDepth
;
927 case AL_EAXREVERB_MODULATION_TIME
:
928 *pflValue
= ALEffect
->Reverb
.ModulationTime
;
931 case AL_EAXREVERB_MODULATION_DEPTH
:
932 *pflValue
= ALEffect
->Reverb
.ModulationDepth
;
935 case AL_EAXREVERB_HFREFERENCE
:
936 *pflValue
= ALEffect
->Reverb
.HFReference
;
939 case AL_EAXREVERB_LFREFERENCE
:
940 *pflValue
= ALEffect
->Reverb
.LFReference
;
943 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
944 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
948 alSetError(AL_INVALID_ENUM
);
952 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
956 case AL_REVERB_DENSITY
:
957 *pflValue
= ALEffect
->Reverb
.Density
;
960 case AL_REVERB_DIFFUSION
:
961 *pflValue
= ALEffect
->Reverb
.Diffusion
;
965 *pflValue
= ALEffect
->Reverb
.Gain
;
968 case AL_REVERB_GAINHF
:
969 *pflValue
= ALEffect
->Reverb
.GainHF
;
972 case AL_REVERB_DECAY_TIME
:
973 *pflValue
= ALEffect
->Reverb
.DecayTime
;
976 case AL_REVERB_DECAY_HFRATIO
:
977 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
980 case AL_REVERB_REFLECTIONS_GAIN
:
981 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
984 case AL_REVERB_REFLECTIONS_DELAY
:
985 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
988 case AL_REVERB_LATE_REVERB_GAIN
:
989 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
992 case AL_REVERB_LATE_REVERB_DELAY
:
993 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
996 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
997 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
1000 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1001 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
1005 alSetError(AL_INVALID_ENUM
);
1009 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1014 *pflValue
= ALEffect
->Echo
.Delay
;
1017 case AL_ECHO_LRDELAY
:
1018 *pflValue
= ALEffect
->Echo
.LRDelay
;
1021 case AL_ECHO_DAMPING
:
1022 *pflValue
= ALEffect
->Echo
.Damping
;
1025 case AL_ECHO_FEEDBACK
:
1026 *pflValue
= ALEffect
->Echo
.Feedback
;
1029 case AL_ECHO_SPREAD
:
1030 *pflValue
= ALEffect
->Echo
.Spread
;
1034 alSetError(AL_INVALID_ENUM
);
1039 alSetError(AL_INVALID_ENUM
);
1042 alSetError(AL_INVALID_NAME
);
1044 ProcessContext(Context
);
1047 ALvoid AL_APIENTRY
alGetEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
1049 ALCcontext
*Context
;
1051 Context
= alcGetCurrentContext();
1052 SuspendContext(Context
);
1054 if (effect
&& alIsEffect(effect
))
1056 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
1058 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
1062 case AL_EAXREVERB_DENSITY
:
1063 case AL_EAXREVERB_DIFFUSION
:
1064 case AL_EAXREVERB_GAIN
:
1065 case AL_EAXREVERB_GAINHF
:
1066 case AL_EAXREVERB_GAINLF
:
1067 case AL_EAXREVERB_DECAY_TIME
:
1068 case AL_EAXREVERB_DECAY_HFRATIO
:
1069 case AL_EAXREVERB_DECAY_LFRATIO
:
1070 case AL_EAXREVERB_REFLECTIONS_GAIN
:
1071 case AL_EAXREVERB_REFLECTIONS_DELAY
:
1072 case AL_EAXREVERB_LATE_REVERB_GAIN
:
1073 case AL_EAXREVERB_LATE_REVERB_DELAY
:
1074 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
1075 case AL_EAXREVERB_ECHO_TIME
:
1076 case AL_EAXREVERB_ECHO_DEPTH
:
1077 case AL_EAXREVERB_MODULATION_TIME
:
1078 case AL_EAXREVERB_MODULATION_DEPTH
:
1079 case AL_EAXREVERB_HFREFERENCE
:
1080 case AL_EAXREVERB_LFREFERENCE
:
1081 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
1082 alGetEffectf(effect
, param
, pflValues
);
1085 case AL_EAXREVERB_REFLECTIONS_PAN
:
1086 pflValues
[0] = ALEffect
->Reverb
.ReflectionsPan
[0];
1087 pflValues
[1] = ALEffect
->Reverb
.ReflectionsPan
[1];
1088 pflValues
[2] = ALEffect
->Reverb
.ReflectionsPan
[2];
1090 case AL_EAXREVERB_LATE_REVERB_PAN
:
1091 pflValues
[0] = ALEffect
->Reverb
.LateReverbPan
[0];
1092 pflValues
[1] = ALEffect
->Reverb
.LateReverbPan
[1];
1093 pflValues
[2] = ALEffect
->Reverb
.LateReverbPan
[2];
1097 alSetError(AL_INVALID_ENUM
);
1101 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
1105 case AL_REVERB_DENSITY
:
1106 case AL_REVERB_DIFFUSION
:
1107 case AL_REVERB_GAIN
:
1108 case AL_REVERB_GAINHF
:
1109 case AL_REVERB_DECAY_TIME
:
1110 case AL_REVERB_DECAY_HFRATIO
:
1111 case AL_REVERB_REFLECTIONS_GAIN
:
1112 case AL_REVERB_REFLECTIONS_DELAY
:
1113 case AL_REVERB_LATE_REVERB_GAIN
:
1114 case AL_REVERB_LATE_REVERB_DELAY
:
1115 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1116 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1117 alGetEffectf(effect
, param
, pflValues
);
1121 alSetError(AL_INVALID_ENUM
);
1125 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1130 case AL_ECHO_LRDELAY
:
1131 case AL_ECHO_DAMPING
:
1132 case AL_ECHO_FEEDBACK
:
1133 case AL_ECHO_SPREAD
:
1134 alGetEffectf(effect
, param
, pflValues
);
1138 alSetError(AL_INVALID_ENUM
);
1143 alSetError(AL_INVALID_ENUM
);
1146 alSetError(AL_INVALID_NAME
);
1148 ProcessContext(Context
);
1152 ALvoid
ReleaseALEffects(ALvoid
)
1155 if(g_EffectCount
> 0)
1156 AL_PRINT("exit(): deleting %d Effect(s)\n", g_EffectCount
);
1161 ALeffect
*temp
= g_EffectList
;
1162 g_EffectList
= g_EffectList
->next
;
1164 // Release effect structure
1165 memset(temp
, 0, sizeof(ALeffect
));
1172 static void InitEffectParams(ALeffect
*effect
, ALenum type
)
1174 effect
->type
= type
;
1177 /* NOTE: Standard reverb and EAX reverb use the same defaults for the
1178 * shared parameters, and EAX's additional parameters default to
1179 * values assumed by standard reverb.
1181 case AL_EFFECT_EAXREVERB
:
1182 case AL_EFFECT_REVERB
:
1183 effect
->Reverb
.Density
= AL_EAXREVERB_DEFAULT_DENSITY
;
1184 effect
->Reverb
.Diffusion
= AL_EAXREVERB_DEFAULT_DIFFUSION
;
1185 effect
->Reverb
.Gain
= AL_EAXREVERB_DEFAULT_GAIN
;
1186 effect
->Reverb
.GainHF
= AL_EAXREVERB_DEFAULT_GAINHF
;
1187 effect
->Reverb
.GainLF
= AL_EAXREVERB_DEFAULT_GAINLF
;
1188 effect
->Reverb
.DecayTime
= AL_EAXREVERB_DEFAULT_DECAY_TIME
;
1189 effect
->Reverb
.DecayHFRatio
= AL_EAXREVERB_DEFAULT_DECAY_HFRATIO
;
1190 effect
->Reverb
.DecayLFRatio
= AL_EAXREVERB_DEFAULT_DECAY_LFRATIO
;
1191 effect
->Reverb
.ReflectionsGain
= AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN
;
1192 effect
->Reverb
.ReflectionsDelay
= AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY
;
1193 effect
->Reverb
.ReflectionsPan
[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1194 effect
->Reverb
.ReflectionsPan
[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1195 effect
->Reverb
.ReflectionsPan
[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1196 effect
->Reverb
.LateReverbGain
= AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN
;
1197 effect
->Reverb
.LateReverbDelay
= AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY
;
1198 effect
->Reverb
.LateReverbPan
[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1199 effect
->Reverb
.LateReverbPan
[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1200 effect
->Reverb
.LateReverbPan
[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1201 effect
->Reverb
.EchoTime
= AL_EAXREVERB_DEFAULT_ECHO_TIME
;
1202 effect
->Reverb
.EchoDepth
= AL_EAXREVERB_DEFAULT_ECHO_DEPTH
;
1203 effect
->Reverb
.ModulationTime
= AL_EAXREVERB_DEFAULT_MODULATION_TIME
;
1204 effect
->Reverb
.ModulationDepth
= AL_EAXREVERB_DEFAULT_MODULATION_DEPTH
;
1205 effect
->Reverb
.AirAbsorptionGainHF
= AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF
;
1206 effect
->Reverb
.HFReference
= AL_EAXREVERB_DEFAULT_HFREFERENCE
;
1207 effect
->Reverb
.LFReference
= AL_EAXREVERB_DEFAULT_LFREFERENCE
;
1208 effect
->Reverb
.RoomRolloffFactor
= AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR
;
1209 effect
->Reverb
.DecayHFLimit
= AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT
;
1211 case AL_EFFECT_ECHO
:
1212 effect
->Echo
.Delay
= AL_ECHO_DEFAULT_DELAY
;
1213 effect
->Echo
.LRDelay
= AL_ECHO_DEFAULT_LRDELAY
;
1214 effect
->Echo
.Damping
= AL_ECHO_DEFAULT_DAMPING
;
1215 effect
->Echo
.Feedback
= AL_ECHO_DEFAULT_FEEDBACK
;
1216 effect
->Echo
.Spread
= AL_ECHO_DEFAULT_SPREAD
;