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 DECL_VERIFIER(Effect
, ALeffect
, effect
)
41 ALvoid AL_APIENTRY
alGenEffects(ALsizei n
, ALuint
*effects
)
46 Context
= GetContextSuspended();
51 ALCdevice
*device
= Context
->Device
;
53 // Check that enough memory has been allocted in the 'effects' array for n Effects
54 if (!IsBadWritePtr((void*)effects
, n
* sizeof(ALuint
)))
57 ALeffect
**list
= &device
->EffectList
;
59 list
= &(*list
)->next
;
64 *list
= calloc(1, sizeof(ALeffect
));
69 ALeffect
*temp
= end
->next
;
70 end
->next
= temp
->next
;
72 ALTHUNK_REMOVEENTRY(temp
->effect
);
73 device
->EffectCount
--;
76 alSetError(Context
, AL_OUT_OF_MEMORY
);
80 effects
[i
] = (ALuint
)ALTHUNK_ADDENTRY(*list
);
81 (*list
)->effect
= effects
[i
];
83 InitEffectParams(*list
, AL_EFFECT_NULL
);
84 device
->EffectCount
++;
87 list
= &(*list
)->next
;
92 ProcessContext(Context
);
95 ALvoid AL_APIENTRY
alDeleteEffects(ALsizei n
, ALuint
*effects
)
101 Context
= GetContextSuspended();
106 ALCdevice
*device
= Context
->Device
;
108 // Check that all effects are valid
109 for (i
= 0; i
< n
; i
++)
114 if(!VerifyEffect(device
->EffectList
, effects
[i
]))
116 alSetError(Context
, AL_INVALID_NAME
);
123 // All effects are valid
124 for (i
= 0; i
< n
; i
++)
126 // Recheck that the effect is valid, because there could be duplicated names
127 if((ALEffect
=VerifyEffect(device
->EffectList
, effects
[i
])) != NULL
)
131 // Remove Effect from list of effects
132 list
= &device
->EffectList
;
133 while(*list
&& *list
!= ALEffect
)
134 list
= &(*list
)->next
;
137 *list
= (*list
)->next
;
138 ALTHUNK_REMOVEENTRY(ALEffect
->effect
);
140 memset(ALEffect
, 0, sizeof(ALeffect
));
143 device
->EffectCount
--;
149 alSetError(Context
, AL_INVALID_VALUE
);
151 ProcessContext(Context
);
154 ALboolean AL_APIENTRY
alIsEffect(ALuint effect
)
157 ALboolean result
= AL_TRUE
;
159 Context
= GetContextSuspended();
160 if(!Context
) return AL_FALSE
;
163 result
= (VerifyEffect(Context
->Device
->EffectList
, effect
) ?
166 ProcessContext(Context
);
171 ALvoid AL_APIENTRY
alEffecti(ALuint effect
, ALenum param
, ALint iValue
)
177 Context
= GetContextSuspended();
180 Device
= Context
->Device
;
181 if((ALEffect
=VerifyEffect(Device
->EffectList
, effect
)) != NULL
)
183 if(param
== AL_EFFECT_TYPE
)
185 ALboolean isOk
= (iValue
== AL_EFFECT_NULL
||
186 (iValue
== AL_EFFECT_EAXREVERB
&& !DisabledEffects
[EAXREVERB
]) ||
187 (iValue
== AL_EFFECT_REVERB
&& !DisabledEffects
[REVERB
]) ||
188 (iValue
== AL_EFFECT_ECHO
&& !DisabledEffects
[ECHO
]));
191 InitEffectParams(ALEffect
, iValue
);
193 alSetError(Context
, AL_INVALID_VALUE
);
195 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
199 case AL_EAXREVERB_DECAY_HFLIMIT
:
200 if(iValue
>= AL_EAXREVERB_MIN_DECAY_HFLIMIT
&&
201 iValue
<= AL_EAXREVERB_MAX_DECAY_HFLIMIT
)
202 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
204 alSetError(Context
, AL_INVALID_VALUE
);
208 alSetError(Context
, AL_INVALID_ENUM
);
212 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
216 case AL_REVERB_DECAY_HFLIMIT
:
217 if(iValue
>= AL_REVERB_MIN_DECAY_HFLIMIT
&&
218 iValue
<= AL_REVERB_MAX_DECAY_HFLIMIT
)
219 ALEffect
->Reverb
.DecayHFLimit
= iValue
;
221 alSetError(Context
, AL_INVALID_VALUE
);
225 alSetError(Context
, AL_INVALID_ENUM
);
229 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
234 alSetError(Context
, AL_INVALID_ENUM
);
239 alSetError(Context
, AL_INVALID_ENUM
);
242 alSetError(Context
, AL_INVALID_NAME
);
244 ProcessContext(Context
);
247 ALvoid AL_APIENTRY
alEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
253 Context
= GetContextSuspended();
256 Device
= Context
->Device
;
257 if((ALEffect
=VerifyEffect(Device
->EffectList
, effect
)) != NULL
)
259 if(param
== AL_EFFECT_TYPE
)
261 alEffecti(effect
, param
, piValues
[0]);
263 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
267 case AL_EAXREVERB_DECAY_HFLIMIT
:
268 alEffecti(effect
, param
, piValues
[0]);
272 alSetError(Context
, AL_INVALID_ENUM
);
276 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
280 case AL_REVERB_DECAY_HFLIMIT
:
281 alEffecti(effect
, param
, piValues
[0]);
285 alSetError(Context
, AL_INVALID_ENUM
);
289 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
294 alSetError(Context
, AL_INVALID_ENUM
);
299 alSetError(Context
, AL_INVALID_ENUM
);
302 alSetError(Context
, AL_INVALID_NAME
);
304 ProcessContext(Context
);
307 ALvoid AL_APIENTRY
alEffectf(ALuint effect
, ALenum param
, ALfloat flValue
)
313 Context
= GetContextSuspended();
316 Device
= Context
->Device
;
317 if((ALEffect
=VerifyEffect(Device
->EffectList
, effect
)) != NULL
)
319 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
323 case AL_EAXREVERB_DENSITY
:
324 if(flValue
>= AL_EAXREVERB_MIN_DENSITY
&&
325 flValue
<= AL_EAXREVERB_MAX_DENSITY
)
326 ALEffect
->Reverb
.Density
= flValue
;
328 alSetError(Context
, AL_INVALID_VALUE
);
331 case AL_EAXREVERB_DIFFUSION
:
332 if(flValue
>= AL_EAXREVERB_MIN_DIFFUSION
&&
333 flValue
<= AL_EAXREVERB_MAX_DIFFUSION
)
334 ALEffect
->Reverb
.Diffusion
= flValue
;
336 alSetError(Context
, AL_INVALID_VALUE
);
339 case AL_EAXREVERB_GAIN
:
340 if(flValue
>= AL_EAXREVERB_MIN_GAIN
&&
341 flValue
<= AL_EAXREVERB_MAX_GAIN
)
342 ALEffect
->Reverb
.Gain
= flValue
;
344 alSetError(Context
, AL_INVALID_VALUE
);
347 case AL_EAXREVERB_GAINHF
:
348 if(flValue
>= AL_EAXREVERB_MIN_GAINHF
&&
349 flValue
<= AL_EAXREVERB_MAX_GAIN
)
350 ALEffect
->Reverb
.GainHF
= flValue
;
352 alSetError(Context
, AL_INVALID_VALUE
);
355 case AL_EAXREVERB_GAINLF
:
356 if(flValue
>= AL_EAXREVERB_MIN_GAINLF
&&
357 flValue
<= AL_EAXREVERB_MAX_GAINLF
)
358 ALEffect
->Reverb
.GainLF
= flValue
;
360 alSetError(Context
, AL_INVALID_VALUE
);
363 case AL_EAXREVERB_DECAY_TIME
:
364 if(flValue
>= AL_EAXREVERB_MIN_DECAY_TIME
&&
365 flValue
<= AL_EAXREVERB_MAX_DECAY_TIME
)
366 ALEffect
->Reverb
.DecayTime
= flValue
;
368 alSetError(Context
, AL_INVALID_VALUE
);
371 case AL_EAXREVERB_DECAY_HFRATIO
:
372 if(flValue
>= AL_EAXREVERB_MIN_DECAY_HFRATIO
&&
373 flValue
<= AL_EAXREVERB_MAX_DECAY_HFRATIO
)
374 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
376 alSetError(Context
, AL_INVALID_VALUE
);
379 case AL_EAXREVERB_DECAY_LFRATIO
:
380 if(flValue
>= AL_EAXREVERB_MIN_DECAY_LFRATIO
&&
381 flValue
<= AL_EAXREVERB_MAX_DECAY_LFRATIO
)
382 ALEffect
->Reverb
.DecayLFRatio
= flValue
;
384 alSetError(Context
, AL_INVALID_VALUE
);
387 case AL_EAXREVERB_REFLECTIONS_GAIN
:
388 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_GAIN
&&
389 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_GAIN
)
390 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
392 alSetError(Context
, AL_INVALID_VALUE
);
395 case AL_EAXREVERB_REFLECTIONS_DELAY
:
396 if(flValue
>= AL_EAXREVERB_MIN_REFLECTIONS_DELAY
&&
397 flValue
<= AL_EAXREVERB_MAX_REFLECTIONS_DELAY
)
398 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
400 alSetError(Context
, AL_INVALID_VALUE
);
403 case AL_EAXREVERB_LATE_REVERB_GAIN
:
404 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_GAIN
&&
405 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_GAIN
)
406 ALEffect
->Reverb
.LateReverbGain
= flValue
;
408 alSetError(Context
, AL_INVALID_VALUE
);
411 case AL_EAXREVERB_LATE_REVERB_DELAY
:
412 if(flValue
>= AL_EAXREVERB_MIN_LATE_REVERB_DELAY
&&
413 flValue
<= AL_EAXREVERB_MAX_LATE_REVERB_DELAY
)
414 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
416 alSetError(Context
, AL_INVALID_VALUE
);
419 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
420 if(flValue
>= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF
&&
421 flValue
<= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF
)
422 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
424 alSetError(Context
, AL_INVALID_VALUE
);
427 case AL_EAXREVERB_ECHO_TIME
:
428 if(flValue
>= AL_EAXREVERB_MIN_ECHO_TIME
&&
429 flValue
<= AL_EAXREVERB_MAX_ECHO_TIME
)
430 ALEffect
->Reverb
.EchoTime
= flValue
;
432 alSetError(Context
, AL_INVALID_VALUE
);
435 case AL_EAXREVERB_ECHO_DEPTH
:
436 if(flValue
>= AL_EAXREVERB_MIN_ECHO_DEPTH
&&
437 flValue
<= AL_EAXREVERB_MAX_ECHO_DEPTH
)
438 ALEffect
->Reverb
.EchoDepth
= flValue
;
440 alSetError(Context
, AL_INVALID_VALUE
);
443 case AL_EAXREVERB_MODULATION_TIME
:
444 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_TIME
&&
445 flValue
<= AL_EAXREVERB_MAX_MODULATION_TIME
)
446 ALEffect
->Reverb
.ModulationTime
= flValue
;
448 alSetError(Context
, AL_INVALID_VALUE
);
451 case AL_EAXREVERB_MODULATION_DEPTH
:
452 if(flValue
>= AL_EAXREVERB_MIN_MODULATION_DEPTH
&&
453 flValue
<= AL_EAXREVERB_MAX_MODULATION_DEPTH
)
454 ALEffect
->Reverb
.ModulationDepth
= flValue
;
456 alSetError(Context
, AL_INVALID_VALUE
);
459 case AL_EAXREVERB_HFREFERENCE
:
460 if(flValue
>= AL_EAXREVERB_MIN_HFREFERENCE
&&
461 flValue
<= AL_EAXREVERB_MAX_HFREFERENCE
)
462 ALEffect
->Reverb
.HFReference
= flValue
;
464 alSetError(Context
, AL_INVALID_VALUE
);
467 case AL_EAXREVERB_LFREFERENCE
:
468 if(flValue
>= AL_EAXREVERB_MIN_LFREFERENCE
&&
469 flValue
<= AL_EAXREVERB_MAX_LFREFERENCE
)
470 ALEffect
->Reverb
.LFReference
= flValue
;
472 alSetError(Context
, AL_INVALID_VALUE
);
475 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
476 if(flValue
>= 0.0f
&& flValue
<= 10.0f
)
477 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
479 alSetError(Context
, AL_INVALID_VALUE
);
483 alSetError(Context
, AL_INVALID_ENUM
);
487 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
491 case AL_REVERB_DENSITY
:
492 if(flValue
>= AL_REVERB_MIN_DENSITY
&&
493 flValue
<= AL_REVERB_MAX_DENSITY
)
494 ALEffect
->Reverb
.Density
= flValue
;
496 alSetError(Context
, AL_INVALID_VALUE
);
499 case AL_REVERB_DIFFUSION
:
500 if(flValue
>= AL_REVERB_MIN_DIFFUSION
&&
501 flValue
<= AL_REVERB_MAX_DIFFUSION
)
502 ALEffect
->Reverb
.Diffusion
= flValue
;
504 alSetError(Context
, AL_INVALID_VALUE
);
508 if(flValue
>= AL_REVERB_MIN_GAIN
&&
509 flValue
<= AL_REVERB_MAX_GAIN
)
510 ALEffect
->Reverb
.Gain
= flValue
;
512 alSetError(Context
, AL_INVALID_VALUE
);
515 case AL_REVERB_GAINHF
:
516 if(flValue
>= AL_REVERB_MIN_GAINHF
&&
517 flValue
<= AL_REVERB_MAX_GAINHF
)
518 ALEffect
->Reverb
.GainHF
= flValue
;
520 alSetError(Context
, AL_INVALID_VALUE
);
523 case AL_REVERB_DECAY_TIME
:
524 if(flValue
>= AL_REVERB_MIN_DECAY_TIME
&&
525 flValue
<= AL_REVERB_MAX_DECAY_TIME
)
526 ALEffect
->Reverb
.DecayTime
= flValue
;
528 alSetError(Context
, AL_INVALID_VALUE
);
531 case AL_REVERB_DECAY_HFRATIO
:
532 if(flValue
>= AL_REVERB_MIN_DECAY_HFRATIO
&&
533 flValue
<= AL_REVERB_MAX_DECAY_HFRATIO
)
534 ALEffect
->Reverb
.DecayHFRatio
= flValue
;
536 alSetError(Context
, AL_INVALID_VALUE
);
539 case AL_REVERB_REFLECTIONS_GAIN
:
540 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_GAIN
&&
541 flValue
<= AL_REVERB_MAX_REFLECTIONS_GAIN
)
542 ALEffect
->Reverb
.ReflectionsGain
= flValue
;
544 alSetError(Context
, AL_INVALID_VALUE
);
547 case AL_REVERB_REFLECTIONS_DELAY
:
548 if(flValue
>= AL_REVERB_MIN_REFLECTIONS_DELAY
&&
549 flValue
<= AL_REVERB_MAX_REFLECTIONS_DELAY
)
550 ALEffect
->Reverb
.ReflectionsDelay
= flValue
;
552 alSetError(Context
, AL_INVALID_VALUE
);
555 case AL_REVERB_LATE_REVERB_GAIN
:
556 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_GAIN
&&
557 flValue
<= AL_REVERB_MAX_LATE_REVERB_GAIN
)
558 ALEffect
->Reverb
.LateReverbGain
= flValue
;
560 alSetError(Context
, AL_INVALID_VALUE
);
563 case AL_REVERB_LATE_REVERB_DELAY
:
564 if(flValue
>= AL_REVERB_MIN_LATE_REVERB_DELAY
&&
565 flValue
<= AL_REVERB_MAX_LATE_REVERB_DELAY
)
566 ALEffect
->Reverb
.LateReverbDelay
= flValue
;
568 alSetError(Context
, AL_INVALID_VALUE
);
571 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
572 if(flValue
>= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF
&&
573 flValue
<= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF
)
574 ALEffect
->Reverb
.AirAbsorptionGainHF
= flValue
;
576 alSetError(Context
, AL_INVALID_VALUE
);
579 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
580 if(flValue
>= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR
&&
581 flValue
<= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR
)
582 ALEffect
->Reverb
.RoomRolloffFactor
= flValue
;
584 alSetError(Context
, AL_INVALID_VALUE
);
588 alSetError(Context
, AL_INVALID_ENUM
);
592 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
597 if(flValue
>= AL_ECHO_MIN_DELAY
&& flValue
<= AL_ECHO_MAX_DELAY
)
598 ALEffect
->Echo
.Delay
= flValue
;
600 alSetError(Context
, AL_INVALID_VALUE
);
603 case AL_ECHO_LRDELAY
:
604 if(flValue
>= AL_ECHO_MIN_LRDELAY
&& flValue
<= AL_ECHO_MAX_LRDELAY
)
605 ALEffect
->Echo
.LRDelay
= flValue
;
607 alSetError(Context
, AL_INVALID_VALUE
);
610 case AL_ECHO_DAMPING
:
611 if(flValue
>= AL_ECHO_MIN_DAMPING
&& flValue
<= AL_ECHO_MAX_DAMPING
)
612 ALEffect
->Echo
.Damping
= flValue
;
614 alSetError(Context
, AL_INVALID_VALUE
);
617 case AL_ECHO_FEEDBACK
:
618 if(flValue
>= AL_ECHO_MIN_FEEDBACK
&& flValue
<= AL_ECHO_MAX_FEEDBACK
)
619 ALEffect
->Echo
.Feedback
= flValue
;
621 alSetError(Context
, AL_INVALID_VALUE
);
625 if(flValue
>= AL_ECHO_MIN_SPREAD
&& flValue
<= AL_ECHO_MAX_SPREAD
)
626 ALEffect
->Echo
.Spread
= flValue
;
628 alSetError(Context
, AL_INVALID_VALUE
);
632 alSetError(Context
, AL_INVALID_ENUM
);
637 alSetError(Context
, AL_INVALID_ENUM
);
640 alSetError(Context
, AL_INVALID_NAME
);
642 ProcessContext(Context
);
645 ALvoid AL_APIENTRY
alEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
651 Context
= GetContextSuspended();
654 Device
= Context
->Device
;
655 if((ALEffect
=VerifyEffect(Device
->EffectList
, effect
)) != NULL
)
657 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
661 case AL_EAXREVERB_DENSITY
:
662 case AL_EAXREVERB_DIFFUSION
:
663 case AL_EAXREVERB_GAIN
:
664 case AL_EAXREVERB_GAINHF
:
665 case AL_EAXREVERB_GAINLF
:
666 case AL_EAXREVERB_DECAY_TIME
:
667 case AL_EAXREVERB_DECAY_HFRATIO
:
668 case AL_EAXREVERB_DECAY_LFRATIO
:
669 case AL_EAXREVERB_REFLECTIONS_GAIN
:
670 case AL_EAXREVERB_REFLECTIONS_DELAY
:
671 case AL_EAXREVERB_LATE_REVERB_GAIN
:
672 case AL_EAXREVERB_LATE_REVERB_DELAY
:
673 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
674 case AL_EAXREVERB_ECHO_TIME
:
675 case AL_EAXREVERB_ECHO_DEPTH
:
676 case AL_EAXREVERB_MODULATION_TIME
:
677 case AL_EAXREVERB_MODULATION_DEPTH
:
678 case AL_EAXREVERB_HFREFERENCE
:
679 case AL_EAXREVERB_LFREFERENCE
:
680 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
681 alEffectf(effect
, param
, pflValues
[0]);
684 case AL_EAXREVERB_REFLECTIONS_PAN
:
685 if(!isnan(pflValues
[0]) && !isnan(pflValues
[1]) && !isnan(pflValues
[2]))
687 ALEffect
->Reverb
.ReflectionsPan
[0] = pflValues
[0];
688 ALEffect
->Reverb
.ReflectionsPan
[1] = pflValues
[1];
689 ALEffect
->Reverb
.ReflectionsPan
[2] = pflValues
[2];
692 alSetError(Context
, AL_INVALID_VALUE
);
694 case AL_EAXREVERB_LATE_REVERB_PAN
:
695 if(!isnan(pflValues
[0]) && !isnan(pflValues
[1]) && !isnan(pflValues
[2]))
697 ALEffect
->Reverb
.LateReverbPan
[0] = pflValues
[0];
698 ALEffect
->Reverb
.LateReverbPan
[1] = pflValues
[1];
699 ALEffect
->Reverb
.LateReverbPan
[2] = pflValues
[2];
702 alSetError(Context
, AL_INVALID_VALUE
);
706 alSetError(Context
, AL_INVALID_ENUM
);
710 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
714 case AL_REVERB_DENSITY
:
715 case AL_REVERB_DIFFUSION
:
717 case AL_REVERB_GAINHF
:
718 case AL_REVERB_DECAY_TIME
:
719 case AL_REVERB_DECAY_HFRATIO
:
720 case AL_REVERB_REFLECTIONS_GAIN
:
721 case AL_REVERB_REFLECTIONS_DELAY
:
722 case AL_REVERB_LATE_REVERB_GAIN
:
723 case AL_REVERB_LATE_REVERB_DELAY
:
724 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
725 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
726 alEffectf(effect
, param
, pflValues
[0]);
730 alSetError(Context
, AL_INVALID_ENUM
);
734 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
739 case AL_ECHO_LRDELAY
:
740 case AL_ECHO_DAMPING
:
741 case AL_ECHO_FEEDBACK
:
743 alEffectf(effect
, param
, pflValues
[0]);
747 alSetError(Context
, AL_INVALID_ENUM
);
752 alSetError(Context
, AL_INVALID_ENUM
);
755 alSetError(Context
, AL_INVALID_NAME
);
757 ProcessContext(Context
);
760 ALvoid AL_APIENTRY
alGetEffecti(ALuint effect
, ALenum param
, ALint
*piValue
)
766 Context
= GetContextSuspended();
769 Device
= Context
->Device
;
770 if((ALEffect
=VerifyEffect(Device
->EffectList
, effect
)) != NULL
)
772 if(param
== AL_EFFECT_TYPE
)
774 *piValue
= ALEffect
->type
;
776 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
780 case AL_EAXREVERB_DECAY_HFLIMIT
:
781 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
785 alSetError(Context
, AL_INVALID_ENUM
);
789 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
793 case AL_REVERB_DECAY_HFLIMIT
:
794 *piValue
= ALEffect
->Reverb
.DecayHFLimit
;
798 alSetError(Context
, AL_INVALID_ENUM
);
802 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
807 alSetError(Context
, AL_INVALID_ENUM
);
812 alSetError(Context
, AL_INVALID_ENUM
);
815 alSetError(Context
, AL_INVALID_NAME
);
817 ProcessContext(Context
);
820 ALvoid AL_APIENTRY
alGetEffectiv(ALuint effect
, ALenum param
, ALint
*piValues
)
826 Context
= GetContextSuspended();
829 Device
= Context
->Device
;
830 if((ALEffect
=VerifyEffect(Device
->EffectList
, effect
)) != NULL
)
832 if(param
== AL_EFFECT_TYPE
)
834 alGetEffecti(effect
, param
, piValues
);
836 else if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
840 case AL_EAXREVERB_DECAY_HFLIMIT
:
841 alGetEffecti(effect
, param
, piValues
);
845 alSetError(Context
, AL_INVALID_ENUM
);
849 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
853 case AL_REVERB_DECAY_HFLIMIT
:
854 alGetEffecti(effect
, param
, piValues
);
858 alSetError(Context
, AL_INVALID_ENUM
);
862 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
867 alSetError(Context
, AL_INVALID_ENUM
);
872 alSetError(Context
, AL_INVALID_ENUM
);
875 alSetError(Context
, AL_INVALID_NAME
);
877 ProcessContext(Context
);
880 ALvoid AL_APIENTRY
alGetEffectf(ALuint effect
, ALenum param
, ALfloat
*pflValue
)
886 Context
= GetContextSuspended();
889 Device
= Context
->Device
;
890 if((ALEffect
=VerifyEffect(Device
->EffectList
, effect
)) != NULL
)
892 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
896 case AL_EAXREVERB_DENSITY
:
897 *pflValue
= ALEffect
->Reverb
.Density
;
900 case AL_EAXREVERB_DIFFUSION
:
901 *pflValue
= ALEffect
->Reverb
.Diffusion
;
904 case AL_EAXREVERB_GAIN
:
905 *pflValue
= ALEffect
->Reverb
.Gain
;
908 case AL_EAXREVERB_GAINHF
:
909 *pflValue
= ALEffect
->Reverb
.GainHF
;
912 case AL_EAXREVERB_GAINLF
:
913 *pflValue
= ALEffect
->Reverb
.GainLF
;
916 case AL_EAXREVERB_DECAY_TIME
:
917 *pflValue
= ALEffect
->Reverb
.DecayTime
;
920 case AL_EAXREVERB_DECAY_HFRATIO
:
921 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
924 case AL_EAXREVERB_DECAY_LFRATIO
:
925 *pflValue
= ALEffect
->Reverb
.DecayLFRatio
;
928 case AL_EAXREVERB_REFLECTIONS_GAIN
:
929 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
932 case AL_EAXREVERB_REFLECTIONS_DELAY
:
933 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
936 case AL_EAXREVERB_LATE_REVERB_GAIN
:
937 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
940 case AL_EAXREVERB_LATE_REVERB_DELAY
:
941 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
944 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
945 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
948 case AL_EAXREVERB_ECHO_TIME
:
949 *pflValue
= ALEffect
->Reverb
.EchoTime
;
952 case AL_EAXREVERB_ECHO_DEPTH
:
953 *pflValue
= ALEffect
->Reverb
.EchoDepth
;
956 case AL_EAXREVERB_MODULATION_TIME
:
957 *pflValue
= ALEffect
->Reverb
.ModulationTime
;
960 case AL_EAXREVERB_MODULATION_DEPTH
:
961 *pflValue
= ALEffect
->Reverb
.ModulationDepth
;
964 case AL_EAXREVERB_HFREFERENCE
:
965 *pflValue
= ALEffect
->Reverb
.HFReference
;
968 case AL_EAXREVERB_LFREFERENCE
:
969 *pflValue
= ALEffect
->Reverb
.LFReference
;
972 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
973 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
977 alSetError(Context
, AL_INVALID_ENUM
);
981 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
985 case AL_REVERB_DENSITY
:
986 *pflValue
= ALEffect
->Reverb
.Density
;
989 case AL_REVERB_DIFFUSION
:
990 *pflValue
= ALEffect
->Reverb
.Diffusion
;
994 *pflValue
= ALEffect
->Reverb
.Gain
;
997 case AL_REVERB_GAINHF
:
998 *pflValue
= ALEffect
->Reverb
.GainHF
;
1001 case AL_REVERB_DECAY_TIME
:
1002 *pflValue
= ALEffect
->Reverb
.DecayTime
;
1005 case AL_REVERB_DECAY_HFRATIO
:
1006 *pflValue
= ALEffect
->Reverb
.DecayHFRatio
;
1009 case AL_REVERB_REFLECTIONS_GAIN
:
1010 *pflValue
= ALEffect
->Reverb
.ReflectionsGain
;
1013 case AL_REVERB_REFLECTIONS_DELAY
:
1014 *pflValue
= ALEffect
->Reverb
.ReflectionsDelay
;
1017 case AL_REVERB_LATE_REVERB_GAIN
:
1018 *pflValue
= ALEffect
->Reverb
.LateReverbGain
;
1021 case AL_REVERB_LATE_REVERB_DELAY
:
1022 *pflValue
= ALEffect
->Reverb
.LateReverbDelay
;
1025 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1026 *pflValue
= ALEffect
->Reverb
.AirAbsorptionGainHF
;
1029 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1030 *pflValue
= ALEffect
->Reverb
.RoomRolloffFactor
;
1034 alSetError(Context
, AL_INVALID_ENUM
);
1038 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1043 *pflValue
= ALEffect
->Echo
.Delay
;
1046 case AL_ECHO_LRDELAY
:
1047 *pflValue
= ALEffect
->Echo
.LRDelay
;
1050 case AL_ECHO_DAMPING
:
1051 *pflValue
= ALEffect
->Echo
.Damping
;
1054 case AL_ECHO_FEEDBACK
:
1055 *pflValue
= ALEffect
->Echo
.Feedback
;
1058 case AL_ECHO_SPREAD
:
1059 *pflValue
= ALEffect
->Echo
.Spread
;
1063 alSetError(Context
, AL_INVALID_ENUM
);
1068 alSetError(Context
, AL_INVALID_ENUM
);
1071 alSetError(Context
, AL_INVALID_NAME
);
1073 ProcessContext(Context
);
1076 ALvoid AL_APIENTRY
alGetEffectfv(ALuint effect
, ALenum param
, ALfloat
*pflValues
)
1078 ALCcontext
*Context
;
1082 Context
= GetContextSuspended();
1083 if(!Context
) return;
1085 Device
= Context
->Device
;
1086 if((ALEffect
=VerifyEffect(Device
->EffectList
, effect
)) != NULL
)
1088 if(ALEffect
->type
== AL_EFFECT_EAXREVERB
)
1092 case AL_EAXREVERB_DENSITY
:
1093 case AL_EAXREVERB_DIFFUSION
:
1094 case AL_EAXREVERB_GAIN
:
1095 case AL_EAXREVERB_GAINHF
:
1096 case AL_EAXREVERB_GAINLF
:
1097 case AL_EAXREVERB_DECAY_TIME
:
1098 case AL_EAXREVERB_DECAY_HFRATIO
:
1099 case AL_EAXREVERB_DECAY_LFRATIO
:
1100 case AL_EAXREVERB_REFLECTIONS_GAIN
:
1101 case AL_EAXREVERB_REFLECTIONS_DELAY
:
1102 case AL_EAXREVERB_LATE_REVERB_GAIN
:
1103 case AL_EAXREVERB_LATE_REVERB_DELAY
:
1104 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF
:
1105 case AL_EAXREVERB_ECHO_TIME
:
1106 case AL_EAXREVERB_ECHO_DEPTH
:
1107 case AL_EAXREVERB_MODULATION_TIME
:
1108 case AL_EAXREVERB_MODULATION_DEPTH
:
1109 case AL_EAXREVERB_HFREFERENCE
:
1110 case AL_EAXREVERB_LFREFERENCE
:
1111 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
:
1112 alGetEffectf(effect
, param
, pflValues
);
1115 case AL_EAXREVERB_REFLECTIONS_PAN
:
1116 pflValues
[0] = ALEffect
->Reverb
.ReflectionsPan
[0];
1117 pflValues
[1] = ALEffect
->Reverb
.ReflectionsPan
[1];
1118 pflValues
[2] = ALEffect
->Reverb
.ReflectionsPan
[2];
1120 case AL_EAXREVERB_LATE_REVERB_PAN
:
1121 pflValues
[0] = ALEffect
->Reverb
.LateReverbPan
[0];
1122 pflValues
[1] = ALEffect
->Reverb
.LateReverbPan
[1];
1123 pflValues
[2] = ALEffect
->Reverb
.LateReverbPan
[2];
1127 alSetError(Context
, AL_INVALID_ENUM
);
1131 else if(ALEffect
->type
== AL_EFFECT_REVERB
)
1135 case AL_REVERB_DENSITY
:
1136 case AL_REVERB_DIFFUSION
:
1137 case AL_REVERB_GAIN
:
1138 case AL_REVERB_GAINHF
:
1139 case AL_REVERB_DECAY_TIME
:
1140 case AL_REVERB_DECAY_HFRATIO
:
1141 case AL_REVERB_REFLECTIONS_GAIN
:
1142 case AL_REVERB_REFLECTIONS_DELAY
:
1143 case AL_REVERB_LATE_REVERB_GAIN
:
1144 case AL_REVERB_LATE_REVERB_DELAY
:
1145 case AL_REVERB_AIR_ABSORPTION_GAINHF
:
1146 case AL_REVERB_ROOM_ROLLOFF_FACTOR
:
1147 alGetEffectf(effect
, param
, pflValues
);
1151 alSetError(Context
, AL_INVALID_ENUM
);
1155 else if(ALEffect
->type
== AL_EFFECT_ECHO
)
1160 case AL_ECHO_LRDELAY
:
1161 case AL_ECHO_DAMPING
:
1162 case AL_ECHO_FEEDBACK
:
1163 case AL_ECHO_SPREAD
:
1164 alGetEffectf(effect
, param
, pflValues
);
1168 alSetError(Context
, AL_INVALID_ENUM
);
1173 alSetError(Context
, AL_INVALID_ENUM
);
1176 alSetError(Context
, AL_INVALID_NAME
);
1178 ProcessContext(Context
);
1182 ALvoid
ReleaseALEffects(ALCdevice
*device
)
1184 ALeffect
*list
= device
->EffectList
;
1187 ALeffect
*temp
= list
;
1190 // Release effect structure
1191 memset(temp
, 0, sizeof(ALeffect
));
1194 device
->EffectList
= NULL
;
1195 device
->EffectCount
= 0;
1199 static void InitEffectParams(ALeffect
*effect
, ALenum type
)
1201 effect
->type
= type
;
1204 /* NOTE: Standard reverb and EAX reverb use the same defaults for the
1205 * shared parameters, and EAX's additional parameters default to
1206 * values assumed by standard reverb.
1208 case AL_EFFECT_EAXREVERB
:
1209 case AL_EFFECT_REVERB
:
1210 effect
->Reverb
.Density
= AL_EAXREVERB_DEFAULT_DENSITY
;
1211 effect
->Reverb
.Diffusion
= AL_EAXREVERB_DEFAULT_DIFFUSION
;
1212 effect
->Reverb
.Gain
= AL_EAXREVERB_DEFAULT_GAIN
;
1213 effect
->Reverb
.GainHF
= AL_EAXREVERB_DEFAULT_GAINHF
;
1214 effect
->Reverb
.GainLF
= AL_EAXREVERB_DEFAULT_GAINLF
;
1215 effect
->Reverb
.DecayTime
= AL_EAXREVERB_DEFAULT_DECAY_TIME
;
1216 effect
->Reverb
.DecayHFRatio
= AL_EAXREVERB_DEFAULT_DECAY_HFRATIO
;
1217 effect
->Reverb
.DecayLFRatio
= AL_EAXREVERB_DEFAULT_DECAY_LFRATIO
;
1218 effect
->Reverb
.ReflectionsGain
= AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN
;
1219 effect
->Reverb
.ReflectionsDelay
= AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY
;
1220 effect
->Reverb
.ReflectionsPan
[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1221 effect
->Reverb
.ReflectionsPan
[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1222 effect
->Reverb
.ReflectionsPan
[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ
;
1223 effect
->Reverb
.LateReverbGain
= AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN
;
1224 effect
->Reverb
.LateReverbDelay
= AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY
;
1225 effect
->Reverb
.LateReverbPan
[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1226 effect
->Reverb
.LateReverbPan
[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1227 effect
->Reverb
.LateReverbPan
[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ
;
1228 effect
->Reverb
.EchoTime
= AL_EAXREVERB_DEFAULT_ECHO_TIME
;
1229 effect
->Reverb
.EchoDepth
= AL_EAXREVERB_DEFAULT_ECHO_DEPTH
;
1230 effect
->Reverb
.ModulationTime
= AL_EAXREVERB_DEFAULT_MODULATION_TIME
;
1231 effect
->Reverb
.ModulationDepth
= AL_EAXREVERB_DEFAULT_MODULATION_DEPTH
;
1232 effect
->Reverb
.AirAbsorptionGainHF
= AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF
;
1233 effect
->Reverb
.HFReference
= AL_EAXREVERB_DEFAULT_HFREFERENCE
;
1234 effect
->Reverb
.LFReference
= AL_EAXREVERB_DEFAULT_LFREFERENCE
;
1235 effect
->Reverb
.RoomRolloffFactor
= AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR
;
1236 effect
->Reverb
.DecayHFLimit
= AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT
;
1238 case AL_EFFECT_ECHO
:
1239 effect
->Echo
.Delay
= AL_ECHO_DEFAULT_DELAY
;
1240 effect
->Echo
.LRDelay
= AL_ECHO_DEFAULT_LRDELAY
;
1241 effect
->Echo
.Damping
= AL_ECHO_DEFAULT_DAMPING
;
1242 effect
->Echo
.Feedback
= AL_ECHO_DEFAULT_FEEDBACK
;
1243 effect
->Echo
.Spread
= AL_ECHO_DEFAULT_SPREAD
;