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
);
40 ALvoid AL_APIENTRY
alGenEffects(ALsizei n
, ALuint
*effects
)
45 Context
= GetContextSuspended();
50 ALCdevice
*device
= Context
->Device
;
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
= &device
->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
);
75 device
->EffectCount
++;
78 list
= &(*list
)->next
;
83 ProcessContext(Context
);
86 ALvoid AL_APIENTRY
alDeleteEffects(ALsizei n
, ALuint
*effects
)
92 Context
= GetContextSuspended();
97 ALCdevice
*device
= Context
->Device
;
99 // Check that all effects are valid
100 for (i
= 0; i
< n
; i
++)
102 if (!alIsEffect(effects
[i
]))
104 alSetError(AL_INVALID_NAME
);
111 // All effects are valid
112 for (i
= 0; i
< n
; i
++)
114 // Recheck that the effect is valid, because there could be duplicated names
115 if (effects
[i
] && alIsEffect(effects
[i
]))
119 ALEffect
= ((ALeffect
*)ALTHUNK_LOOKUPENTRY(effects
[i
]));
121 // Remove Source from list of Sources
122 list
= &device
->EffectList
;
123 while(*list
&& *list
!= ALEffect
)
124 list
= &(*list
)->next
;
127 *list
= (*list
)->next
;
128 ALTHUNK_REMOVEENTRY(ALEffect
->effect
);
130 memset(ALEffect
, 0, sizeof(ALeffect
));
133 device
->EffectCount
--;
139 alSetError(AL_INVALID_VALUE
);
141 ProcessContext(Context
);
144 ALboolean AL_APIENTRY
alIsEffect(ALuint effect
)
149 Context
= GetContextSuspended();
150 if(!Context
) return AL_FALSE
;
152 list
= Context
->Device
->EffectList
;
153 while(list
&& list
->effect
!= effect
)
156 ProcessContext(Context
);
158 return ((list
|| !effect
) ? AL_TRUE
: AL_FALSE
);
161 ALvoid AL_APIENTRY
alEffecti(ALuint effect
, ALenum param
, ALint iValue
)
165 Context
= GetContextSuspended();
168 if (effect
&& alIsEffect(effect
))
170 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
172 if(param
== AL_EFFECT_TYPE
)
174 ALboolean isOk
= (iValue
== AL_EFFECT_NULL
||
175 (iValue
== AL_EFFECT_EAXREVERB
&& !DisabledEffects
[EAXREVERB
]) ||
176 (iValue
== AL_EFFECT_REVERB
&& !DisabledEffects
[REVERB
]) ||
177 (iValue
== AL_EFFECT_ECHO
&& !DisabledEffects
[ECHO
]));
180 InitEffectParams(ALEffect
, iValue
);
182 alSetError(AL_INVALID_VALUE
);
184 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
188 case AL_EAXREVERB_DECAY_HFLIMIT
:
189 if(iValue
>= AL_EAXREVERB_MIN_DECAY_HFLIMIT
&&
190 iValue
<= AL_EAXREVERB_MAX_DECAY_HFLIMIT
)
191 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
193 alSetError(AL_INVALID_VALUE
);
197 alSetError(AL_INVALID_ENUM
);
201 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
205 case AL_REVERB_DECAY_HFLIMIT
:
206 if(iValue
>= AL_REVERB_MIN_DECAY_HFLIMIT
&&
207 iValue
<= AL_REVERB_MAX_DECAY_HFLIMIT
)
208 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
210 alSetError(AL_INVALID_VALUE
);
214 alSetError(AL_INVALID_ENUM
);
218 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
223 alSetError(AL_INVALID_ENUM
);
228 alSetError(AL_INVALID_ENUM
);
231 alSetError(AL_INVALID_NAME
);
233 ProcessContext(Context
);
236 ALvoid AL_APIENTRY
alEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
240 Context
= GetContextSuspended();
243 if (effect
&& alIsEffect(effect
))
245 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
247 if(param
== AL_EFFECT_TYPE
)
249 alEffecti(effect
, param
, piValues
[0]);
251 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
255 case AL_EAXREVERB_DECAY_HFLIMIT
:
256 alEffecti(effect
, param
, piValues
[0]);
260 alSetError(AL_INVALID_ENUM
);
264 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
268 case AL_REVERB_DECAY_HFLIMIT
:
269 alEffecti(effect
, param
, piValues
[0]);
273 alSetError(AL_INVALID_ENUM
);
277 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
282 alSetError(AL_INVALID_ENUM
);
287 alSetError(AL_INVALID_ENUM
);
290 alSetError(AL_INVALID_NAME
);
292 ProcessContext(Context
);
295 ALvoid AL_APIENTRY
alEffectf(ALuint effect
, ALenum param
, ALfloat flValue
)
299 Context
= GetContextSuspended();
302 if (effect
&& alIsEffect(effect
))
304 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
306 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
310 case AL_EAXREVERB_DENSITY
:
311 if(flValue
>= AL_EAXREVERB_MIN_DENSITY
&&
312 flValue
<= AL_EAXREVERB_MAX_DENSITY
)
313 ALEffect
->Reverb
.Density
= flValue
;
315 alSetError(AL_INVALID_VALUE
);
318 case AL_EAXREVERB_DIFFUSION
:
319 if(flValue
>= AL_EAXREVERB_MIN_DIFFUSION
&&
320 flValue
<= AL_EAXREVERB_MAX_DIFFUSION
)
321 ALEffect
->Reverb
.Diffusion
= flValue
;
323 alSetError(AL_INVALID_VALUE
);
326 case AL_EAXREVERB_GAIN
:
327 if(flValue
>= AL_EAXREVERB_MIN_GAIN
&&
328 flValue
<= AL_EAXREVERB_MAX_GAIN
)
329 ALEffect
->Reverb
.Gain
= flValue
;
331 alSetError(AL_INVALID_VALUE
);
334 case AL_EAXREVERB_GAINHF
:
335 if(flValue
>= AL_EAXREVERB_MIN_GAINHF
&&
336 flValue
<= AL_EAXREVERB_MAX_GAIN
)
337 ALEffect
->Reverb
.GainHF
= flValue
;
339 alSetError(AL_INVALID_VALUE
);
342 case AL_EAXREVERB_GAINLF
:
343 if(flValue
>= AL_EAXREVERB_MIN_GAINLF
&&
344 flValue
<= AL_EAXREVERB_MAX_GAINLF
)
345 ALEffect
->Reverb
.GainLF
= flValue
;
347 alSetError(AL_INVALID_VALUE
);
350 case AL_EAXREVERB_DECAY_TIME
:
351 if(flValue
>= AL_EAXREVERB_MIN_DECAY_TIME
&&
352 flValue
<= AL_EAXREVERB_MAX_DECAY_TIME
)
353 ALEffect
->Reverb
.DecayTime
= flValue
;
355 alSetError(AL_INVALID_VALUE
);
358 case AL_EAXREVERB_DECAY_HFRATIO
:
359 if(flValue
>= AL_EAXREVERB_MIN_DECAY_HFRATIO
&&
360 flValue
<= AL_EAXREVERB_MAX_DECAY_HFRATIO
)
361 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
363 alSetError(AL_INVALID_VALUE
);
366 case AL_EAXREVERB_DECAY_LFRATIO
:
367 if(flValue
>= AL_EAXREVERB_MIN_DECAY_LFRATIO
&&
368 flValue
<= AL_EAXREVERB_MAX_DECAY_LFRATIO
)
369 ALEffect
->Reverb
.DecayLFRatio
= flValue
;
371 alSetError(AL_INVALID_VALUE
);
374 case AL_EAXREVERB_REFLECTIONS_GAIN
:
375 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_GAIN
&&
376 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_GAIN
)
377 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
379 alSetError(AL_INVALID_VALUE
);
382 case AL_EAXREVERB_REFLECTIONS_DELAY
:
383 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_DELAY
&&
384 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_DELAY
)
385 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
387 alSetError(AL_INVALID_VALUE
);
390 case AL_EAXREVERB_LATE_REVERB_GAIN
:
391 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_GAIN
&&
392 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_GAIN
)
393 ALEffect
->Reverb
.LateReverbGain
= flValue
;
395 alSetError(AL_INVALID_VALUE
);
398 case AL_EAXREVERB_LATE_REVERB_DELAY
:
399 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_DELAY
&&
400 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_DELAY
)
401 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
403 alSetError(AL_INVALID_VALUE
);
406 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
407 if(flValue
>= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF
&&
408 flValue
<= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF
)
409 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
411 alSetError(AL_INVALID_VALUE
);
414 case AL_EAXREVERB_ECHO_TIME
:
415 if(flValue
>= AL_EAXREVERB_MIN_ECHO_TIME
&&
416 flValue
<= AL_EAXREVERB_MAX_ECHO_TIME
)
417 ALEffect
->Reverb
.EchoTime
= flValue
;
419 alSetError(AL_INVALID_VALUE
);
422 case AL_EAXREVERB_ECHO_DEPTH
:
423 if(flValue
>= AL_EAXREVERB_MIN_ECHO_DEPTH
&&
424 flValue
<= AL_EAXREVERB_MAX_ECHO_DEPTH
)
425 ALEffect
->Reverb
.EchoDepth
= flValue
;
427 alSetError(AL_INVALID_VALUE
);
430 case AL_EAXREVERB_MODULATION_TIME
:
431 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_TIME
&&
432 flValue
<= AL_EAXREVERB_MAX_MODULATION_TIME
)
433 ALEffect
->Reverb
.ModulationTime
= flValue
;
435 alSetError(AL_INVALID_VALUE
);
438 case AL_EAXREVERB_MODULATION_DEPTH
:
439 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_DEPTH
&&
440 flValue
<= AL_EAXREVERB_MAX_MODULATION_DEPTH
)
441 ALEffect
->Reverb
.ModulationDepth
= flValue
;
443 alSetError(AL_INVALID_VALUE
);
446 case AL_EAXREVERB_HFREFERENCE
:
447 if(flValue
>= AL_EAXREVERB_MIN_HFREFERENCE
&&
448 flValue
<= AL_EAXREVERB_MAX_HFREFERENCE
)
449 ALEffect
->Reverb
.HFReference
= flValue
;
451 alSetError(AL_INVALID_VALUE
);
454 case AL_EAXREVERB_LFREFERENCE
:
455 if(flValue
>= AL_EAXREVERB_MIN_LFREFERENCE
&&
456 flValue
<= AL_EAXREVERB_MAX_LFREFERENCE
)
457 ALEffect
->Reverb
.LFReference
= flValue
;
459 alSetError(AL_INVALID_VALUE
);
462 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
463 if(flValue
>= 0.0f
&& flValue
<= 10.0f
)
464 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
466 alSetError(AL_INVALID_VALUE
);
470 alSetError(AL_INVALID_ENUM
);
474 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
478 case AL_REVERB_DENSITY
:
479 if(flValue
>= AL_REVERB_MIN_DENSITY
&&
480 flValue
<= AL_REVERB_MAX_DENSITY
)
481 ALEffect
->Reverb
.Density
= flValue
;
483 alSetError(AL_INVALID_VALUE
);
486 case AL_REVERB_DIFFUSION
:
487 if(flValue
>= AL_REVERB_MIN_DIFFUSION
&&
488 flValue
<= AL_REVERB_MAX_DIFFUSION
)
489 ALEffect
->Reverb
.Diffusion
= flValue
;
491 alSetError(AL_INVALID_VALUE
);
495 if(flValue
>= AL_REVERB_MIN_GAIN
&&
496 flValue
<= AL_REVERB_MAX_GAIN
)
497 ALEffect
->Reverb
.Gain
= flValue
;
499 alSetError(AL_INVALID_VALUE
);
502 case AL_REVERB_GAINHF
:
503 if(flValue
>= AL_REVERB_MIN_GAINHF
&&
504 flValue
<= AL_REVERB_MAX_GAINHF
)
505 ALEffect
->Reverb
.GainHF
= flValue
;
507 alSetError(AL_INVALID_VALUE
);
510 case AL_REVERB_DECAY_TIME
:
511 if(flValue
>= AL_REVERB_MIN_DECAY_TIME
&&
512 flValue
<= AL_REVERB_MAX_DECAY_TIME
)
513 ALEffect
->Reverb
.DecayTime
= flValue
;
515 alSetError(AL_INVALID_VALUE
);
518 case AL_REVERB_DECAY_HFRATIO
:
519 if(flValue
>= AL_REVERB_MIN_DECAY_HFRATIO
&&
520 flValue
<= AL_REVERB_MAX_DECAY_HFRATIO
)
521 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
523 alSetError(AL_INVALID_VALUE
);
526 case AL_REVERB_REFLECTIONS_GAIN
:
527 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_GAIN
&&
528 flValue
<= AL_REVERB_MAX_REFLECTIONS_GAIN
)
529 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
531 alSetError(AL_INVALID_VALUE
);
534 case AL_REVERB_REFLECTIONS_DELAY
:
535 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_DELAY
&&
536 flValue
<= AL_REVERB_MAX_REFLECTIONS_DELAY
)
537 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
539 alSetError(AL_INVALID_VALUE
);
542 case AL_REVERB_LATE_REVERB_GAIN
:
543 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_GAIN
&&
544 flValue
<= AL_REVERB_MAX_LATE_REVERB_GAIN
)
545 ALEffect
->Reverb
.LateReverbGain
= flValue
;
547 alSetError(AL_INVALID_VALUE
);
550 case AL_REVERB_LATE_REVERB_DELAY
:
551 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_DELAY
&&
552 flValue
<= AL_REVERB_MAX_LATE_REVERB_DELAY
)
553 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
555 alSetError(AL_INVALID_VALUE
);
558 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
559 if(flValue
>= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF
&&
560 flValue
<= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF
)
561 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
563 alSetError(AL_INVALID_VALUE
);
566 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
567 if(flValue
>= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR
&&
568 flValue
<= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR
)
569 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
571 alSetError(AL_INVALID_VALUE
);
575 alSetError(AL_INVALID_ENUM
);
579 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
584 if(flValue
>= AL_ECHO_MIN_DELAY
&& flValue
<= AL_ECHO_MAX_DELAY
)
585 ALEffect
->Echo
.Delay
= flValue
;
587 alSetError(AL_INVALID_VALUE
);
590 case AL_ECHO_LRDELAY
:
591 if(flValue
>= AL_ECHO_MIN_LRDELAY
&& flValue
<= AL_ECHO_MAX_LRDELAY
)
592 ALEffect
->Echo
.LRDelay
= flValue
;
594 alSetError(AL_INVALID_VALUE
);
597 case AL_ECHO_DAMPING
:
598 if(flValue
>= AL_ECHO_MIN_DAMPING
&& flValue
<= AL_ECHO_MAX_DAMPING
)
599 ALEffect
->Echo
.Damping
= flValue
;
601 alSetError(AL_INVALID_VALUE
);
604 case AL_ECHO_FEEDBACK
:
605 if(flValue
>= AL_ECHO_MIN_FEEDBACK
&& flValue
<= AL_ECHO_MAX_FEEDBACK
)
606 ALEffect
->Echo
.Feedback
= flValue
;
608 alSetError(AL_INVALID_VALUE
);
612 if(flValue
>= AL_ECHO_MIN_SPREAD
&& flValue
<= AL_ECHO_MAX_SPREAD
)
613 ALEffect
->Echo
.Spread
= flValue
;
615 alSetError(AL_INVALID_VALUE
);
619 alSetError(AL_INVALID_ENUM
);
624 alSetError(AL_INVALID_ENUM
);
627 alSetError(AL_INVALID_NAME
);
629 ProcessContext(Context
);
632 ALvoid AL_APIENTRY
alEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
636 Context
= GetContextSuspended();
639 if (effect
&& alIsEffect(effect
))
641 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
643 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
647 case AL_EAXREVERB_DENSITY
:
648 case AL_EAXREVERB_DIFFUSION
:
649 case AL_EAXREVERB_GAIN
:
650 case AL_EAXREVERB_GAINHF
:
651 case AL_EAXREVERB_GAINLF
:
652 case AL_EAXREVERB_DECAY_TIME
:
653 case AL_EAXREVERB_DECAY_HFRATIO
:
654 case AL_EAXREVERB_DECAY_LFRATIO
:
655 case AL_EAXREVERB_REFLECTIONS_GAIN
:
656 case AL_EAXREVERB_REFLECTIONS_DELAY
:
657 case AL_EAXREVERB_LATE_REVERB_GAIN
:
658 case AL_EAXREVERB_LATE_REVERB_DELAY
:
659 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
660 case AL_EAXREVERB_ECHO_TIME
:
661 case AL_EAXREVERB_ECHO_DEPTH
:
662 case AL_EAXREVERB_MODULATION_TIME
:
663 case AL_EAXREVERB_MODULATION_DEPTH
:
664 case AL_EAXREVERB_HFREFERENCE
:
665 case AL_EAXREVERB_LFREFERENCE
:
666 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
667 alEffectf(effect
, param
, pflValues
[0]);
670 case AL_EAXREVERB_REFLECTIONS_PAN
:
671 if(!isnan(pflValues
[0]) && !isnan(pflValues
[1]) && !isnan(pflValues
[2]))
673 ALEffect
->Reverb
.ReflectionsPan
[0] = pflValues
[0];
674 ALEffect
->Reverb
.ReflectionsPan
[1] = pflValues
[1];
675 ALEffect
->Reverb
.ReflectionsPan
[2] = pflValues
[2];
678 alSetError(AL_INVALID_VALUE
);
680 case AL_EAXREVERB_LATE_REVERB_PAN
:
681 if(!isnan(pflValues
[0]) && !isnan(pflValues
[1]) && !isnan(pflValues
[2]))
683 ALEffect
->Reverb
.LateReverbPan
[0] = pflValues
[0];
684 ALEffect
->Reverb
.LateReverbPan
[1] = pflValues
[1];
685 ALEffect
->Reverb
.LateReverbPan
[2] = pflValues
[2];
688 alSetError(AL_INVALID_VALUE
);
692 alSetError(AL_INVALID_ENUM
);
696 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
700 case AL_REVERB_DENSITY
:
701 case AL_REVERB_DIFFUSION
:
703 case AL_REVERB_GAINHF
:
704 case AL_REVERB_DECAY_TIME
:
705 case AL_REVERB_DECAY_HFRATIO
:
706 case AL_REVERB_REFLECTIONS_GAIN
:
707 case AL_REVERB_REFLECTIONS_DELAY
:
708 case AL_REVERB_LATE_REVERB_GAIN
:
709 case AL_REVERB_LATE_REVERB_DELAY
:
710 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
711 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
712 alEffectf(effect
, param
, pflValues
[0]);
716 alSetError(AL_INVALID_ENUM
);
720 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
725 case AL_ECHO_LRDELAY
:
726 case AL_ECHO_DAMPING
:
727 case AL_ECHO_FEEDBACK
:
729 alEffectf(effect
, param
, pflValues
[0]);
733 alSetError(AL_INVALID_ENUM
);
738 alSetError(AL_INVALID_ENUM
);
741 alSetError(AL_INVALID_NAME
);
743 ProcessContext(Context
);
746 ALvoid AL_APIENTRY
alGetEffecti(ALuint effect
, ALenum param
, ALint
*piValue
)
750 Context
= GetContextSuspended();
753 if (effect
&& alIsEffect(effect
))
755 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
757 if(param
== AL_EFFECT_TYPE
)
759 *piValue
= ALEffect
->type
;
761 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
765 case AL_EAXREVERB_DECAY_HFLIMIT
:
766 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
770 alSetError(AL_INVALID_ENUM
);
774 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
778 case AL_REVERB_DECAY_HFLIMIT
:
779 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
783 alSetError(AL_INVALID_ENUM
);
787 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
792 alSetError(AL_INVALID_ENUM
);
797 alSetError(AL_INVALID_ENUM
);
800 alSetError(AL_INVALID_NAME
);
802 ProcessContext(Context
);
805 ALvoid AL_APIENTRY
alGetEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
809 Context
= GetContextSuspended();
812 if (effect
&& alIsEffect(effect
))
814 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
816 if(param
== AL_EFFECT_TYPE
)
818 alGetEffecti(effect
, param
, piValues
);
820 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
824 case AL_EAXREVERB_DECAY_HFLIMIT
:
825 alGetEffecti(effect
, param
, piValues
);
829 alSetError(AL_INVALID_ENUM
);
833 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
837 case AL_REVERB_DECAY_HFLIMIT
:
838 alGetEffecti(effect
, param
, piValues
);
842 alSetError(AL_INVALID_ENUM
);
846 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
851 alSetError(AL_INVALID_ENUM
);
856 alSetError(AL_INVALID_ENUM
);
859 alSetError(AL_INVALID_NAME
);
861 ProcessContext(Context
);
864 ALvoid AL_APIENTRY
alGetEffectf(ALuint effect
, ALenum param
, ALfloat
*pflValue
)
868 Context
= GetContextSuspended();
871 if (effect
&& alIsEffect(effect
))
873 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
875 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
879 case AL_EAXREVERB_DENSITY
:
880 *pflValue
= ALEffect
->Reverb
.Density
;
883 case AL_EAXREVERB_DIFFUSION
:
884 *pflValue
= ALEffect
->Reverb
.Diffusion
;
887 case AL_EAXREVERB_GAIN
:
888 *pflValue
= ALEffect
->Reverb
.Gain
;
891 case AL_EAXREVERB_GAINHF
:
892 *pflValue
= ALEffect
->Reverb
.GainHF
;
895 case AL_EAXREVERB_GAINLF
:
896 *pflValue
= ALEffect
->Reverb
.GainLF
;
899 case AL_EAXREVERB_DECAY_TIME
:
900 *pflValue
= ALEffect
->Reverb
.DecayTime
;
903 case AL_EAXREVERB_DECAY_HFRATIO
:
904 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
907 case AL_EAXREVERB_DECAY_LFRATIO
:
908 *pflValue
= ALEffect
->Reverb
.DecayLFRatio
;
911 case AL_EAXREVERB_REFLECTIONS_GAIN
:
912 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
915 case AL_EAXREVERB_REFLECTIONS_DELAY
:
916 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
919 case AL_EAXREVERB_LATE_REVERB_GAIN
:
920 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
923 case AL_EAXREVERB_LATE_REVERB_DELAY
:
924 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
927 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
928 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
931 case AL_EAXREVERB_ECHO_TIME
:
932 *pflValue
= ALEffect
->Reverb
.EchoTime
;
935 case AL_EAXREVERB_ECHO_DEPTH
:
936 *pflValue
= ALEffect
->Reverb
.EchoDepth
;
939 case AL_EAXREVERB_MODULATION_TIME
:
940 *pflValue
= ALEffect
->Reverb
.ModulationTime
;
943 case AL_EAXREVERB_MODULATION_DEPTH
:
944 *pflValue
= ALEffect
->Reverb
.ModulationDepth
;
947 case AL_EAXREVERB_HFREFERENCE
:
948 *pflValue
= ALEffect
->Reverb
.HFReference
;
951 case AL_EAXREVERB_LFREFERENCE
:
952 *pflValue
= ALEffect
->Reverb
.LFReference
;
955 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
956 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
960 alSetError(AL_INVALID_ENUM
);
964 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
968 case AL_REVERB_DENSITY
:
969 *pflValue
= ALEffect
->Reverb
.Density
;
972 case AL_REVERB_DIFFUSION
:
973 *pflValue
= ALEffect
->Reverb
.Diffusion
;
977 *pflValue
= ALEffect
->Reverb
.Gain
;
980 case AL_REVERB_GAINHF
:
981 *pflValue
= ALEffect
->Reverb
.GainHF
;
984 case AL_REVERB_DECAY_TIME
:
985 *pflValue
= ALEffect
->Reverb
.DecayTime
;
988 case AL_REVERB_DECAY_HFRATIO
:
989 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
992 case AL_REVERB_REFLECTIONS_GAIN
:
993 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
996 case AL_REVERB_REFLECTIONS_DELAY
:
997 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
1000 case AL_REVERB_LATE_REVERB_GAIN
:
1001 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
1004 case AL_REVERB_LATE_REVERB_DELAY
:
1005 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
1008 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1009 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
1012 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1013 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
1017 alSetError(AL_INVALID_ENUM
);
1021 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1026 *pflValue
= ALEffect
->Echo
.Delay
;
1029 case AL_ECHO_LRDELAY
:
1030 *pflValue
= ALEffect
->Echo
.LRDelay
;
1033 case AL_ECHO_DAMPING
:
1034 *pflValue
= ALEffect
->Echo
.Damping
;
1037 case AL_ECHO_FEEDBACK
:
1038 *pflValue
= ALEffect
->Echo
.Feedback
;
1041 case AL_ECHO_SPREAD
:
1042 *pflValue
= ALEffect
->Echo
.Spread
;
1046 alSetError(AL_INVALID_ENUM
);
1051 alSetError(AL_INVALID_ENUM
);
1054 alSetError(AL_INVALID_NAME
);
1056 ProcessContext(Context
);
1059 ALvoid AL_APIENTRY
alGetEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
1061 ALCcontext
*Context
;
1063 Context
= GetContextSuspended();
1064 if(!Context
) return;
1066 if (effect
&& alIsEffect(effect
))
1068 ALeffect
*ALEffect
= (ALeffect
*)ALTHUNK_LOOKUPENTRY(effect
);
1070 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
1074 case AL_EAXREVERB_DENSITY
:
1075 case AL_EAXREVERB_DIFFUSION
:
1076 case AL_EAXREVERB_GAIN
:
1077 case AL_EAXREVERB_GAINHF
:
1078 case AL_EAXREVERB_GAINLF
:
1079 case AL_EAXREVERB_DECAY_TIME
:
1080 case AL_EAXREVERB_DECAY_HFRATIO
:
1081 case AL_EAXREVERB_DECAY_LFRATIO
:
1082 case AL_EAXREVERB_REFLECTIONS_GAIN
:
1083 case AL_EAXREVERB_REFLECTIONS_DELAY
:
1084 case AL_EAXREVERB_LATE_REVERB_GAIN
:
1085 case AL_EAXREVERB_LATE_REVERB_DELAY
:
1086 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
1087 case AL_EAXREVERB_ECHO_TIME
:
1088 case AL_EAXREVERB_ECHO_DEPTH
:
1089 case AL_EAXREVERB_MODULATION_TIME
:
1090 case AL_EAXREVERB_MODULATION_DEPTH
:
1091 case AL_EAXREVERB_HFREFERENCE
:
1092 case AL_EAXREVERB_LFREFERENCE
:
1093 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
1094 alGetEffectf(effect
, param
, pflValues
);
1097 case AL_EAXREVERB_REFLECTIONS_PAN
:
1098 pflValues
[0] = ALEffect
->Reverb
.ReflectionsPan
[0];
1099 pflValues
[1] = ALEffect
->Reverb
.ReflectionsPan
[1];
1100 pflValues
[2] = ALEffect
->Reverb
.ReflectionsPan
[2];
1102 case AL_EAXREVERB_LATE_REVERB_PAN
:
1103 pflValues
[0] = ALEffect
->Reverb
.LateReverbPan
[0];
1104 pflValues
[1] = ALEffect
->Reverb
.LateReverbPan
[1];
1105 pflValues
[2] = ALEffect
->Reverb
.LateReverbPan
[2];
1109 alSetError(AL_INVALID_ENUM
);
1113 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
1117 case AL_REVERB_DENSITY
:
1118 case AL_REVERB_DIFFUSION
:
1119 case AL_REVERB_GAIN
:
1120 case AL_REVERB_GAINHF
:
1121 case AL_REVERB_DECAY_TIME
:
1122 case AL_REVERB_DECAY_HFRATIO
:
1123 case AL_REVERB_REFLECTIONS_GAIN
:
1124 case AL_REVERB_REFLECTIONS_DELAY
:
1125 case AL_REVERB_LATE_REVERB_GAIN
:
1126 case AL_REVERB_LATE_REVERB_DELAY
:
1127 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1128 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1129 alGetEffectf(effect
, param
, pflValues
);
1133 alSetError(AL_INVALID_ENUM
);
1137 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1142 case AL_ECHO_LRDELAY
:
1143 case AL_ECHO_DAMPING
:
1144 case AL_ECHO_FEEDBACK
:
1145 case AL_ECHO_SPREAD
:
1146 alGetEffectf(effect
, param
, pflValues
);
1150 alSetError(AL_INVALID_ENUM
);
1155 alSetError(AL_INVALID_ENUM
);
1158 alSetError(AL_INVALID_NAME
);
1160 ProcessContext(Context
);
1164 ALvoid
ReleaseALEffects(ALCdevice
*device
)
1166 ALeffect
*list
= device
->EffectList
;
1169 ALeffect
*temp
= list
;
1172 // Release effect structure
1173 memset(temp
, 0, sizeof(ALeffect
));
1176 device
->EffectList
= NULL
;
1177 device
->EffectCount
= 0;
1181 static void InitEffectParams(ALeffect
*effect
, ALenum type
)
1183 effect
->type
= type
;
1186 /* NOTE: Standard reverb and EAX reverb use the same defaults for the
1187 * shared parameters, and EAX's additional parameters default to
1188 * values assumed by standard reverb.
1190 case AL_EFFECT_EAXREVERB
:
1191 case AL_EFFECT_REVERB
:
1192 effect
->Reverb
.Density
= AL_EAXREVERB_DEFAULT_DENSITY
;
1193 effect
->Reverb
.Diffusion
= AL_EAXREVERB_DEFAULT_DIFFUSION
;
1194 effect
->Reverb
.Gain
= AL_EAXREVERB_DEFAULT_GAIN
;
1195 effect
->Reverb
.GainHF
= AL_EAXREVERB_DEFAULT_GAINHF
;
1196 effect
->Reverb
.GainLF
= AL_EAXREVERB_DEFAULT_GAINLF
;
1197 effect
->Reverb
.DecayTime
= AL_EAXREVERB_DEFAULT_DECAY_TIME
;
1198 effect
->Reverb
.DecayHFRatio
= AL_EAXREVERB_DEFAULT_DECAY_HFRATIO
;
1199 effect
->Reverb
.DecayLFRatio
= AL_EAXREVERB_DEFAULT_DECAY_LFRATIO
;
1200 effect
->Reverb
.ReflectionsGain
= AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN
;
1201 effect
->Reverb
.ReflectionsDelay
= AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY
;
1202 effect
->Reverb
.ReflectionsPan
[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1203 effect
->Reverb
.ReflectionsPan
[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1204 effect
->Reverb
.ReflectionsPan
[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1205 effect
->Reverb
.LateReverbGain
= AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN
;
1206 effect
->Reverb
.LateReverbDelay
= AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY
;
1207 effect
->Reverb
.LateReverbPan
[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1208 effect
->Reverb
.LateReverbPan
[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1209 effect
->Reverb
.LateReverbPan
[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1210 effect
->Reverb
.EchoTime
= AL_EAXREVERB_DEFAULT_ECHO_TIME
;
1211 effect
->Reverb
.EchoDepth
= AL_EAXREVERB_DEFAULT_ECHO_DEPTH
;
1212 effect
->Reverb
.ModulationTime
= AL_EAXREVERB_DEFAULT_MODULATION_TIME
;
1213 effect
->Reverb
.ModulationDepth
= AL_EAXREVERB_DEFAULT_MODULATION_DEPTH
;
1214 effect
->Reverb
.AirAbsorptionGainHF
= AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF
;
1215 effect
->Reverb
.HFReference
= AL_EAXREVERB_DEFAULT_HFREFERENCE
;
1216 effect
->Reverb
.LFReference
= AL_EAXREVERB_DEFAULT_LFREFERENCE
;
1217 effect
->Reverb
.RoomRolloffFactor
= AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR
;
1218 effect
->Reverb
.DecayHFLimit
= AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT
;
1220 case AL_EFFECT_ECHO
:
1221 effect
->Echo
.Delay
= AL_ECHO_DEFAULT_DELAY
;
1222 effect
->Echo
.LRDelay
= AL_ECHO_DEFAULT_LRDELAY
;
1223 effect
->Echo
.Damping
= AL_ECHO_DEFAULT_DAMPING
;
1224 effect
->Echo
.Feedback
= AL_ECHO_DEFAULT_FEEDBACK
;
1225 effect
->Echo
.Spread
= AL_ECHO_DEFAULT_SPREAD
;