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 ALeffect
*g_EffectList
;
38 static ALuint g_EffectCount
;
40 static void InitEffectParams(ALeffect
*effect
, ALenum type
);
43 ALvoid AL_APIENTRY
alGenEffects(ALsizei n
, ALuint
*effects
)
48 Context
= alcGetCurrentContext();
49 SuspendContext(Context
);
53 // Check that enough memory has been allocted in the 'effects' array for n Effects
54 if (!IsBadWritePtr((void*)effects
, n
* sizeof(ALuint
)))
56 ALeffect
**list
= &g_EffectList
;
58 list
= &(*list
)->next
;
63 *list
= calloc(1, sizeof(ALeffect
));
66 // We must have run out or memory
67 alDeleteEffects(i
, effects
);
68 alSetError(AL_OUT_OF_MEMORY
);
72 effects
[i
] = (ALuint
)ALTHUNK_ADDENTRY(*list
);
73 (*list
)->effect
= effects
[i
];
75 InitEffectParams(*list
, AL_EFFECT_NULL
);
79 list
= &(*list
)->next
;
84 ProcessContext(Context
);
87 ALvoid AL_APIENTRY
alDeleteEffects(ALsizei n
, ALuint
*effects
)
93 Context
= alcGetCurrentContext();
94 SuspendContext(Context
);
98 // Check that all effects are valid
99 for (i
= 0; i
< n
; i
++)
101 if (!alIsEffect(effects
[i
]))
103 alSetError(AL_INVALID_NAME
);
110 // All effects are valid
111 for (i
= 0; i
< n
; i
++)
113 // Recheck that the effect is valid, because there could be duplicated names
114 if (effects
[i
] && alIsEffect(effects
[i
]))
118 ALEffect
= ((ALeffect
*)ALTHUNK_LOOKUPENTRY(effects
[i
]));
120 // Remove Source from list of Sources
121 list
= &g_EffectList
;
122 while(*list
&& *list
!= ALEffect
)
123 list
= &(*list
)->next
;
126 *list
= (*list
)->next
;
127 ALTHUNK_REMOVEENTRY(ALEffect
->effect
);
129 memset(ALEffect
, 0, sizeof(ALeffect
));
138 alSetError(AL_INVALID_VALUE
);
140 ProcessContext(Context
);
143 ALboolean AL_APIENTRY
alIsEffect(ALuint effect
)
148 Context
= alcGetCurrentContext();
149 SuspendContext(Context
);
151 list
= &g_EffectList
;
152 while(*list
&& (*list
)->effect
!= effect
)
153 list
= &(*list
)->next
;
155 ProcessContext(Context
);
157 return ((*list
|| !effect
) ? AL_TRUE
: AL_FALSE
);
160 ALvoid AL_APIENTRY
alEffecti(ALuint effect
, ALenum param
, ALint iValue
)
164 Context
= alcGetCurrentContext();
165 SuspendContext(Context
);
167 if (effect
&& alIsEffect(effect
))
169 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
171 if(param
== AL_EFFECT_TYPE
)
173 ALboolean isOk
= (iValue
== AL_EFFECT_NULL
||
174 (iValue
== AL_EFFECT_EAXREVERB
&& !DisabledEffects
[EAXREVERB
]) ||
175 (iValue
== AL_EFFECT_REVERB
&& !DisabledEffects
[REVERB
]) ||
176 (iValue
== AL_EFFECT_ECHO
&& !DisabledEffects
[ECHO
]));
179 InitEffectParams(ALEffect
, iValue
);
181 alSetError(AL_INVALID_VALUE
);
183 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
187 case AL_EAXREVERB_DECAY_HFLIMIT
:
188 if(iValue
>= AL_EAXREVERB_MIN_DECAY_HFLIMIT
&&
189 iValue
<= AL_EAXREVERB_MAX_DECAY_HFLIMIT
)
190 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
192 alSetError(AL_INVALID_VALUE
);
196 alSetError(AL_INVALID_ENUM
);
200 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
204 case AL_REVERB_DECAY_HFLIMIT
:
205 if(iValue
>= AL_REVERB_MIN_DECAY_HFLIMIT
&&
206 iValue
<= AL_REVERB_MAX_DECAY_HFLIMIT
)
207 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
209 alSetError(AL_INVALID_VALUE
);
213 alSetError(AL_INVALID_ENUM
);
217 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
222 alSetError(AL_INVALID_ENUM
);
227 alSetError(AL_INVALID_ENUM
);
230 alSetError(AL_INVALID_NAME
);
232 ProcessContext(Context
);
235 ALvoid AL_APIENTRY
alEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
239 Context
= alcGetCurrentContext();
240 SuspendContext(Context
);
242 if (effect
&& alIsEffect(effect
))
244 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
246 if(param
== AL_EFFECT_TYPE
)
248 alEffecti(effect
, param
, piValues
[0]);
250 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
254 case AL_EAXREVERB_DECAY_HFLIMIT
:
255 alEffecti(effect
, param
, piValues
[0]);
259 alSetError(AL_INVALID_ENUM
);
263 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
267 case AL_REVERB_DECAY_HFLIMIT
:
268 alEffecti(effect
, param
, piValues
[0]);
272 alSetError(AL_INVALID_ENUM
);
276 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
281 alSetError(AL_INVALID_ENUM
);
286 alSetError(AL_INVALID_ENUM
);
289 alSetError(AL_INVALID_NAME
);
291 ProcessContext(Context
);
294 ALvoid AL_APIENTRY
alEffectf(ALuint effect
, ALenum param
, ALfloat flValue
)
298 Context
= alcGetCurrentContext();
299 SuspendContext(Context
);
301 if (effect
&& alIsEffect(effect
))
303 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
305 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
309 case AL_EAXREVERB_DENSITY
:
310 if(flValue
>= AL_EAXREVERB_MIN_DENSITY
&&
311 flValue
<= AL_EAXREVERB_MAX_DENSITY
)
312 ALEffect
->Reverb
.Density
= flValue
;
314 alSetError(AL_INVALID_VALUE
);
317 case AL_EAXREVERB_DIFFUSION
:
318 if(flValue
>= AL_EAXREVERB_MIN_DIFFUSION
&&
319 flValue
<= AL_EAXREVERB_MAX_DIFFUSION
)
320 ALEffect
->Reverb
.Diffusion
= flValue
;
322 alSetError(AL_INVALID_VALUE
);
325 case AL_EAXREVERB_GAIN
:
326 if(flValue
>= AL_EAXREVERB_MIN_GAIN
&&
327 flValue
<= AL_EAXREVERB_MAX_GAIN
)
328 ALEffect
->Reverb
.Gain
= flValue
;
330 alSetError(AL_INVALID_VALUE
);
333 case AL_EAXREVERB_GAINHF
:
334 if(flValue
>= AL_EAXREVERB_MIN_GAINHF
&&
335 flValue
<= AL_EAXREVERB_MAX_GAIN
)
336 ALEffect
->Reverb
.GainHF
= flValue
;
338 alSetError(AL_INVALID_VALUE
);
341 case AL_EAXREVERB_GAINLF
:
342 if(flValue
>= AL_EAXREVERB_MIN_GAINLF
&&
343 flValue
<= AL_EAXREVERB_MAX_GAINLF
)
344 ALEffect
->Reverb
.GainLF
= flValue
;
346 alSetError(AL_INVALID_VALUE
);
349 case AL_EAXREVERB_DECAY_TIME
:
350 if(flValue
>= AL_EAXREVERB_MIN_DECAY_TIME
&&
351 flValue
<= AL_EAXREVERB_MAX_DECAY_TIME
)
352 ALEffect
->Reverb
.DecayTime
= flValue
;
354 alSetError(AL_INVALID_VALUE
);
357 case AL_EAXREVERB_DECAY_HFRATIO
:
358 if(flValue
>= AL_EAXREVERB_MIN_DECAY_HFRATIO
&&
359 flValue
<= AL_EAXREVERB_MAX_DECAY_HFRATIO
)
360 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
362 alSetError(AL_INVALID_VALUE
);
365 case AL_EAXREVERB_DECAY_LFRATIO
:
366 if(flValue
>= AL_EAXREVERB_MIN_DECAY_LFRATIO
&&
367 flValue
<= AL_EAXREVERB_MAX_DECAY_LFRATIO
)
368 ALEffect
->Reverb
.DecayLFRatio
= flValue
;
370 alSetError(AL_INVALID_VALUE
);
373 case AL_EAXREVERB_REFLECTIONS_GAIN
:
374 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_GAIN
&&
375 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_GAIN
)
376 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
378 alSetError(AL_INVALID_VALUE
);
381 case AL_EAXREVERB_REFLECTIONS_DELAY
:
382 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_DELAY
&&
383 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_DELAY
)
384 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
386 alSetError(AL_INVALID_VALUE
);
389 case AL_EAXREVERB_LATE_REVERB_GAIN
:
390 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_GAIN
&&
391 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_GAIN
)
392 ALEffect
->Reverb
.LateReverbGain
= flValue
;
394 alSetError(AL_INVALID_VALUE
);
397 case AL_EAXREVERB_LATE_REVERB_DELAY
:
398 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_DELAY
&&
399 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_DELAY
)
400 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
402 alSetError(AL_INVALID_VALUE
);
405 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
406 if(flValue
>= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF
&&
407 flValue
<= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF
)
408 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
410 alSetError(AL_INVALID_VALUE
);
413 case AL_EAXREVERB_ECHO_TIME
:
414 if(flValue
>= AL_EAXREVERB_MIN_ECHO_TIME
&&
415 flValue
<= AL_EAXREVERB_MAX_ECHO_TIME
)
416 ALEffect
->Reverb
.EchoTime
= flValue
;
418 alSetError(AL_INVALID_VALUE
);
421 case AL_EAXREVERB_ECHO_DEPTH
:
422 if(flValue
>= AL_EAXREVERB_MIN_ECHO_DEPTH
&&
423 flValue
<= AL_EAXREVERB_MAX_ECHO_DEPTH
)
424 ALEffect
->Reverb
.EchoDepth
= flValue
;
426 alSetError(AL_INVALID_VALUE
);
429 case AL_EAXREVERB_MODULATION_TIME
:
430 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_TIME
&&
431 flValue
<= AL_EAXREVERB_MAX_MODULATION_TIME
)
432 ALEffect
->Reverb
.ModulationTime
= flValue
;
434 alSetError(AL_INVALID_VALUE
);
437 case AL_EAXREVERB_MODULATION_DEPTH
:
438 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_DEPTH
&&
439 flValue
<= AL_EAXREVERB_MAX_MODULATION_DEPTH
)
440 ALEffect
->Reverb
.ModulationDepth
= flValue
;
442 alSetError(AL_INVALID_VALUE
);
445 case AL_EAXREVERB_HFREFERENCE
:
446 if(flValue
>= AL_EAXREVERB_MIN_HFREFERENCE
&&
447 flValue
<= AL_EAXREVERB_MAX_HFREFERENCE
)
448 ALEffect
->Reverb
.HFReference
= flValue
;
450 alSetError(AL_INVALID_VALUE
);
453 case AL_EAXREVERB_LFREFERENCE
:
454 if(flValue
>= AL_EAXREVERB_MIN_LFREFERENCE
&&
455 flValue
<= AL_EAXREVERB_MAX_LFREFERENCE
)
456 ALEffect
->Reverb
.LFReference
= flValue
;
458 alSetError(AL_INVALID_VALUE
);
461 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
462 if(flValue
>= 0.0f
&& flValue
<= 10.0f
)
463 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
465 alSetError(AL_INVALID_VALUE
);
469 alSetError(AL_INVALID_ENUM
);
473 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
477 case AL_REVERB_DENSITY
:
478 if(flValue
>= AL_REVERB_MIN_DENSITY
&&
479 flValue
<= AL_REVERB_MAX_DENSITY
)
480 ALEffect
->Reverb
.Density
= flValue
;
482 alSetError(AL_INVALID_VALUE
);
485 case AL_REVERB_DIFFUSION
:
486 if(flValue
>= AL_REVERB_MIN_DIFFUSION
&&
487 flValue
<= AL_REVERB_MAX_DIFFUSION
)
488 ALEffect
->Reverb
.Diffusion
= flValue
;
490 alSetError(AL_INVALID_VALUE
);
494 if(flValue
>= AL_REVERB_MIN_GAIN
&&
495 flValue
<= AL_REVERB_MAX_GAIN
)
496 ALEffect
->Reverb
.Gain
= flValue
;
498 alSetError(AL_INVALID_VALUE
);
501 case AL_REVERB_GAINHF
:
502 if(flValue
>= AL_REVERB_MIN_GAINHF
&&
503 flValue
<= AL_REVERB_MAX_GAINHF
)
504 ALEffect
->Reverb
.GainHF
= flValue
;
506 alSetError(AL_INVALID_VALUE
);
509 case AL_REVERB_DECAY_TIME
:
510 if(flValue
>= AL_REVERB_MIN_DECAY_TIME
&&
511 flValue
<= AL_REVERB_MAX_DECAY_TIME
)
512 ALEffect
->Reverb
.DecayTime
= flValue
;
514 alSetError(AL_INVALID_VALUE
);
517 case AL_REVERB_DECAY_HFRATIO
:
518 if(flValue
>= AL_REVERB_MIN_DECAY_HFRATIO
&&
519 flValue
<= AL_REVERB_MAX_DECAY_HFRATIO
)
520 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
522 alSetError(AL_INVALID_VALUE
);
525 case AL_REVERB_REFLECTIONS_GAIN
:
526 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_GAIN
&&
527 flValue
<= AL_REVERB_MAX_REFLECTIONS_GAIN
)
528 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
530 alSetError(AL_INVALID_VALUE
);
533 case AL_REVERB_REFLECTIONS_DELAY
:
534 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_DELAY
&&
535 flValue
<= AL_REVERB_MAX_REFLECTIONS_DELAY
)
536 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
538 alSetError(AL_INVALID_VALUE
);
541 case AL_REVERB_LATE_REVERB_GAIN
:
542 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_GAIN
&&
543 flValue
<= AL_REVERB_MAX_LATE_REVERB_GAIN
)
544 ALEffect
->Reverb
.LateReverbGain
= flValue
;
546 alSetError(AL_INVALID_VALUE
);
549 case AL_REVERB_LATE_REVERB_DELAY
:
550 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_DELAY
&&
551 flValue
<= AL_REVERB_MAX_LATE_REVERB_DELAY
)
552 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
554 alSetError(AL_INVALID_VALUE
);
557 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
558 if(flValue
>= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF
&&
559 flValue
<= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF
)
560 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
562 alSetError(AL_INVALID_VALUE
);
565 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
566 if(flValue
>= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR
&&
567 flValue
<= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR
)
568 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
570 alSetError(AL_INVALID_VALUE
);
574 alSetError(AL_INVALID_ENUM
);
578 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
583 if(flValue
>= AL_ECHO_MIN_DELAY
&& flValue
<= AL_ECHO_MAX_DELAY
)
584 ALEffect
->Echo
.Delay
= flValue
;
586 alSetError(AL_INVALID_VALUE
);
589 case AL_ECHO_LRDELAY
:
590 if(flValue
>= AL_ECHO_MIN_LRDELAY
&& flValue
<= AL_ECHO_MAX_LRDELAY
)
591 ALEffect
->Echo
.LRDelay
= flValue
;
593 alSetError(AL_INVALID_VALUE
);
596 case AL_ECHO_DAMPING
:
597 if(flValue
>= AL_ECHO_MIN_DAMPING
&& flValue
<= AL_ECHO_MAX_DAMPING
)
598 ALEffect
->Echo
.Damping
= flValue
;
600 alSetError(AL_INVALID_VALUE
);
603 case AL_ECHO_FEEDBACK
:
604 if(flValue
>= AL_ECHO_MIN_FEEDBACK
&& flValue
<= AL_ECHO_MAX_FEEDBACK
)
605 ALEffect
->Echo
.Feedback
= flValue
;
607 alSetError(AL_INVALID_VALUE
);
611 if(flValue
>= AL_ECHO_MIN_SPREAD
&& flValue
<= AL_ECHO_MAX_SPREAD
)
612 ALEffect
->Echo
.Spread
= flValue
;
614 alSetError(AL_INVALID_VALUE
);
618 alSetError(AL_INVALID_ENUM
);
623 alSetError(AL_INVALID_ENUM
);
626 alSetError(AL_INVALID_NAME
);
628 ProcessContext(Context
);
631 ALvoid AL_APIENTRY
alEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
635 Context
= alcGetCurrentContext();
636 SuspendContext(Context
);
638 if (effect
&& alIsEffect(effect
))
640 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
642 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
646 case AL_EAXREVERB_DENSITY
:
647 case AL_EAXREVERB_DIFFUSION
:
648 case AL_EAXREVERB_GAIN
:
649 case AL_EAXREVERB_GAINHF
:
650 case AL_EAXREVERB_GAINLF
:
651 case AL_EAXREVERB_DECAY_TIME
:
652 case AL_EAXREVERB_DECAY_HFRATIO
:
653 case AL_EAXREVERB_DECAY_LFRATIO
:
654 case AL_EAXREVERB_REFLECTIONS_GAIN
:
655 case AL_EAXREVERB_REFLECTIONS_DELAY
:
656 case AL_EAXREVERB_LATE_REVERB_GAIN
:
657 case AL_EAXREVERB_LATE_REVERB_DELAY
:
658 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
659 case AL_EAXREVERB_ECHO_TIME
:
660 case AL_EAXREVERB_ECHO_DEPTH
:
661 case AL_EAXREVERB_MODULATION_TIME
:
662 case AL_EAXREVERB_MODULATION_DEPTH
:
663 case AL_EAXREVERB_HFREFERENCE
:
664 case AL_EAXREVERB_LFREFERENCE
:
665 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
666 alEffectf(effect
, param
, pflValues
[0]);
669 case AL_EAXREVERB_REFLECTIONS_PAN
:
670 if(!isnan(pflValues
[0]) && !isnan(pflValues
[1]) && !isnan(pflValues
[2]))
672 ALEffect
->Reverb
.ReflectionsPan
[0] = pflValues
[0];
673 ALEffect
->Reverb
.ReflectionsPan
[1] = pflValues
[1];
674 ALEffect
->Reverb
.ReflectionsPan
[2] = pflValues
[2];
677 alSetError(AL_INVALID_VALUE
);
679 case AL_EAXREVERB_LATE_REVERB_PAN
:
680 if(!isnan(pflValues
[0]) && !isnan(pflValues
[1]) && !isnan(pflValues
[2]))
682 ALEffect
->Reverb
.LateReverbPan
[0] = pflValues
[0];
683 ALEffect
->Reverb
.LateReverbPan
[1] = pflValues
[1];
684 ALEffect
->Reverb
.LateReverbPan
[2] = pflValues
[2];
687 alSetError(AL_INVALID_VALUE
);
691 alSetError(AL_INVALID_ENUM
);
695 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
699 case AL_REVERB_DENSITY
:
700 case AL_REVERB_DIFFUSION
:
702 case AL_REVERB_GAINHF
:
703 case AL_REVERB_DECAY_TIME
:
704 case AL_REVERB_DECAY_HFRATIO
:
705 case AL_REVERB_REFLECTIONS_GAIN
:
706 case AL_REVERB_REFLECTIONS_DELAY
:
707 case AL_REVERB_LATE_REVERB_GAIN
:
708 case AL_REVERB_LATE_REVERB_DELAY
:
709 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
710 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
711 alEffectf(effect
, param
, pflValues
[0]);
715 alSetError(AL_INVALID_ENUM
);
719 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
724 case AL_ECHO_LRDELAY
:
725 case AL_ECHO_DAMPING
:
726 case AL_ECHO_FEEDBACK
:
728 alEffectf(effect
, param
, pflValues
[0]);
732 alSetError(AL_INVALID_ENUM
);
737 alSetError(AL_INVALID_ENUM
);
740 alSetError(AL_INVALID_NAME
);
742 ProcessContext(Context
);
745 ALvoid AL_APIENTRY
alGetEffecti(ALuint effect
, ALenum param
, ALint
*piValue
)
749 Context
= alcGetCurrentContext();
750 SuspendContext(Context
);
752 if (effect
&& alIsEffect(effect
))
754 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
756 if(param
== AL_EFFECT_TYPE
)
758 *piValue
= ALEffect
->type
;
760 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
764 case AL_EAXREVERB_DECAY_HFLIMIT
:
765 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
769 alSetError(AL_INVALID_ENUM
);
773 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
777 case AL_REVERB_DECAY_HFLIMIT
:
778 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
782 alSetError(AL_INVALID_ENUM
);
786 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
791 alSetError(AL_INVALID_ENUM
);
796 alSetError(AL_INVALID_ENUM
);
799 alSetError(AL_INVALID_NAME
);
801 ProcessContext(Context
);
804 ALvoid AL_APIENTRY
alGetEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
808 Context
= alcGetCurrentContext();
809 SuspendContext(Context
);
811 if (effect
&& alIsEffect(effect
))
813 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
815 if(param
== AL_EFFECT_TYPE
)
817 alGetEffecti(effect
, param
, piValues
);
819 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
823 case AL_EAXREVERB_DECAY_HFLIMIT
:
824 alGetEffecti(effect
, param
, piValues
);
828 alSetError(AL_INVALID_ENUM
);
832 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
836 case AL_REVERB_DECAY_HFLIMIT
:
837 alGetEffecti(effect
, param
, piValues
);
841 alSetError(AL_INVALID_ENUM
);
845 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
850 alSetError(AL_INVALID_ENUM
);
855 alSetError(AL_INVALID_ENUM
);
858 alSetError(AL_INVALID_NAME
);
860 ProcessContext(Context
);
863 ALvoid AL_APIENTRY
alGetEffectf(ALuint effect
, ALenum param
, ALfloat
*pflValue
)
867 Context
= alcGetCurrentContext();
868 SuspendContext(Context
);
870 if (effect
&& alIsEffect(effect
))
872 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
874 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
878 case AL_EAXREVERB_DENSITY
:
879 *pflValue
= ALEffect
->Reverb
.Density
;
882 case AL_EAXREVERB_DIFFUSION
:
883 *pflValue
= ALEffect
->Reverb
.Diffusion
;
886 case AL_EAXREVERB_GAIN
:
887 *pflValue
= ALEffect
->Reverb
.Gain
;
890 case AL_EAXREVERB_GAINHF
:
891 *pflValue
= ALEffect
->Reverb
.GainHF
;
894 case AL_EAXREVERB_GAINLF
:
895 *pflValue
= ALEffect
->Reverb
.GainLF
;
898 case AL_EAXREVERB_DECAY_TIME
:
899 *pflValue
= ALEffect
->Reverb
.DecayTime
;
902 case AL_EAXREVERB_DECAY_HFRATIO
:
903 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
906 case AL_EAXREVERB_DECAY_LFRATIO
:
907 *pflValue
= ALEffect
->Reverb
.DecayLFRatio
;
910 case AL_EAXREVERB_REFLECTIONS_GAIN
:
911 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
914 case AL_EAXREVERB_REFLECTIONS_DELAY
:
915 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
918 case AL_EAXREVERB_LATE_REVERB_GAIN
:
919 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
922 case AL_EAXREVERB_LATE_REVERB_DELAY
:
923 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
926 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
927 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
930 case AL_EAXREVERB_ECHO_TIME
:
931 *pflValue
= ALEffect
->Reverb
.EchoTime
;
934 case AL_EAXREVERB_ECHO_DEPTH
:
935 *pflValue
= ALEffect
->Reverb
.EchoDepth
;
938 case AL_EAXREVERB_MODULATION_TIME
:
939 *pflValue
= ALEffect
->Reverb
.ModulationTime
;
942 case AL_EAXREVERB_MODULATION_DEPTH
:
943 *pflValue
= ALEffect
->Reverb
.ModulationDepth
;
946 case AL_EAXREVERB_HFREFERENCE
:
947 *pflValue
= ALEffect
->Reverb
.HFReference
;
950 case AL_EAXREVERB_LFREFERENCE
:
951 *pflValue
= ALEffect
->Reverb
.LFReference
;
954 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
955 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
959 alSetError(AL_INVALID_ENUM
);
963 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
967 case AL_REVERB_DENSITY
:
968 *pflValue
= ALEffect
->Reverb
.Density
;
971 case AL_REVERB_DIFFUSION
:
972 *pflValue
= ALEffect
->Reverb
.Diffusion
;
976 *pflValue
= ALEffect
->Reverb
.Gain
;
979 case AL_REVERB_GAINHF
:
980 *pflValue
= ALEffect
->Reverb
.GainHF
;
983 case AL_REVERB_DECAY_TIME
:
984 *pflValue
= ALEffect
->Reverb
.DecayTime
;
987 case AL_REVERB_DECAY_HFRATIO
:
988 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
991 case AL_REVERB_REFLECTIONS_GAIN
:
992 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
995 case AL_REVERB_REFLECTIONS_DELAY
:
996 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
999 case AL_REVERB_LATE_REVERB_GAIN
:
1000 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
1003 case AL_REVERB_LATE_REVERB_DELAY
:
1004 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
1007 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1008 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
1011 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1012 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
1016 alSetError(AL_INVALID_ENUM
);
1020 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1025 *pflValue
= ALEffect
->Echo
.Delay
;
1028 case AL_ECHO_LRDELAY
:
1029 *pflValue
= ALEffect
->Echo
.LRDelay
;
1032 case AL_ECHO_DAMPING
:
1033 *pflValue
= ALEffect
->Echo
.Damping
;
1036 case AL_ECHO_FEEDBACK
:
1037 *pflValue
= ALEffect
->Echo
.Feedback
;
1040 case AL_ECHO_SPREAD
:
1041 *pflValue
= ALEffect
->Echo
.Spread
;
1045 alSetError(AL_INVALID_ENUM
);
1050 alSetError(AL_INVALID_ENUM
);
1053 alSetError(AL_INVALID_NAME
);
1055 ProcessContext(Context
);
1058 ALvoid AL_APIENTRY
alGetEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
1060 ALCcontext
*Context
;
1062 Context
= alcGetCurrentContext();
1063 SuspendContext(Context
);
1065 if (effect
&& alIsEffect(effect
))
1067 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
1069 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
1073 case AL_EAXREVERB_DENSITY
:
1074 case AL_EAXREVERB_DIFFUSION
:
1075 case AL_EAXREVERB_GAIN
:
1076 case AL_EAXREVERB_GAINHF
:
1077 case AL_EAXREVERB_GAINLF
:
1078 case AL_EAXREVERB_DECAY_TIME
:
1079 case AL_EAXREVERB_DECAY_HFRATIO
:
1080 case AL_EAXREVERB_DECAY_LFRATIO
:
1081 case AL_EAXREVERB_REFLECTIONS_GAIN
:
1082 case AL_EAXREVERB_REFLECTIONS_DELAY
:
1083 case AL_EAXREVERB_LATE_REVERB_GAIN
:
1084 case AL_EAXREVERB_LATE_REVERB_DELAY
:
1085 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
1086 case AL_EAXREVERB_ECHO_TIME
:
1087 case AL_EAXREVERB_ECHO_DEPTH
:
1088 case AL_EAXREVERB_MODULATION_TIME
:
1089 case AL_EAXREVERB_MODULATION_DEPTH
:
1090 case AL_EAXREVERB_HFREFERENCE
:
1091 case AL_EAXREVERB_LFREFERENCE
:
1092 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
1093 alGetEffectf(effect
, param
, pflValues
);
1096 case AL_EAXREVERB_REFLECTIONS_PAN
:
1097 pflValues
[0] = ALEffect
->Reverb
.ReflectionsPan
[0];
1098 pflValues
[1] = ALEffect
->Reverb
.ReflectionsPan
[1];
1099 pflValues
[2] = ALEffect
->Reverb
.ReflectionsPan
[2];
1101 case AL_EAXREVERB_LATE_REVERB_PAN
:
1102 pflValues
[0] = ALEffect
->Reverb
.LateReverbPan
[0];
1103 pflValues
[1] = ALEffect
->Reverb
.LateReverbPan
[1];
1104 pflValues
[2] = ALEffect
->Reverb
.LateReverbPan
[2];
1108 alSetError(AL_INVALID_ENUM
);
1112 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
1116 case AL_REVERB_DENSITY
:
1117 case AL_REVERB_DIFFUSION
:
1118 case AL_REVERB_GAIN
:
1119 case AL_REVERB_GAINHF
:
1120 case AL_REVERB_DECAY_TIME
:
1121 case AL_REVERB_DECAY_HFRATIO
:
1122 case AL_REVERB_REFLECTIONS_GAIN
:
1123 case AL_REVERB_REFLECTIONS_DELAY
:
1124 case AL_REVERB_LATE_REVERB_GAIN
:
1125 case AL_REVERB_LATE_REVERB_DELAY
:
1126 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1127 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1128 alGetEffectf(effect
, param
, pflValues
);
1132 alSetError(AL_INVALID_ENUM
);
1136 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1141 case AL_ECHO_LRDELAY
:
1142 case AL_ECHO_DAMPING
:
1143 case AL_ECHO_FEEDBACK
:
1144 case AL_ECHO_SPREAD
:
1145 alGetEffectf(effect
, param
, pflValues
);
1149 alSetError(AL_INVALID_ENUM
);
1154 alSetError(AL_INVALID_ENUM
);
1157 alSetError(AL_INVALID_NAME
);
1159 ProcessContext(Context
);
1163 ALvoid
ReleaseALEffects(ALvoid
)
1166 if(g_EffectCount
> 0)
1167 AL_PRINT("exit(): deleting %d Effect(s)\n", g_EffectCount
);
1172 ALeffect
*temp
= g_EffectList
;
1173 g_EffectList
= g_EffectList
->next
;
1175 // Release effect structure
1176 memset(temp
, 0, sizeof(ALeffect
));
1183 static void InitEffectParams(ALeffect
*effect
, ALenum type
)
1185 effect
->type
= type
;
1188 /* NOTE: Standard reverb and EAX reverb use the same defaults for the
1189 * shared parameters, and EAX's additional parameters default to
1190 * values assumed by standard reverb.
1192 case AL_EFFECT_EAXREVERB
:
1193 case AL_EFFECT_REVERB
:
1194 effect
->Reverb
.Density
= AL_EAXREVERB_DEFAULT_DENSITY
;
1195 effect
->Reverb
.Diffusion
= AL_EAXREVERB_DEFAULT_DIFFUSION
;
1196 effect
->Reverb
.Gain
= AL_EAXREVERB_DEFAULT_GAIN
;
1197 effect
->Reverb
.GainHF
= AL_EAXREVERB_DEFAULT_GAINHF
;
1198 effect
->Reverb
.GainLF
= AL_EAXREVERB_DEFAULT_GAINLF
;
1199 effect
->Reverb
.DecayTime
= AL_EAXREVERB_DEFAULT_DECAY_TIME
;
1200 effect
->Reverb
.DecayHFRatio
= AL_EAXREVERB_DEFAULT_DECAY_HFRATIO
;
1201 effect
->Reverb
.DecayLFRatio
= AL_EAXREVERB_DEFAULT_DECAY_LFRATIO
;
1202 effect
->Reverb
.ReflectionsGain
= AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN
;
1203 effect
->Reverb
.ReflectionsDelay
= AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY
;
1204 effect
->Reverb
.ReflectionsPan
[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1205 effect
->Reverb
.ReflectionsPan
[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1206 effect
->Reverb
.ReflectionsPan
[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1207 effect
->Reverb
.LateReverbGain
= AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN
;
1208 effect
->Reverb
.LateReverbDelay
= AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY
;
1209 effect
->Reverb
.LateReverbPan
[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1210 effect
->Reverb
.LateReverbPan
[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1211 effect
->Reverb
.LateReverbPan
[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1212 effect
->Reverb
.EchoTime
= AL_EAXREVERB_DEFAULT_ECHO_TIME
;
1213 effect
->Reverb
.EchoDepth
= AL_EAXREVERB_DEFAULT_ECHO_DEPTH
;
1214 effect
->Reverb
.ModulationTime
= AL_EAXREVERB_DEFAULT_MODULATION_TIME
;
1215 effect
->Reverb
.ModulationDepth
= AL_EAXREVERB_DEFAULT_MODULATION_DEPTH
;
1216 effect
->Reverb
.AirAbsorptionGainHF
= AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF
;
1217 effect
->Reverb
.HFReference
= AL_EAXREVERB_DEFAULT_HFREFERENCE
;
1218 effect
->Reverb
.LFReference
= AL_EAXREVERB_DEFAULT_LFREFERENCE
;
1219 effect
->Reverb
.RoomRolloffFactor
= AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR
;
1220 effect
->Reverb
.DecayHFLimit
= AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT
;
1222 case AL_EFFECT_ECHO
:
1223 effect
->Echo
.Delay
= AL_ECHO_DEFAULT_DELAY
;
1224 effect
->Echo
.LRDelay
= AL_ECHO_DEFAULT_LRDELAY
;
1225 effect
->Echo
.Damping
= AL_ECHO_DEFAULT_DAMPING
;
1226 effect
->Echo
.Feedback
= AL_ECHO_DEFAULT_FEEDBACK
;
1227 effect
->Echo
.Spread
= AL_ECHO_DEFAULT_SPREAD
;