diff OpenAL32/alEffect.c @ 0:f9476ff7637e

initial forking of open-al to create multiple listeners
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 13:02:31 -0700
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/OpenAL32/alEffect.c	Tue Oct 25 13:02:31 2011 -0700
     1.3 @@ -0,0 +1,1142 @@
     1.4 +/**
     1.5 + * OpenAL cross platform audio library
     1.6 + * Copyright (C) 1999-2007 by authors.
     1.7 + * This library is free software; you can redistribute it and/or
     1.8 + *  modify it under the terms of the GNU Library General Public
     1.9 + *  License as published by the Free Software Foundation; either
    1.10 + *  version 2 of the License, or (at your option) any later version.
    1.11 + *
    1.12 + * This library is distributed in the hope that it will be useful,
    1.13 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.15 + *  Library General Public License for more details.
    1.16 + *
    1.17 + * You should have received a copy of the GNU Library General Public
    1.18 + *  License along with this library; if not, write to the
    1.19 + *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    1.20 + *  Boston, MA  02111-1307, USA.
    1.21 + * Or go to http://www.gnu.org/copyleft/lgpl.html
    1.22 + */
    1.23 +
    1.24 +#include "config.h"
    1.25 +
    1.26 +#include <stdlib.h>
    1.27 +#include <math.h>
    1.28 +
    1.29 +#include "AL/al.h"
    1.30 +#include "AL/alc.h"
    1.31 +#include "alMain.h"
    1.32 +#include "alEffect.h"
    1.33 +#include "alThunk.h"
    1.34 +#include "alError.h"
    1.35 +
    1.36 +
    1.37 +ALboolean DisabledEffects[MAX_EFFECTS];
    1.38 +
    1.39 +
    1.40 +static void InitEffectParams(ALeffect *effect, ALenum type);
    1.41 +
    1.42 +#define LookupEffect(m, k) ((ALeffect*)LookupUIntMapKey(&(m), (k)))
    1.43 +
    1.44 +AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
    1.45 +{
    1.46 +    ALCcontext *Context;
    1.47 +    ALsizei i=0;
    1.48 +
    1.49 +    Context = GetLockedContext();
    1.50 +    if(!Context) return;
    1.51 +
    1.52 +    if(n < 0 || IsBadWritePtr((void*)effects, n * sizeof(ALuint)))
    1.53 +        alSetError(Context, AL_INVALID_VALUE);
    1.54 +    else
    1.55 +    {
    1.56 +        ALCdevice *device = Context->Device;
    1.57 +        ALenum err;
    1.58 +
    1.59 +        while(i < n)
    1.60 +        {
    1.61 +            ALeffect *effect = calloc(1, sizeof(ALeffect));
    1.62 +            if(!effect)
    1.63 +            {
    1.64 +                alSetError(Context, AL_OUT_OF_MEMORY);
    1.65 +                alDeleteEffects(i, effects);
    1.66 +                break;
    1.67 +            }
    1.68 +
    1.69 +            err = NewThunkEntry(&effect->effect);
    1.70 +            if(err == AL_NO_ERROR)
    1.71 +                err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect);
    1.72 +            if(err != AL_NO_ERROR)
    1.73 +            {
    1.74 +                FreeThunkEntry(effect->effect);
    1.75 +                memset(effect, 0, sizeof(ALeffect));
    1.76 +                free(effect);
    1.77 +
    1.78 +                alSetError(Context, err);
    1.79 +                alDeleteEffects(i, effects);
    1.80 +                break;
    1.81 +            }
    1.82 +
    1.83 +            effects[i++] = effect->effect;
    1.84 +            InitEffectParams(effect, AL_EFFECT_NULL);
    1.85 +        }
    1.86 +    }
    1.87 +
    1.88 +    UnlockContext(Context);
    1.89 +}
    1.90 +
    1.91 +AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects)
    1.92 +{
    1.93 +    ALCcontext *Context;
    1.94 +    ALCdevice *device;
    1.95 +    ALeffect *ALEffect;
    1.96 +    ALboolean Failed;
    1.97 +    ALsizei i;
    1.98 +
    1.99 +    Context = GetLockedContext();
   1.100 +    if(!Context) return;
   1.101 +
   1.102 +    Failed = AL_TRUE;
   1.103 +    device = Context->Device;
   1.104 +    if(n < 0)
   1.105 +        alSetError(Context, AL_INVALID_VALUE);
   1.106 +    else
   1.107 +    {
   1.108 +        Failed = AL_FALSE;
   1.109 +        // Check that all effects are valid
   1.110 +        for(i = 0;i < n;i++)
   1.111 +        {
   1.112 +            if(!effects[i])
   1.113 +                continue;
   1.114 +
   1.115 +            if(LookupEffect(device->EffectMap, effects[i]) == NULL)
   1.116 +            {
   1.117 +                alSetError(Context, AL_INVALID_NAME);
   1.118 +                Failed = AL_TRUE;
   1.119 +                break;
   1.120 +            }
   1.121 +        }
   1.122 +    }
   1.123 +
   1.124 +    if(!Failed)
   1.125 +    {
   1.126 +        // All effects are valid
   1.127 +        for(i = 0;i < n;i++)
   1.128 +        {
   1.129 +            // Recheck that the effect is valid, because there could be duplicated names
   1.130 +            if((ALEffect=LookupEffect(device->EffectMap, effects[i])) == NULL)
   1.131 +                continue;
   1.132 +
   1.133 +            RemoveUIntMapKey(&device->EffectMap, ALEffect->effect);
   1.134 +            FreeThunkEntry(ALEffect->effect);
   1.135 +
   1.136 +            memset(ALEffect, 0, sizeof(ALeffect));
   1.137 +            free(ALEffect);
   1.138 +        }
   1.139 +    }
   1.140 +
   1.141 +    UnlockContext(Context);
   1.142 +}
   1.143 +
   1.144 +AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
   1.145 +{
   1.146 +    ALCcontext *Context;
   1.147 +    ALboolean  result;
   1.148 +
   1.149 +    Context = GetLockedContext();
   1.150 +    if(!Context) return AL_FALSE;
   1.151 +
   1.152 +    result = ((!effect || LookupEffect(Context->Device->EffectMap, effect)) ?
   1.153 +              AL_TRUE : AL_FALSE);
   1.154 +
   1.155 +    UnlockContext(Context);
   1.156 +
   1.157 +    return result;
   1.158 +}
   1.159 +
   1.160 +AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
   1.161 +{
   1.162 +    ALCcontext *Context;
   1.163 +    ALCdevice  *Device;
   1.164 +    ALeffect   *ALEffect;
   1.165 +
   1.166 +    Context = GetLockedContext();
   1.167 +    if(!Context) return;
   1.168 +
   1.169 +    Device = Context->Device;
   1.170 +    if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
   1.171 +    {
   1.172 +        if(param == AL_EFFECT_TYPE)
   1.173 +        {
   1.174 +            ALboolean isOk = (iValue == AL_EFFECT_NULL);
   1.175 +            ALint i;
   1.176 +            for(i = 0;!isOk && EffectList[i].val;i++)
   1.177 +            {
   1.178 +                if(iValue == EffectList[i].val &&
   1.179 +                   !DisabledEffects[EffectList[i].type])
   1.180 +                    isOk = AL_TRUE;
   1.181 +            }
   1.182 +
   1.183 +            if(isOk)
   1.184 +                InitEffectParams(ALEffect, iValue);
   1.185 +            else
   1.186 +                alSetError(Context, AL_INVALID_VALUE);
   1.187 +        }
   1.188 +        else if(ALEffect->type == AL_EFFECT_EAXREVERB)
   1.189 +        {
   1.190 +            switch(param)
   1.191 +            {
   1.192 +            case AL_EAXREVERB_DECAY_HFLIMIT:
   1.193 +                if(iValue >= AL_EAXREVERB_MIN_DECAY_HFLIMIT &&
   1.194 +                   iValue <= AL_EAXREVERB_MAX_DECAY_HFLIMIT)
   1.195 +                    ALEffect->Params.Reverb.DecayHFLimit = iValue;
   1.196 +                else
   1.197 +                    alSetError(Context, AL_INVALID_VALUE);
   1.198 +                break;
   1.199 +
   1.200 +            default:
   1.201 +                alSetError(Context, AL_INVALID_ENUM);
   1.202 +                break;
   1.203 +            }
   1.204 +        }
   1.205 +        else if(ALEffect->type == AL_EFFECT_REVERB)
   1.206 +        {
   1.207 +            switch(param)
   1.208 +            {
   1.209 +            case AL_REVERB_DECAY_HFLIMIT:
   1.210 +                if(iValue >= AL_REVERB_MIN_DECAY_HFLIMIT &&
   1.211 +                   iValue <= AL_REVERB_MAX_DECAY_HFLIMIT)
   1.212 +                    ALEffect->Params.Reverb.DecayHFLimit = iValue;
   1.213 +                else
   1.214 +                    alSetError(Context, AL_INVALID_VALUE);
   1.215 +                break;
   1.216 +
   1.217 +            default:
   1.218 +                alSetError(Context, AL_INVALID_ENUM);
   1.219 +                break;
   1.220 +            }
   1.221 +        }
   1.222 +        else if(ALEffect->type == AL_EFFECT_ECHO)
   1.223 +        {
   1.224 +            switch(param)
   1.225 +            {
   1.226 +            default:
   1.227 +                alSetError(Context, AL_INVALID_ENUM);
   1.228 +                break;
   1.229 +            }
   1.230 +        }
   1.231 +        else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
   1.232 +        {
   1.233 +            switch(param)
   1.234 +            {
   1.235 +            case AL_RING_MODULATOR_FREQUENCY:
   1.236 +                if(iValue >= AL_RING_MODULATOR_MIN_FREQUENCY &&
   1.237 +                   iValue <= AL_RING_MODULATOR_MAX_FREQUENCY)
   1.238 +                    ALEffect->Params.Modulator.Frequency = iValue;
   1.239 +                else
   1.240 +                    alSetError(Context, AL_INVALID_VALUE);
   1.241 +                break;
   1.242 +
   1.243 +            case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
   1.244 +                if(iValue >= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF &&
   1.245 +                   iValue <= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF)
   1.246 +                    ALEffect->Params.Modulator.HighPassCutoff = iValue;
   1.247 +                else
   1.248 +                    alSetError(Context, AL_INVALID_VALUE);
   1.249 +                break;
   1.250 +
   1.251 +            case AL_RING_MODULATOR_WAVEFORM:
   1.252 +                if(iValue >= AL_RING_MODULATOR_MIN_WAVEFORM &&
   1.253 +                   iValue <= AL_RING_MODULATOR_MAX_WAVEFORM)
   1.254 +                    ALEffect->Params.Modulator.Waveform = iValue;
   1.255 +                else
   1.256 +                    alSetError(Context, AL_INVALID_VALUE);
   1.257 +                break;
   1.258 +
   1.259 +            default:
   1.260 +                alSetError(Context, AL_INVALID_ENUM);
   1.261 +                break;
   1.262 +            }
   1.263 +        }
   1.264 +        else
   1.265 +            alSetError(Context, AL_INVALID_ENUM);
   1.266 +    }
   1.267 +    else
   1.268 +        alSetError(Context, AL_INVALID_NAME);
   1.269 +
   1.270 +    UnlockContext(Context);
   1.271 +}
   1.272 +
   1.273 +AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues)
   1.274 +{
   1.275 +    /* There are no multi-value int effect parameters */
   1.276 +    alEffecti(effect, param, piValues[0]);
   1.277 +}
   1.278 +
   1.279 +AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue)
   1.280 +{
   1.281 +    ALCcontext *Context;
   1.282 +    ALCdevice  *Device;
   1.283 +    ALeffect   *ALEffect;
   1.284 +
   1.285 +    Context = GetLockedContext();
   1.286 +    if(!Context) return;
   1.287 +
   1.288 +    Device = Context->Device;
   1.289 +    if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
   1.290 +    {
   1.291 +        if(ALEffect->type == AL_EFFECT_EAXREVERB)
   1.292 +        {
   1.293 +            switch(param)
   1.294 +            {
   1.295 +            case AL_EAXREVERB_DENSITY:
   1.296 +                if(flValue >= AL_EAXREVERB_MIN_DENSITY &&
   1.297 +                   flValue <= AL_EAXREVERB_MAX_DENSITY)
   1.298 +                    ALEffect->Params.Reverb.Density = flValue;
   1.299 +                else
   1.300 +                    alSetError(Context, AL_INVALID_VALUE);
   1.301 +                break;
   1.302 +
   1.303 +            case AL_EAXREVERB_DIFFUSION:
   1.304 +                if(flValue >= AL_EAXREVERB_MIN_DIFFUSION &&
   1.305 +                   flValue <= AL_EAXREVERB_MAX_DIFFUSION)
   1.306 +                    ALEffect->Params.Reverb.Diffusion = flValue;
   1.307 +                else
   1.308 +                    alSetError(Context, AL_INVALID_VALUE);
   1.309 +                break;
   1.310 +
   1.311 +            case AL_EAXREVERB_GAIN:
   1.312 +                if(flValue >= AL_EAXREVERB_MIN_GAIN &&
   1.313 +                   flValue <= AL_EAXREVERB_MAX_GAIN)
   1.314 +                    ALEffect->Params.Reverb.Gain = flValue;
   1.315 +                else
   1.316 +                    alSetError(Context, AL_INVALID_VALUE);
   1.317 +                break;
   1.318 +
   1.319 +            case AL_EAXREVERB_GAINHF:
   1.320 +                if(flValue >= AL_EAXREVERB_MIN_GAINHF &&
   1.321 +                   flValue <= AL_EAXREVERB_MAX_GAINHF)
   1.322 +                    ALEffect->Params.Reverb.GainHF = flValue;
   1.323 +                else
   1.324 +                    alSetError(Context, AL_INVALID_VALUE);
   1.325 +                break;
   1.326 +
   1.327 +            case AL_EAXREVERB_GAINLF:
   1.328 +                if(flValue >= AL_EAXREVERB_MIN_GAINLF &&
   1.329 +                   flValue <= AL_EAXREVERB_MAX_GAINLF)
   1.330 +                    ALEffect->Params.Reverb.GainLF = flValue;
   1.331 +                else
   1.332 +                    alSetError(Context, AL_INVALID_VALUE);
   1.333 +                break;
   1.334 +
   1.335 +            case AL_EAXREVERB_DECAY_TIME:
   1.336 +                if(flValue >= AL_EAXREVERB_MIN_DECAY_TIME &&
   1.337 +                   flValue <= AL_EAXREVERB_MAX_DECAY_TIME)
   1.338 +                    ALEffect->Params.Reverb.DecayTime = flValue;
   1.339 +                else
   1.340 +                    alSetError(Context, AL_INVALID_VALUE);
   1.341 +                break;
   1.342 +
   1.343 +            case AL_EAXREVERB_DECAY_HFRATIO:
   1.344 +                if(flValue >= AL_EAXREVERB_MIN_DECAY_HFRATIO &&
   1.345 +                   flValue <= AL_EAXREVERB_MAX_DECAY_HFRATIO)
   1.346 +                    ALEffect->Params.Reverb.DecayHFRatio = flValue;
   1.347 +                else
   1.348 +                    alSetError(Context, AL_INVALID_VALUE);
   1.349 +                break;
   1.350 +
   1.351 +            case AL_EAXREVERB_DECAY_LFRATIO:
   1.352 +                if(flValue >= AL_EAXREVERB_MIN_DECAY_LFRATIO &&
   1.353 +                   flValue <= AL_EAXREVERB_MAX_DECAY_LFRATIO)
   1.354 +                    ALEffect->Params.Reverb.DecayLFRatio = flValue;
   1.355 +                else
   1.356 +                    alSetError(Context, AL_INVALID_VALUE);
   1.357 +                break;
   1.358 +
   1.359 +            case AL_EAXREVERB_REFLECTIONS_GAIN:
   1.360 +                if(flValue >= AL_EAXREVERB_MIN_REFLECTIONS_GAIN &&
   1.361 +                   flValue <= AL_EAXREVERB_MAX_REFLECTIONS_GAIN)
   1.362 +                    ALEffect->Params.Reverb.ReflectionsGain = flValue;
   1.363 +                else
   1.364 +                    alSetError(Context, AL_INVALID_VALUE);
   1.365 +                break;
   1.366 +
   1.367 +            case AL_EAXREVERB_REFLECTIONS_DELAY:
   1.368 +                if(flValue >= AL_EAXREVERB_MIN_REFLECTIONS_DELAY &&
   1.369 +                   flValue <= AL_EAXREVERB_MAX_REFLECTIONS_DELAY)
   1.370 +                    ALEffect->Params.Reverb.ReflectionsDelay = flValue;
   1.371 +                else
   1.372 +                    alSetError(Context, AL_INVALID_VALUE);
   1.373 +                break;
   1.374 +
   1.375 +            case AL_EAXREVERB_LATE_REVERB_GAIN:
   1.376 +                if(flValue >= AL_EAXREVERB_MIN_LATE_REVERB_GAIN &&
   1.377 +                   flValue <= AL_EAXREVERB_MAX_LATE_REVERB_GAIN)
   1.378 +                    ALEffect->Params.Reverb.LateReverbGain = flValue;
   1.379 +                else
   1.380 +                    alSetError(Context, AL_INVALID_VALUE);
   1.381 +                break;
   1.382 +
   1.383 +            case AL_EAXREVERB_LATE_REVERB_DELAY:
   1.384 +                if(flValue >= AL_EAXREVERB_MIN_LATE_REVERB_DELAY &&
   1.385 +                   flValue <= AL_EAXREVERB_MAX_LATE_REVERB_DELAY)
   1.386 +                    ALEffect->Params.Reverb.LateReverbDelay = flValue;
   1.387 +                else
   1.388 +                    alSetError(Context, AL_INVALID_VALUE);
   1.389 +                break;
   1.390 +
   1.391 +            case AL_EAXREVERB_AIR_ABSORPTION_GAINHF:
   1.392 +                if(flValue >= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF &&
   1.393 +                   flValue <= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF)
   1.394 +                    ALEffect->Params.Reverb.AirAbsorptionGainHF = flValue;
   1.395 +                else
   1.396 +                    alSetError(Context, AL_INVALID_VALUE);
   1.397 +                break;
   1.398 +
   1.399 +            case AL_EAXREVERB_ECHO_TIME:
   1.400 +                if(flValue >= AL_EAXREVERB_MIN_ECHO_TIME &&
   1.401 +                   flValue <= AL_EAXREVERB_MAX_ECHO_TIME)
   1.402 +                    ALEffect->Params.Reverb.EchoTime = flValue;
   1.403 +                else
   1.404 +                    alSetError(Context, AL_INVALID_VALUE);
   1.405 +                break;
   1.406 +
   1.407 +            case AL_EAXREVERB_ECHO_DEPTH:
   1.408 +                if(flValue >= AL_EAXREVERB_MIN_ECHO_DEPTH &&
   1.409 +                   flValue <= AL_EAXREVERB_MAX_ECHO_DEPTH)
   1.410 +                    ALEffect->Params.Reverb.EchoDepth = flValue;
   1.411 +                else
   1.412 +                    alSetError(Context, AL_INVALID_VALUE);
   1.413 +                break;
   1.414 +
   1.415 +            case AL_EAXREVERB_MODULATION_TIME:
   1.416 +                if(flValue >= AL_EAXREVERB_MIN_MODULATION_TIME &&
   1.417 +                   flValue <= AL_EAXREVERB_MAX_MODULATION_TIME)
   1.418 +                    ALEffect->Params.Reverb.ModulationTime = flValue;
   1.419 +                else
   1.420 +                    alSetError(Context, AL_INVALID_VALUE);
   1.421 +                break;
   1.422 +
   1.423 +            case AL_EAXREVERB_MODULATION_DEPTH:
   1.424 +                if(flValue >= AL_EAXREVERB_MIN_MODULATION_DEPTH &&
   1.425 +                   flValue <= AL_EAXREVERB_MAX_MODULATION_DEPTH)
   1.426 +                    ALEffect->Params.Reverb.ModulationDepth = flValue;
   1.427 +                else
   1.428 +                    alSetError(Context, AL_INVALID_VALUE);
   1.429 +                break;
   1.430 +
   1.431 +            case AL_EAXREVERB_HFREFERENCE:
   1.432 +                if(flValue >= AL_EAXREVERB_MIN_HFREFERENCE &&
   1.433 +                   flValue <= AL_EAXREVERB_MAX_HFREFERENCE)
   1.434 +                    ALEffect->Params.Reverb.HFReference = flValue;
   1.435 +                else
   1.436 +                    alSetError(Context, AL_INVALID_VALUE);
   1.437 +                break;
   1.438 +
   1.439 +            case AL_EAXREVERB_LFREFERENCE:
   1.440 +                if(flValue >= AL_EAXREVERB_MIN_LFREFERENCE &&
   1.441 +                   flValue <= AL_EAXREVERB_MAX_LFREFERENCE)
   1.442 +                    ALEffect->Params.Reverb.LFReference = flValue;
   1.443 +                else
   1.444 +                    alSetError(Context, AL_INVALID_VALUE);
   1.445 +                break;
   1.446 +
   1.447 +            case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR:
   1.448 +                if(flValue >= 0.0f && flValue <= 10.0f)
   1.449 +                    ALEffect->Params.Reverb.RoomRolloffFactor = flValue;
   1.450 +                else
   1.451 +                    alSetError(Context, AL_INVALID_VALUE);
   1.452 +                break;
   1.453 +
   1.454 +            default:
   1.455 +                alSetError(Context, AL_INVALID_ENUM);
   1.456 +                break;
   1.457 +            }
   1.458 +        }
   1.459 +        else if(ALEffect->type == AL_EFFECT_REVERB)
   1.460 +        {
   1.461 +            switch(param)
   1.462 +            {
   1.463 +            case AL_REVERB_DENSITY:
   1.464 +                if(flValue >= AL_REVERB_MIN_DENSITY &&
   1.465 +                   flValue <= AL_REVERB_MAX_DENSITY)
   1.466 +                    ALEffect->Params.Reverb.Density = flValue;
   1.467 +                else
   1.468 +                    alSetError(Context, AL_INVALID_VALUE);
   1.469 +                break;
   1.470 +
   1.471 +            case AL_REVERB_DIFFUSION:
   1.472 +                if(flValue >= AL_REVERB_MIN_DIFFUSION &&
   1.473 +                   flValue <= AL_REVERB_MAX_DIFFUSION)
   1.474 +                    ALEffect->Params.Reverb.Diffusion = flValue;
   1.475 +                else
   1.476 +                    alSetError(Context, AL_INVALID_VALUE);
   1.477 +                break;
   1.478 +
   1.479 +            case AL_REVERB_GAIN:
   1.480 +                if(flValue >= AL_REVERB_MIN_GAIN &&
   1.481 +                   flValue <= AL_REVERB_MAX_GAIN)
   1.482 +                    ALEffect->Params.Reverb.Gain = flValue;
   1.483 +                else
   1.484 +                    alSetError(Context, AL_INVALID_VALUE);
   1.485 +                break;
   1.486 +
   1.487 +            case AL_REVERB_GAINHF:
   1.488 +                if(flValue >= AL_REVERB_MIN_GAINHF &&
   1.489 +                   flValue <= AL_REVERB_MAX_GAINHF)
   1.490 +                    ALEffect->Params.Reverb.GainHF = flValue;
   1.491 +                else
   1.492 +                    alSetError(Context, AL_INVALID_VALUE);
   1.493 +                break;
   1.494 +
   1.495 +            case AL_REVERB_DECAY_TIME:
   1.496 +                if(flValue >= AL_REVERB_MIN_DECAY_TIME &&
   1.497 +                   flValue <= AL_REVERB_MAX_DECAY_TIME)
   1.498 +                    ALEffect->Params.Reverb.DecayTime = flValue;
   1.499 +                else
   1.500 +                    alSetError(Context, AL_INVALID_VALUE);
   1.501 +                break;
   1.502 +
   1.503 +            case AL_REVERB_DECAY_HFRATIO:
   1.504 +                if(flValue >= AL_REVERB_MIN_DECAY_HFRATIO &&
   1.505 +                   flValue <= AL_REVERB_MAX_DECAY_HFRATIO)
   1.506 +                    ALEffect->Params.Reverb.DecayHFRatio = flValue;
   1.507 +                else
   1.508 +                    alSetError(Context, AL_INVALID_VALUE);
   1.509 +                break;
   1.510 +
   1.511 +            case AL_REVERB_REFLECTIONS_GAIN:
   1.512 +                if(flValue >= AL_REVERB_MIN_REFLECTIONS_GAIN &&
   1.513 +                   flValue <= AL_REVERB_MAX_REFLECTIONS_GAIN)
   1.514 +                    ALEffect->Params.Reverb.ReflectionsGain = flValue;
   1.515 +                else
   1.516 +                    alSetError(Context, AL_INVALID_VALUE);
   1.517 +                break;
   1.518 +
   1.519 +            case AL_REVERB_REFLECTIONS_DELAY:
   1.520 +                if(flValue >= AL_REVERB_MIN_REFLECTIONS_DELAY &&
   1.521 +                   flValue <= AL_REVERB_MAX_REFLECTIONS_DELAY)
   1.522 +                    ALEffect->Params.Reverb.ReflectionsDelay = flValue;
   1.523 +                else
   1.524 +                    alSetError(Context, AL_INVALID_VALUE);
   1.525 +                break;
   1.526 +
   1.527 +            case AL_REVERB_LATE_REVERB_GAIN:
   1.528 +                if(flValue >= AL_REVERB_MIN_LATE_REVERB_GAIN &&
   1.529 +                   flValue <= AL_REVERB_MAX_LATE_REVERB_GAIN)
   1.530 +                    ALEffect->Params.Reverb.LateReverbGain = flValue;
   1.531 +                else
   1.532 +                    alSetError(Context, AL_INVALID_VALUE);
   1.533 +                break;
   1.534 +
   1.535 +            case AL_REVERB_LATE_REVERB_DELAY:
   1.536 +                if(flValue >= AL_REVERB_MIN_LATE_REVERB_DELAY &&
   1.537 +                   flValue <= AL_REVERB_MAX_LATE_REVERB_DELAY)
   1.538 +                    ALEffect->Params.Reverb.LateReverbDelay = flValue;
   1.539 +                else
   1.540 +                    alSetError(Context, AL_INVALID_VALUE);
   1.541 +                break;
   1.542 +
   1.543 +            case AL_REVERB_AIR_ABSORPTION_GAINHF:
   1.544 +                if(flValue >= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF &&
   1.545 +                   flValue <= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF)
   1.546 +                    ALEffect->Params.Reverb.AirAbsorptionGainHF = flValue;
   1.547 +                else
   1.548 +                    alSetError(Context, AL_INVALID_VALUE);
   1.549 +                break;
   1.550 +
   1.551 +            case AL_REVERB_ROOM_ROLLOFF_FACTOR:
   1.552 +                if(flValue >= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR &&
   1.553 +                   flValue <= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR)
   1.554 +                    ALEffect->Params.Reverb.RoomRolloffFactor = flValue;
   1.555 +                else
   1.556 +                    alSetError(Context, AL_INVALID_VALUE);
   1.557 +                break;
   1.558 +
   1.559 +            default:
   1.560 +                alSetError(Context, AL_INVALID_ENUM);
   1.561 +                break;
   1.562 +            }
   1.563 +        }
   1.564 +        else if(ALEffect->type == AL_EFFECT_ECHO)
   1.565 +        {
   1.566 +            switch(param)
   1.567 +            {
   1.568 +            case AL_ECHO_DELAY:
   1.569 +                if(flValue >= AL_ECHO_MIN_DELAY && flValue <= AL_ECHO_MAX_DELAY)
   1.570 +                    ALEffect->Params.Echo.Delay = flValue;
   1.571 +                else
   1.572 +                    alSetError(Context, AL_INVALID_VALUE);
   1.573 +                break;
   1.574 +
   1.575 +            case AL_ECHO_LRDELAY:
   1.576 +                if(flValue >= AL_ECHO_MIN_LRDELAY && flValue <= AL_ECHO_MAX_LRDELAY)
   1.577 +                    ALEffect->Params.Echo.LRDelay = flValue;
   1.578 +                else
   1.579 +                    alSetError(Context, AL_INVALID_VALUE);
   1.580 +                break;
   1.581 +
   1.582 +            case AL_ECHO_DAMPING:
   1.583 +                if(flValue >= AL_ECHO_MIN_DAMPING && flValue <= AL_ECHO_MAX_DAMPING)
   1.584 +                    ALEffect->Params.Echo.Damping = flValue;
   1.585 +                else
   1.586 +                    alSetError(Context, AL_INVALID_VALUE);
   1.587 +                break;
   1.588 +
   1.589 +            case AL_ECHO_FEEDBACK:
   1.590 +                if(flValue >= AL_ECHO_MIN_FEEDBACK && flValue <= AL_ECHO_MAX_FEEDBACK)
   1.591 +                    ALEffect->Params.Echo.Feedback = flValue;
   1.592 +                else
   1.593 +                    alSetError(Context, AL_INVALID_VALUE);
   1.594 +                break;
   1.595 +
   1.596 +            case AL_ECHO_SPREAD:
   1.597 +                if(flValue >= AL_ECHO_MIN_SPREAD && flValue <= AL_ECHO_MAX_SPREAD)
   1.598 +                    ALEffect->Params.Echo.Spread = flValue;
   1.599 +                else
   1.600 +                    alSetError(Context, AL_INVALID_VALUE);
   1.601 +                break;
   1.602 +
   1.603 +            default:
   1.604 +                alSetError(Context, AL_INVALID_ENUM);
   1.605 +                break;
   1.606 +            }
   1.607 +        }
   1.608 +        else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
   1.609 +        {
   1.610 +            switch(param)
   1.611 +            {
   1.612 +            case AL_RING_MODULATOR_FREQUENCY:
   1.613 +                if(flValue >= AL_RING_MODULATOR_MIN_FREQUENCY &&
   1.614 +                   flValue <= AL_RING_MODULATOR_MAX_FREQUENCY)
   1.615 +                    ALEffect->Params.Modulator.Frequency = flValue;
   1.616 +                else
   1.617 +                    alSetError(Context, AL_INVALID_VALUE);
   1.618 +                break;
   1.619 +
   1.620 +            case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
   1.621 +                if(flValue >= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF &&
   1.622 +                   flValue <= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF)
   1.623 +                    ALEffect->Params.Modulator.HighPassCutoff = flValue;
   1.624 +                else
   1.625 +                    alSetError(Context, AL_INVALID_VALUE);
   1.626 +                break;
   1.627 +
   1.628 +            default:
   1.629 +                alSetError(Context, AL_INVALID_ENUM);
   1.630 +                break;
   1.631 +            }
   1.632 +        }
   1.633 +        else if(ALEffect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
   1.634 +                ALEffect->type == AL_EFFECT_DEDICATED_DIALOGUE)
   1.635 +        {
   1.636 +            switch(param)
   1.637 +            {
   1.638 +            case AL_DEDICATED_GAIN:
   1.639 +                if(flValue >= 0.0f && isfinite(flValue))
   1.640 +                    ALEffect->Params.Dedicated.Gain = flValue;
   1.641 +                else
   1.642 +                    alSetError(Context, AL_INVALID_VALUE);
   1.643 +                break;
   1.644 +
   1.645 +            default:
   1.646 +                alSetError(Context, AL_INVALID_ENUM);
   1.647 +                break;
   1.648 +            }
   1.649 +        }
   1.650 +        else
   1.651 +            alSetError(Context, AL_INVALID_ENUM);
   1.652 +    }
   1.653 +    else
   1.654 +        alSetError(Context, AL_INVALID_NAME);
   1.655 +
   1.656 +    UnlockContext(Context);
   1.657 +}
   1.658 +
   1.659 +AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflValues)
   1.660 +{
   1.661 +    ALCcontext *Context;
   1.662 +    ALCdevice  *Device;
   1.663 +    ALeffect   *ALEffect;
   1.664 +
   1.665 +    Context = GetLockedContext();
   1.666 +    if(!Context) return;
   1.667 +
   1.668 +    Device = Context->Device;
   1.669 +    if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
   1.670 +    {
   1.671 +        if(ALEffect->type == AL_EFFECT_EAXREVERB)
   1.672 +        {
   1.673 +            switch(param)
   1.674 +            {
   1.675 +            case AL_EAXREVERB_REFLECTIONS_PAN:
   1.676 +                if(isfinite(pflValues[0]) && isfinite(pflValues[1]) && isfinite(pflValues[2]))
   1.677 +                {
   1.678 +                    ALEffect->Params.Reverb.ReflectionsPan[0] = pflValues[0];
   1.679 +                    ALEffect->Params.Reverb.ReflectionsPan[1] = pflValues[1];
   1.680 +                    ALEffect->Params.Reverb.ReflectionsPan[2] = pflValues[2];
   1.681 +                }
   1.682 +                else
   1.683 +                    alSetError(Context, AL_INVALID_VALUE);
   1.684 +                break;
   1.685 +            case AL_EAXREVERB_LATE_REVERB_PAN:
   1.686 +                if(isfinite(pflValues[0]) && isfinite(pflValues[1]) && isfinite(pflValues[2]))
   1.687 +                {
   1.688 +                    ALEffect->Params.Reverb.LateReverbPan[0] = pflValues[0];
   1.689 +                    ALEffect->Params.Reverb.LateReverbPan[1] = pflValues[1];
   1.690 +                    ALEffect->Params.Reverb.LateReverbPan[2] = pflValues[2];
   1.691 +                }
   1.692 +                else
   1.693 +                    alSetError(Context, AL_INVALID_VALUE);
   1.694 +                break;
   1.695 +
   1.696 +            default:
   1.697 +                UnlockContext(Context);
   1.698 +                alEffectf(effect, param, pflValues[0]);
   1.699 +                return;
   1.700 +            }
   1.701 +        }
   1.702 +        else
   1.703 +        {
   1.704 +            UnlockContext(Context);
   1.705 +            alEffectf(effect, param, pflValues[0]);
   1.706 +            return;
   1.707 +        }
   1.708 +    }
   1.709 +    else
   1.710 +        alSetError(Context, AL_INVALID_NAME);
   1.711 +
   1.712 +    UnlockContext(Context);
   1.713 +}
   1.714 +
   1.715 +AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue)
   1.716 +{
   1.717 +    ALCcontext *Context;
   1.718 +    ALCdevice  *Device;
   1.719 +    ALeffect   *ALEffect;
   1.720 +
   1.721 +    Context = GetLockedContext();
   1.722 +    if(!Context) return;
   1.723 +
   1.724 +    Device = Context->Device;
   1.725 +    if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
   1.726 +    {
   1.727 +        if(param == AL_EFFECT_TYPE)
   1.728 +        {
   1.729 +            *piValue = ALEffect->type;
   1.730 +        }
   1.731 +        else if(ALEffect->type == AL_EFFECT_EAXREVERB)
   1.732 +        {
   1.733 +            switch(param)
   1.734 +            {
   1.735 +            case AL_EAXREVERB_DECAY_HFLIMIT:
   1.736 +                *piValue = ALEffect->Params.Reverb.DecayHFLimit;
   1.737 +                break;
   1.738 +
   1.739 +            default:
   1.740 +                alSetError(Context, AL_INVALID_ENUM);
   1.741 +                break;
   1.742 +            }
   1.743 +        }
   1.744 +        else if(ALEffect->type == AL_EFFECT_REVERB)
   1.745 +        {
   1.746 +            switch(param)
   1.747 +            {
   1.748 +            case AL_REVERB_DECAY_HFLIMIT:
   1.749 +                *piValue = ALEffect->Params.Reverb.DecayHFLimit;
   1.750 +                break;
   1.751 +
   1.752 +            default:
   1.753 +                alSetError(Context, AL_INVALID_ENUM);
   1.754 +                break;
   1.755 +            }
   1.756 +        }
   1.757 +        else if(ALEffect->type == AL_EFFECT_ECHO)
   1.758 +        {
   1.759 +            switch(param)
   1.760 +            {
   1.761 +            default:
   1.762 +                alSetError(Context, AL_INVALID_ENUM);
   1.763 +                break;
   1.764 +            }
   1.765 +        }
   1.766 +        else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
   1.767 +        {
   1.768 +            switch(param)
   1.769 +            {
   1.770 +            case AL_RING_MODULATOR_FREQUENCY:
   1.771 +                *piValue = (ALint)ALEffect->Params.Modulator.Frequency;
   1.772 +                break;
   1.773 +            case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
   1.774 +                *piValue = (ALint)ALEffect->Params.Modulator.HighPassCutoff;
   1.775 +                break;
   1.776 +            case AL_RING_MODULATOR_WAVEFORM:
   1.777 +                *piValue = ALEffect->Params.Modulator.Waveform;
   1.778 +                break;
   1.779 +
   1.780 +            default:
   1.781 +                alSetError(Context, AL_INVALID_ENUM);
   1.782 +                break;
   1.783 +            }
   1.784 +        }
   1.785 +        else
   1.786 +            alSetError(Context, AL_INVALID_ENUM);
   1.787 +    }
   1.788 +    else
   1.789 +        alSetError(Context, AL_INVALID_NAME);
   1.790 +
   1.791 +    UnlockContext(Context);
   1.792 +}
   1.793 +
   1.794 +AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues)
   1.795 +{
   1.796 +    /* There are no multi-value int effect parameters */
   1.797 +    alGetEffecti(effect, param, piValues);
   1.798 +}
   1.799 +
   1.800 +AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue)
   1.801 +{
   1.802 +    ALCcontext *Context;
   1.803 +    ALCdevice  *Device;
   1.804 +    ALeffect   *ALEffect;
   1.805 +
   1.806 +    Context = GetLockedContext();
   1.807 +    if(!Context) return;
   1.808 +
   1.809 +    Device = Context->Device;
   1.810 +    if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
   1.811 +    {
   1.812 +        if(ALEffect->type == AL_EFFECT_EAXREVERB)
   1.813 +        {
   1.814 +            switch(param)
   1.815 +            {
   1.816 +            case AL_EAXREVERB_DENSITY:
   1.817 +                *pflValue = ALEffect->Params.Reverb.Density;
   1.818 +                break;
   1.819 +
   1.820 +            case AL_EAXREVERB_DIFFUSION:
   1.821 +                *pflValue = ALEffect->Params.Reverb.Diffusion;
   1.822 +                break;
   1.823 +
   1.824 +            case AL_EAXREVERB_GAIN:
   1.825 +                *pflValue = ALEffect->Params.Reverb.Gain;
   1.826 +                break;
   1.827 +
   1.828 +            case AL_EAXREVERB_GAINHF:
   1.829 +                *pflValue = ALEffect->Params.Reverb.GainHF;
   1.830 +                break;
   1.831 +
   1.832 +            case AL_EAXREVERB_GAINLF:
   1.833 +                *pflValue = ALEffect->Params.Reverb.GainLF;
   1.834 +                break;
   1.835 +
   1.836 +            case AL_EAXREVERB_DECAY_TIME:
   1.837 +                *pflValue = ALEffect->Params.Reverb.DecayTime;
   1.838 +                break;
   1.839 +
   1.840 +            case AL_EAXREVERB_DECAY_HFRATIO:
   1.841 +                *pflValue = ALEffect->Params.Reverb.DecayHFRatio;
   1.842 +                break;
   1.843 +
   1.844 +            case AL_EAXREVERB_DECAY_LFRATIO:
   1.845 +                *pflValue = ALEffect->Params.Reverb.DecayLFRatio;
   1.846 +                break;
   1.847 +
   1.848 +            case AL_EAXREVERB_REFLECTIONS_GAIN:
   1.849 +                *pflValue = ALEffect->Params.Reverb.ReflectionsGain;
   1.850 +                break;
   1.851 +
   1.852 +            case AL_EAXREVERB_REFLECTIONS_DELAY:
   1.853 +                *pflValue = ALEffect->Params.Reverb.ReflectionsDelay;
   1.854 +                break;
   1.855 +
   1.856 +            case AL_EAXREVERB_LATE_REVERB_GAIN:
   1.857 +                *pflValue = ALEffect->Params.Reverb.LateReverbGain;
   1.858 +                break;
   1.859 +
   1.860 +            case AL_EAXREVERB_LATE_REVERB_DELAY:
   1.861 +                *pflValue = ALEffect->Params.Reverb.LateReverbDelay;
   1.862 +                break;
   1.863 +
   1.864 +            case AL_EAXREVERB_AIR_ABSORPTION_GAINHF:
   1.865 +                *pflValue = ALEffect->Params.Reverb.AirAbsorptionGainHF;
   1.866 +                break;
   1.867 +
   1.868 +            case AL_EAXREVERB_ECHO_TIME:
   1.869 +                *pflValue = ALEffect->Params.Reverb.EchoTime;
   1.870 +                break;
   1.871 +
   1.872 +            case AL_EAXREVERB_ECHO_DEPTH:
   1.873 +                *pflValue = ALEffect->Params.Reverb.EchoDepth;
   1.874 +                break;
   1.875 +
   1.876 +            case AL_EAXREVERB_MODULATION_TIME:
   1.877 +                *pflValue = ALEffect->Params.Reverb.ModulationTime;
   1.878 +                break;
   1.879 +
   1.880 +            case AL_EAXREVERB_MODULATION_DEPTH:
   1.881 +                *pflValue = ALEffect->Params.Reverb.ModulationDepth;
   1.882 +                break;
   1.883 +
   1.884 +            case AL_EAXREVERB_HFREFERENCE:
   1.885 +                *pflValue = ALEffect->Params.Reverb.HFReference;
   1.886 +                break;
   1.887 +
   1.888 +            case AL_EAXREVERB_LFREFERENCE:
   1.889 +                *pflValue = ALEffect->Params.Reverb.LFReference;
   1.890 +                break;
   1.891 +
   1.892 +            case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR:
   1.893 +                *pflValue = ALEffect->Params.Reverb.RoomRolloffFactor;
   1.894 +                break;
   1.895 +
   1.896 +            default:
   1.897 +                alSetError(Context, AL_INVALID_ENUM);
   1.898 +                break;
   1.899 +            }
   1.900 +        }
   1.901 +        else if(ALEffect->type == AL_EFFECT_REVERB)
   1.902 +        {
   1.903 +            switch(param)
   1.904 +            {
   1.905 +            case AL_REVERB_DENSITY:
   1.906 +                *pflValue = ALEffect->Params.Reverb.Density;
   1.907 +                break;
   1.908 +
   1.909 +            case AL_REVERB_DIFFUSION:
   1.910 +                *pflValue = ALEffect->Params.Reverb.Diffusion;
   1.911 +                break;
   1.912 +
   1.913 +            case AL_REVERB_GAIN:
   1.914 +                *pflValue = ALEffect->Params.Reverb.Gain;
   1.915 +                break;
   1.916 +
   1.917 +            case AL_REVERB_GAINHF:
   1.918 +                *pflValue = ALEffect->Params.Reverb.GainHF;
   1.919 +                break;
   1.920 +
   1.921 +            case AL_REVERB_DECAY_TIME:
   1.922 +                *pflValue = ALEffect->Params.Reverb.DecayTime;
   1.923 +                break;
   1.924 +
   1.925 +            case AL_REVERB_DECAY_HFRATIO:
   1.926 +                *pflValue = ALEffect->Params.Reverb.DecayHFRatio;
   1.927 +                break;
   1.928 +
   1.929 +            case AL_REVERB_REFLECTIONS_GAIN:
   1.930 +                *pflValue = ALEffect->Params.Reverb.ReflectionsGain;
   1.931 +                break;
   1.932 +
   1.933 +            case AL_REVERB_REFLECTIONS_DELAY:
   1.934 +                *pflValue = ALEffect->Params.Reverb.ReflectionsDelay;
   1.935 +                break;
   1.936 +
   1.937 +            case AL_REVERB_LATE_REVERB_GAIN:
   1.938 +                *pflValue = ALEffect->Params.Reverb.LateReverbGain;
   1.939 +                break;
   1.940 +
   1.941 +            case AL_REVERB_LATE_REVERB_DELAY:
   1.942 +                *pflValue = ALEffect->Params.Reverb.LateReverbDelay;
   1.943 +                break;
   1.944 +
   1.945 +            case AL_REVERB_AIR_ABSORPTION_GAINHF:
   1.946 +                *pflValue = ALEffect->Params.Reverb.AirAbsorptionGainHF;
   1.947 +                break;
   1.948 +
   1.949 +            case AL_REVERB_ROOM_ROLLOFF_FACTOR:
   1.950 +                *pflValue = ALEffect->Params.Reverb.RoomRolloffFactor;
   1.951 +                break;
   1.952 +
   1.953 +            default:
   1.954 +                alSetError(Context, AL_INVALID_ENUM);
   1.955 +                break;
   1.956 +            }
   1.957 +        }
   1.958 +        else if(ALEffect->type == AL_EFFECT_ECHO)
   1.959 +        {
   1.960 +            switch(param)
   1.961 +            {
   1.962 +            case AL_ECHO_DELAY:
   1.963 +                *pflValue = ALEffect->Params.Echo.Delay;
   1.964 +                break;
   1.965 +
   1.966 +            case AL_ECHO_LRDELAY:
   1.967 +                *pflValue = ALEffect->Params.Echo.LRDelay;
   1.968 +                break;
   1.969 +
   1.970 +            case AL_ECHO_DAMPING:
   1.971 +                *pflValue = ALEffect->Params.Echo.Damping;
   1.972 +                break;
   1.973 +
   1.974 +            case AL_ECHO_FEEDBACK:
   1.975 +                *pflValue = ALEffect->Params.Echo.Feedback;
   1.976 +                break;
   1.977 +
   1.978 +            case AL_ECHO_SPREAD:
   1.979 +                *pflValue = ALEffect->Params.Echo.Spread;
   1.980 +                break;
   1.981 +
   1.982 +            default:
   1.983 +                alSetError(Context, AL_INVALID_ENUM);
   1.984 +                break;
   1.985 +            }
   1.986 +        }
   1.987 +        else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
   1.988 +        {
   1.989 +            switch(param)
   1.990 +            {
   1.991 +            case AL_RING_MODULATOR_FREQUENCY:
   1.992 +                *pflValue = ALEffect->Params.Modulator.Frequency;
   1.993 +                break;
   1.994 +            case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
   1.995 +                *pflValue = ALEffect->Params.Modulator.HighPassCutoff;
   1.996 +                break;
   1.997 +
   1.998 +            default:
   1.999 +                alSetError(Context, AL_INVALID_ENUM);
  1.1000 +                break;
  1.1001 +            }
  1.1002 +        }
  1.1003 +        else if(ALEffect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
  1.1004 +                ALEffect->type == AL_EFFECT_DEDICATED_DIALOGUE)
  1.1005 +        {
  1.1006 +            switch(param)
  1.1007 +            {
  1.1008 +            case AL_DEDICATED_GAIN:
  1.1009 +                *pflValue = ALEffect->Params.Dedicated.Gain;
  1.1010 +                break;
  1.1011 +
  1.1012 +            default:
  1.1013 +                alSetError(Context, AL_INVALID_ENUM);
  1.1014 +                break;
  1.1015 +            }
  1.1016 +        }
  1.1017 +        else
  1.1018 +            alSetError(Context, AL_INVALID_ENUM);
  1.1019 +    }
  1.1020 +    else
  1.1021 +        alSetError(Context, AL_INVALID_NAME);
  1.1022 +
  1.1023 +    UnlockContext(Context);
  1.1024 +}
  1.1025 +
  1.1026 +AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues)
  1.1027 +{
  1.1028 +    ALCcontext *Context;
  1.1029 +    ALCdevice  *Device;
  1.1030 +    ALeffect   *ALEffect;
  1.1031 +
  1.1032 +    Context = GetLockedContext();
  1.1033 +    if(!Context) return;
  1.1034 +
  1.1035 +    Device = Context->Device;
  1.1036 +    if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
  1.1037 +    {
  1.1038 +        if(ALEffect->type == AL_EFFECT_EAXREVERB)
  1.1039 +        {
  1.1040 +            switch(param)
  1.1041 +            {
  1.1042 +            case AL_EAXREVERB_REFLECTIONS_PAN:
  1.1043 +                pflValues[0] = ALEffect->Params.Reverb.ReflectionsPan[0];
  1.1044 +                pflValues[1] = ALEffect->Params.Reverb.ReflectionsPan[1];
  1.1045 +                pflValues[2] = ALEffect->Params.Reverb.ReflectionsPan[2];
  1.1046 +                break;
  1.1047 +            case AL_EAXREVERB_LATE_REVERB_PAN:
  1.1048 +                pflValues[0] = ALEffect->Params.Reverb.LateReverbPan[0];
  1.1049 +                pflValues[1] = ALEffect->Params.Reverb.LateReverbPan[1];
  1.1050 +                pflValues[2] = ALEffect->Params.Reverb.LateReverbPan[2];
  1.1051 +                break;
  1.1052 +
  1.1053 +            default:
  1.1054 +                UnlockContext(Context);
  1.1055 +                alGetEffectf(effect, param, pflValues);
  1.1056 +                return;
  1.1057 +            }
  1.1058 +        }
  1.1059 +        else
  1.1060 +        {
  1.1061 +            UnlockContext(Context);
  1.1062 +            alGetEffectf(effect, param, pflValues);
  1.1063 +            return;
  1.1064 +        }
  1.1065 +    }
  1.1066 +    else
  1.1067 +        alSetError(Context, AL_INVALID_NAME);
  1.1068 +
  1.1069 +    UnlockContext(Context);
  1.1070 +}
  1.1071 +
  1.1072 +
  1.1073 +ALvoid ReleaseALEffects(ALCdevice *device)
  1.1074 +{
  1.1075 +    ALsizei i;
  1.1076 +    for(i = 0;i < device->EffectMap.size;i++)
  1.1077 +    {
  1.1078 +        ALeffect *temp = device->EffectMap.array[i].value;
  1.1079 +        device->EffectMap.array[i].value = NULL;
  1.1080 +
  1.1081 +        // Release effect structure
  1.1082 +        FreeThunkEntry(temp->effect);
  1.1083 +        memset(temp, 0, sizeof(ALeffect));
  1.1084 +        free(temp);
  1.1085 +    }
  1.1086 +}
  1.1087 +
  1.1088 +
  1.1089 +static void InitEffectParams(ALeffect *effect, ALenum type)
  1.1090 +{
  1.1091 +    effect->type = type;
  1.1092 +    switch(type)
  1.1093 +    {
  1.1094 +    /* NOTE: Standard reverb and EAX reverb use the same defaults for the
  1.1095 +     *       shared parameters, and EAX's additional parameters default to
  1.1096 +     *       values assumed by standard reverb.
  1.1097 +     */
  1.1098 +    case AL_EFFECT_EAXREVERB:
  1.1099 +    case AL_EFFECT_REVERB:
  1.1100 +        effect->Params.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY;
  1.1101 +        effect->Params.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION;
  1.1102 +        effect->Params.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN;
  1.1103 +        effect->Params.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF;
  1.1104 +        effect->Params.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF;
  1.1105 +        effect->Params.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME;
  1.1106 +        effect->Params.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO;
  1.1107 +        effect->Params.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO;
  1.1108 +        effect->Params.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN;
  1.1109 +        effect->Params.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY;
  1.1110 +        effect->Params.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  1.1111 +        effect->Params.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  1.1112 +        effect->Params.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  1.1113 +        effect->Params.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN;
  1.1114 +        effect->Params.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY;
  1.1115 +        effect->Params.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  1.1116 +        effect->Params.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  1.1117 +        effect->Params.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  1.1118 +        effect->Params.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME;
  1.1119 +        effect->Params.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH;
  1.1120 +        effect->Params.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME;
  1.1121 +        effect->Params.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH;
  1.1122 +        effect->Params.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
  1.1123 +        effect->Params.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE;
  1.1124 +        effect->Params.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE;
  1.1125 +        effect->Params.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
  1.1126 +        effect->Params.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT;
  1.1127 +        break;
  1.1128 +    case AL_EFFECT_ECHO:
  1.1129 +        effect->Params.Echo.Delay = AL_ECHO_DEFAULT_DELAY;
  1.1130 +        effect->Params.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY;
  1.1131 +        effect->Params.Echo.Damping = AL_ECHO_DEFAULT_DAMPING;
  1.1132 +        effect->Params.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK;
  1.1133 +        effect->Params.Echo.Spread = AL_ECHO_DEFAULT_SPREAD;
  1.1134 +        break;
  1.1135 +    case AL_EFFECT_RING_MODULATOR:
  1.1136 +        effect->Params.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
  1.1137 +        effect->Params.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
  1.1138 +        effect->Params.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
  1.1139 +        break;
  1.1140 +    case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT:
  1.1141 +    case AL_EFFECT_DEDICATED_DIALOGUE:
  1.1142 +        effect->Params.Dedicated.Gain = 1.0f;
  1.1143 +        break;
  1.1144 +    }
  1.1145 +}