annotate OpenAL32/alEffect.c @ 26:56f83c170251

adding hard-to-compile artifacts for other systems
author Robert McIntyre <rlm@mit.edu>
date Sat, 19 Nov 2011 19:17:37 -0700
parents f9476ff7637e
children
rev   line source
rlm@0 1 /**
rlm@0 2 * OpenAL cross platform audio library
rlm@0 3 * Copyright (C) 1999-2007 by authors.
rlm@0 4 * This library is free software; you can redistribute it and/or
rlm@0 5 * modify it under the terms of the GNU Library General Public
rlm@0 6 * License as published by the Free Software Foundation; either
rlm@0 7 * version 2 of the License, or (at your option) any later version.
rlm@0 8 *
rlm@0 9 * This library is distributed in the hope that it will be useful,
rlm@0 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rlm@0 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
rlm@0 12 * Library General Public License for more details.
rlm@0 13 *
rlm@0 14 * You should have received a copy of the GNU Library General Public
rlm@0 15 * License along with this library; if not, write to the
rlm@0 16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
rlm@0 17 * Boston, MA 02111-1307, USA.
rlm@0 18 * Or go to http://www.gnu.org/copyleft/lgpl.html
rlm@0 19 */
rlm@0 20
rlm@0 21 #include "config.h"
rlm@0 22
rlm@0 23 #include <stdlib.h>
rlm@0 24 #include <math.h>
rlm@0 25
rlm@0 26 #include "AL/al.h"
rlm@0 27 #include "AL/alc.h"
rlm@0 28 #include "alMain.h"
rlm@0 29 #include "alEffect.h"
rlm@0 30 #include "alThunk.h"
rlm@0 31 #include "alError.h"
rlm@0 32
rlm@0 33
rlm@0 34 ALboolean DisabledEffects[MAX_EFFECTS];
rlm@0 35
rlm@0 36
rlm@0 37 static void InitEffectParams(ALeffect *effect, ALenum type);
rlm@0 38
rlm@0 39 #define LookupEffect(m, k) ((ALeffect*)LookupUIntMapKey(&(m), (k)))
rlm@0 40
rlm@0 41 AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
rlm@0 42 {
rlm@0 43 ALCcontext *Context;
rlm@0 44 ALsizei i=0;
rlm@0 45
rlm@0 46 Context = GetLockedContext();
rlm@0 47 if(!Context) return;
rlm@0 48
rlm@0 49 if(n < 0 || IsBadWritePtr((void*)effects, n * sizeof(ALuint)))
rlm@0 50 alSetError(Context, AL_INVALID_VALUE);
rlm@0 51 else
rlm@0 52 {
rlm@0 53 ALCdevice *device = Context->Device;
rlm@0 54 ALenum err;
rlm@0 55
rlm@0 56 while(i < n)
rlm@0 57 {
rlm@0 58 ALeffect *effect = calloc(1, sizeof(ALeffect));
rlm@0 59 if(!effect)
rlm@0 60 {
rlm@0 61 alSetError(Context, AL_OUT_OF_MEMORY);
rlm@0 62 alDeleteEffects(i, effects);
rlm@0 63 break;
rlm@0 64 }
rlm@0 65
rlm@0 66 err = NewThunkEntry(&effect->effect);
rlm@0 67 if(err == AL_NO_ERROR)
rlm@0 68 err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect);
rlm@0 69 if(err != AL_NO_ERROR)
rlm@0 70 {
rlm@0 71 FreeThunkEntry(effect->effect);
rlm@0 72 memset(effect, 0, sizeof(ALeffect));
rlm@0 73 free(effect);
rlm@0 74
rlm@0 75 alSetError(Context, err);
rlm@0 76 alDeleteEffects(i, effects);
rlm@0 77 break;
rlm@0 78 }
rlm@0 79
rlm@0 80 effects[i++] = effect->effect;
rlm@0 81 InitEffectParams(effect, AL_EFFECT_NULL);
rlm@0 82 }
rlm@0 83 }
rlm@0 84
rlm@0 85 UnlockContext(Context);
rlm@0 86 }
rlm@0 87
rlm@0 88 AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects)
rlm@0 89 {
rlm@0 90 ALCcontext *Context;
rlm@0 91 ALCdevice *device;
rlm@0 92 ALeffect *ALEffect;
rlm@0 93 ALboolean Failed;
rlm@0 94 ALsizei i;
rlm@0 95
rlm@0 96 Context = GetLockedContext();
rlm@0 97 if(!Context) return;
rlm@0 98
rlm@0 99 Failed = AL_TRUE;
rlm@0 100 device = Context->Device;
rlm@0 101 if(n < 0)
rlm@0 102 alSetError(Context, AL_INVALID_VALUE);
rlm@0 103 else
rlm@0 104 {
rlm@0 105 Failed = AL_FALSE;
rlm@0 106 // Check that all effects are valid
rlm@0 107 for(i = 0;i < n;i++)
rlm@0 108 {
rlm@0 109 if(!effects[i])
rlm@0 110 continue;
rlm@0 111
rlm@0 112 if(LookupEffect(device->EffectMap, effects[i]) == NULL)
rlm@0 113 {
rlm@0 114 alSetError(Context, AL_INVALID_NAME);
rlm@0 115 Failed = AL_TRUE;
rlm@0 116 break;
rlm@0 117 }
rlm@0 118 }
rlm@0 119 }
rlm@0 120
rlm@0 121 if(!Failed)
rlm@0 122 {
rlm@0 123 // All effects are valid
rlm@0 124 for(i = 0;i < n;i++)
rlm@0 125 {
rlm@0 126 // Recheck that the effect is valid, because there could be duplicated names
rlm@0 127 if((ALEffect=LookupEffect(device->EffectMap, effects[i])) == NULL)
rlm@0 128 continue;
rlm@0 129
rlm@0 130 RemoveUIntMapKey(&device->EffectMap, ALEffect->effect);
rlm@0 131 FreeThunkEntry(ALEffect->effect);
rlm@0 132
rlm@0 133 memset(ALEffect, 0, sizeof(ALeffect));
rlm@0 134 free(ALEffect);
rlm@0 135 }
rlm@0 136 }
rlm@0 137
rlm@0 138 UnlockContext(Context);
rlm@0 139 }
rlm@0 140
rlm@0 141 AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
rlm@0 142 {
rlm@0 143 ALCcontext *Context;
rlm@0 144 ALboolean result;
rlm@0 145
rlm@0 146 Context = GetLockedContext();
rlm@0 147 if(!Context) return AL_FALSE;
rlm@0 148
rlm@0 149 result = ((!effect || LookupEffect(Context->Device->EffectMap, effect)) ?
rlm@0 150 AL_TRUE : AL_FALSE);
rlm@0 151
rlm@0 152 UnlockContext(Context);
rlm@0 153
rlm@0 154 return result;
rlm@0 155 }
rlm@0 156
rlm@0 157 AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
rlm@0 158 {
rlm@0 159 ALCcontext *Context;
rlm@0 160 ALCdevice *Device;
rlm@0 161 ALeffect *ALEffect;
rlm@0 162
rlm@0 163 Context = GetLockedContext();
rlm@0 164 if(!Context) return;
rlm@0 165
rlm@0 166 Device = Context->Device;
rlm@0 167 if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
rlm@0 168 {
rlm@0 169 if(param == AL_EFFECT_TYPE)
rlm@0 170 {
rlm@0 171 ALboolean isOk = (iValue == AL_EFFECT_NULL);
rlm@0 172 ALint i;
rlm@0 173 for(i = 0;!isOk && EffectList[i].val;i++)
rlm@0 174 {
rlm@0 175 if(iValue == EffectList[i].val &&
rlm@0 176 !DisabledEffects[EffectList[i].type])
rlm@0 177 isOk = AL_TRUE;
rlm@0 178 }
rlm@0 179
rlm@0 180 if(isOk)
rlm@0 181 InitEffectParams(ALEffect, iValue);
rlm@0 182 else
rlm@0 183 alSetError(Context, AL_INVALID_VALUE);
rlm@0 184 }
rlm@0 185 else if(ALEffect->type == AL_EFFECT_EAXREVERB)
rlm@0 186 {
rlm@0 187 switch(param)
rlm@0 188 {
rlm@0 189 case AL_EAXREVERB_DECAY_HFLIMIT:
rlm@0 190 if(iValue >= AL_EAXREVERB_MIN_DECAY_HFLIMIT &&
rlm@0 191 iValue <= AL_EAXREVERB_MAX_DECAY_HFLIMIT)
rlm@0 192 ALEffect->Params.Reverb.DecayHFLimit = iValue;
rlm@0 193 else
rlm@0 194 alSetError(Context, AL_INVALID_VALUE);
rlm@0 195 break;
rlm@0 196
rlm@0 197 default:
rlm@0 198 alSetError(Context, AL_INVALID_ENUM);
rlm@0 199 break;
rlm@0 200 }
rlm@0 201 }
rlm@0 202 else if(ALEffect->type == AL_EFFECT_REVERB)
rlm@0 203 {
rlm@0 204 switch(param)
rlm@0 205 {
rlm@0 206 case AL_REVERB_DECAY_HFLIMIT:
rlm@0 207 if(iValue >= AL_REVERB_MIN_DECAY_HFLIMIT &&
rlm@0 208 iValue <= AL_REVERB_MAX_DECAY_HFLIMIT)
rlm@0 209 ALEffect->Params.Reverb.DecayHFLimit = iValue;
rlm@0 210 else
rlm@0 211 alSetError(Context, AL_INVALID_VALUE);
rlm@0 212 break;
rlm@0 213
rlm@0 214 default:
rlm@0 215 alSetError(Context, AL_INVALID_ENUM);
rlm@0 216 break;
rlm@0 217 }
rlm@0 218 }
rlm@0 219 else if(ALEffect->type == AL_EFFECT_ECHO)
rlm@0 220 {
rlm@0 221 switch(param)
rlm@0 222 {
rlm@0 223 default:
rlm@0 224 alSetError(Context, AL_INVALID_ENUM);
rlm@0 225 break;
rlm@0 226 }
rlm@0 227 }
rlm@0 228 else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
rlm@0 229 {
rlm@0 230 switch(param)
rlm@0 231 {
rlm@0 232 case AL_RING_MODULATOR_FREQUENCY:
rlm@0 233 if(iValue >= AL_RING_MODULATOR_MIN_FREQUENCY &&
rlm@0 234 iValue <= AL_RING_MODULATOR_MAX_FREQUENCY)
rlm@0 235 ALEffect->Params.Modulator.Frequency = iValue;
rlm@0 236 else
rlm@0 237 alSetError(Context, AL_INVALID_VALUE);
rlm@0 238 break;
rlm@0 239
rlm@0 240 case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
rlm@0 241 if(iValue >= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF &&
rlm@0 242 iValue <= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF)
rlm@0 243 ALEffect->Params.Modulator.HighPassCutoff = iValue;
rlm@0 244 else
rlm@0 245 alSetError(Context, AL_INVALID_VALUE);
rlm@0 246 break;
rlm@0 247
rlm@0 248 case AL_RING_MODULATOR_WAVEFORM:
rlm@0 249 if(iValue >= AL_RING_MODULATOR_MIN_WAVEFORM &&
rlm@0 250 iValue <= AL_RING_MODULATOR_MAX_WAVEFORM)
rlm@0 251 ALEffect->Params.Modulator.Waveform = iValue;
rlm@0 252 else
rlm@0 253 alSetError(Context, AL_INVALID_VALUE);
rlm@0 254 break;
rlm@0 255
rlm@0 256 default:
rlm@0 257 alSetError(Context, AL_INVALID_ENUM);
rlm@0 258 break;
rlm@0 259 }
rlm@0 260 }
rlm@0 261 else
rlm@0 262 alSetError(Context, AL_INVALID_ENUM);
rlm@0 263 }
rlm@0 264 else
rlm@0 265 alSetError(Context, AL_INVALID_NAME);
rlm@0 266
rlm@0 267 UnlockContext(Context);
rlm@0 268 }
rlm@0 269
rlm@0 270 AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues)
rlm@0 271 {
rlm@0 272 /* There are no multi-value int effect parameters */
rlm@0 273 alEffecti(effect, param, piValues[0]);
rlm@0 274 }
rlm@0 275
rlm@0 276 AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue)
rlm@0 277 {
rlm@0 278 ALCcontext *Context;
rlm@0 279 ALCdevice *Device;
rlm@0 280 ALeffect *ALEffect;
rlm@0 281
rlm@0 282 Context = GetLockedContext();
rlm@0 283 if(!Context) return;
rlm@0 284
rlm@0 285 Device = Context->Device;
rlm@0 286 if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
rlm@0 287 {
rlm@0 288 if(ALEffect->type == AL_EFFECT_EAXREVERB)
rlm@0 289 {
rlm@0 290 switch(param)
rlm@0 291 {
rlm@0 292 case AL_EAXREVERB_DENSITY:
rlm@0 293 if(flValue >= AL_EAXREVERB_MIN_DENSITY &&
rlm@0 294 flValue <= AL_EAXREVERB_MAX_DENSITY)
rlm@0 295 ALEffect->Params.Reverb.Density = flValue;
rlm@0 296 else
rlm@0 297 alSetError(Context, AL_INVALID_VALUE);
rlm@0 298 break;
rlm@0 299
rlm@0 300 case AL_EAXREVERB_DIFFUSION:
rlm@0 301 if(flValue >= AL_EAXREVERB_MIN_DIFFUSION &&
rlm@0 302 flValue <= AL_EAXREVERB_MAX_DIFFUSION)
rlm@0 303 ALEffect->Params.Reverb.Diffusion = flValue;
rlm@0 304 else
rlm@0 305 alSetError(Context, AL_INVALID_VALUE);
rlm@0 306 break;
rlm@0 307
rlm@0 308 case AL_EAXREVERB_GAIN:
rlm@0 309 if(flValue >= AL_EAXREVERB_MIN_GAIN &&
rlm@0 310 flValue <= AL_EAXREVERB_MAX_GAIN)
rlm@0 311 ALEffect->Params.Reverb.Gain = flValue;
rlm@0 312 else
rlm@0 313 alSetError(Context, AL_INVALID_VALUE);
rlm@0 314 break;
rlm@0 315
rlm@0 316 case AL_EAXREVERB_GAINHF:
rlm@0 317 if(flValue >= AL_EAXREVERB_MIN_GAINHF &&
rlm@0 318 flValue <= AL_EAXREVERB_MAX_GAINHF)
rlm@0 319 ALEffect->Params.Reverb.GainHF = flValue;
rlm@0 320 else
rlm@0 321 alSetError(Context, AL_INVALID_VALUE);
rlm@0 322 break;
rlm@0 323
rlm@0 324 case AL_EAXREVERB_GAINLF:
rlm@0 325 if(flValue >= AL_EAXREVERB_MIN_GAINLF &&
rlm@0 326 flValue <= AL_EAXREVERB_MAX_GAINLF)
rlm@0 327 ALEffect->Params.Reverb.GainLF = flValue;
rlm@0 328 else
rlm@0 329 alSetError(Context, AL_INVALID_VALUE);
rlm@0 330 break;
rlm@0 331
rlm@0 332 case AL_EAXREVERB_DECAY_TIME:
rlm@0 333 if(flValue >= AL_EAXREVERB_MIN_DECAY_TIME &&
rlm@0 334 flValue <= AL_EAXREVERB_MAX_DECAY_TIME)
rlm@0 335 ALEffect->Params.Reverb.DecayTime = flValue;
rlm@0 336 else
rlm@0 337 alSetError(Context, AL_INVALID_VALUE);
rlm@0 338 break;
rlm@0 339
rlm@0 340 case AL_EAXREVERB_DECAY_HFRATIO:
rlm@0 341 if(flValue >= AL_EAXREVERB_MIN_DECAY_HFRATIO &&
rlm@0 342 flValue <= AL_EAXREVERB_MAX_DECAY_HFRATIO)
rlm@0 343 ALEffect->Params.Reverb.DecayHFRatio = flValue;
rlm@0 344 else
rlm@0 345 alSetError(Context, AL_INVALID_VALUE);
rlm@0 346 break;
rlm@0 347
rlm@0 348 case AL_EAXREVERB_DECAY_LFRATIO:
rlm@0 349 if(flValue >= AL_EAXREVERB_MIN_DECAY_LFRATIO &&
rlm@0 350 flValue <= AL_EAXREVERB_MAX_DECAY_LFRATIO)
rlm@0 351 ALEffect->Params.Reverb.DecayLFRatio = flValue;
rlm@0 352 else
rlm@0 353 alSetError(Context, AL_INVALID_VALUE);
rlm@0 354 break;
rlm@0 355
rlm@0 356 case AL_EAXREVERB_REFLECTIONS_GAIN:
rlm@0 357 if(flValue >= AL_EAXREVERB_MIN_REFLECTIONS_GAIN &&
rlm@0 358 flValue <= AL_EAXREVERB_MAX_REFLECTIONS_GAIN)
rlm@0 359 ALEffect->Params.Reverb.ReflectionsGain = flValue;
rlm@0 360 else
rlm@0 361 alSetError(Context, AL_INVALID_VALUE);
rlm@0 362 break;
rlm@0 363
rlm@0 364 case AL_EAXREVERB_REFLECTIONS_DELAY:
rlm@0 365 if(flValue >= AL_EAXREVERB_MIN_REFLECTIONS_DELAY &&
rlm@0 366 flValue <= AL_EAXREVERB_MAX_REFLECTIONS_DELAY)
rlm@0 367 ALEffect->Params.Reverb.ReflectionsDelay = flValue;
rlm@0 368 else
rlm@0 369 alSetError(Context, AL_INVALID_VALUE);
rlm@0 370 break;
rlm@0 371
rlm@0 372 case AL_EAXREVERB_LATE_REVERB_GAIN:
rlm@0 373 if(flValue >= AL_EAXREVERB_MIN_LATE_REVERB_GAIN &&
rlm@0 374 flValue <= AL_EAXREVERB_MAX_LATE_REVERB_GAIN)
rlm@0 375 ALEffect->Params.Reverb.LateReverbGain = flValue;
rlm@0 376 else
rlm@0 377 alSetError(Context, AL_INVALID_VALUE);
rlm@0 378 break;
rlm@0 379
rlm@0 380 case AL_EAXREVERB_LATE_REVERB_DELAY:
rlm@0 381 if(flValue >= AL_EAXREVERB_MIN_LATE_REVERB_DELAY &&
rlm@0 382 flValue <= AL_EAXREVERB_MAX_LATE_REVERB_DELAY)
rlm@0 383 ALEffect->Params.Reverb.LateReverbDelay = flValue;
rlm@0 384 else
rlm@0 385 alSetError(Context, AL_INVALID_VALUE);
rlm@0 386 break;
rlm@0 387
rlm@0 388 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF:
rlm@0 389 if(flValue >= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF &&
rlm@0 390 flValue <= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF)
rlm@0 391 ALEffect->Params.Reverb.AirAbsorptionGainHF = flValue;
rlm@0 392 else
rlm@0 393 alSetError(Context, AL_INVALID_VALUE);
rlm@0 394 break;
rlm@0 395
rlm@0 396 case AL_EAXREVERB_ECHO_TIME:
rlm@0 397 if(flValue >= AL_EAXREVERB_MIN_ECHO_TIME &&
rlm@0 398 flValue <= AL_EAXREVERB_MAX_ECHO_TIME)
rlm@0 399 ALEffect->Params.Reverb.EchoTime = flValue;
rlm@0 400 else
rlm@0 401 alSetError(Context, AL_INVALID_VALUE);
rlm@0 402 break;
rlm@0 403
rlm@0 404 case AL_EAXREVERB_ECHO_DEPTH:
rlm@0 405 if(flValue >= AL_EAXREVERB_MIN_ECHO_DEPTH &&
rlm@0 406 flValue <= AL_EAXREVERB_MAX_ECHO_DEPTH)
rlm@0 407 ALEffect->Params.Reverb.EchoDepth = flValue;
rlm@0 408 else
rlm@0 409 alSetError(Context, AL_INVALID_VALUE);
rlm@0 410 break;
rlm@0 411
rlm@0 412 case AL_EAXREVERB_MODULATION_TIME:
rlm@0 413 if(flValue >= AL_EAXREVERB_MIN_MODULATION_TIME &&
rlm@0 414 flValue <= AL_EAXREVERB_MAX_MODULATION_TIME)
rlm@0 415 ALEffect->Params.Reverb.ModulationTime = flValue;
rlm@0 416 else
rlm@0 417 alSetError(Context, AL_INVALID_VALUE);
rlm@0 418 break;
rlm@0 419
rlm@0 420 case AL_EAXREVERB_MODULATION_DEPTH:
rlm@0 421 if(flValue >= AL_EAXREVERB_MIN_MODULATION_DEPTH &&
rlm@0 422 flValue <= AL_EAXREVERB_MAX_MODULATION_DEPTH)
rlm@0 423 ALEffect->Params.Reverb.ModulationDepth = flValue;
rlm@0 424 else
rlm@0 425 alSetError(Context, AL_INVALID_VALUE);
rlm@0 426 break;
rlm@0 427
rlm@0 428 case AL_EAXREVERB_HFREFERENCE:
rlm@0 429 if(flValue >= AL_EAXREVERB_MIN_HFREFERENCE &&
rlm@0 430 flValue <= AL_EAXREVERB_MAX_HFREFERENCE)
rlm@0 431 ALEffect->Params.Reverb.HFReference = flValue;
rlm@0 432 else
rlm@0 433 alSetError(Context, AL_INVALID_VALUE);
rlm@0 434 break;
rlm@0 435
rlm@0 436 case AL_EAXREVERB_LFREFERENCE:
rlm@0 437 if(flValue >= AL_EAXREVERB_MIN_LFREFERENCE &&
rlm@0 438 flValue <= AL_EAXREVERB_MAX_LFREFERENCE)
rlm@0 439 ALEffect->Params.Reverb.LFReference = flValue;
rlm@0 440 else
rlm@0 441 alSetError(Context, AL_INVALID_VALUE);
rlm@0 442 break;
rlm@0 443
rlm@0 444 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR:
rlm@0 445 if(flValue >= 0.0f && flValue <= 10.0f)
rlm@0 446 ALEffect->Params.Reverb.RoomRolloffFactor = flValue;
rlm@0 447 else
rlm@0 448 alSetError(Context, AL_INVALID_VALUE);
rlm@0 449 break;
rlm@0 450
rlm@0 451 default:
rlm@0 452 alSetError(Context, AL_INVALID_ENUM);
rlm@0 453 break;
rlm@0 454 }
rlm@0 455 }
rlm@0 456 else if(ALEffect->type == AL_EFFECT_REVERB)
rlm@0 457 {
rlm@0 458 switch(param)
rlm@0 459 {
rlm@0 460 case AL_REVERB_DENSITY:
rlm@0 461 if(flValue >= AL_REVERB_MIN_DENSITY &&
rlm@0 462 flValue <= AL_REVERB_MAX_DENSITY)
rlm@0 463 ALEffect->Params.Reverb.Density = flValue;
rlm@0 464 else
rlm@0 465 alSetError(Context, AL_INVALID_VALUE);
rlm@0 466 break;
rlm@0 467
rlm@0 468 case AL_REVERB_DIFFUSION:
rlm@0 469 if(flValue >= AL_REVERB_MIN_DIFFUSION &&
rlm@0 470 flValue <= AL_REVERB_MAX_DIFFUSION)
rlm@0 471 ALEffect->Params.Reverb.Diffusion = flValue;
rlm@0 472 else
rlm@0 473 alSetError(Context, AL_INVALID_VALUE);
rlm@0 474 break;
rlm@0 475
rlm@0 476 case AL_REVERB_GAIN:
rlm@0 477 if(flValue >= AL_REVERB_MIN_GAIN &&
rlm@0 478 flValue <= AL_REVERB_MAX_GAIN)
rlm@0 479 ALEffect->Params.Reverb.Gain = flValue;
rlm@0 480 else
rlm@0 481 alSetError(Context, AL_INVALID_VALUE);
rlm@0 482 break;
rlm@0 483
rlm@0 484 case AL_REVERB_GAINHF:
rlm@0 485 if(flValue >= AL_REVERB_MIN_GAINHF &&
rlm@0 486 flValue <= AL_REVERB_MAX_GAINHF)
rlm@0 487 ALEffect->Params.Reverb.GainHF = flValue;
rlm@0 488 else
rlm@0 489 alSetError(Context, AL_INVALID_VALUE);
rlm@0 490 break;
rlm@0 491
rlm@0 492 case AL_REVERB_DECAY_TIME:
rlm@0 493 if(flValue >= AL_REVERB_MIN_DECAY_TIME &&
rlm@0 494 flValue <= AL_REVERB_MAX_DECAY_TIME)
rlm@0 495 ALEffect->Params.Reverb.DecayTime = flValue;
rlm@0 496 else
rlm@0 497 alSetError(Context, AL_INVALID_VALUE);
rlm@0 498 break;
rlm@0 499
rlm@0 500 case AL_REVERB_DECAY_HFRATIO:
rlm@0 501 if(flValue >= AL_REVERB_MIN_DECAY_HFRATIO &&
rlm@0 502 flValue <= AL_REVERB_MAX_DECAY_HFRATIO)
rlm@0 503 ALEffect->Params.Reverb.DecayHFRatio = flValue;
rlm@0 504 else
rlm@0 505 alSetError(Context, AL_INVALID_VALUE);
rlm@0 506 break;
rlm@0 507
rlm@0 508 case AL_REVERB_REFLECTIONS_GAIN:
rlm@0 509 if(flValue >= AL_REVERB_MIN_REFLECTIONS_GAIN &&
rlm@0 510 flValue <= AL_REVERB_MAX_REFLECTIONS_GAIN)
rlm@0 511 ALEffect->Params.Reverb.ReflectionsGain = flValue;
rlm@0 512 else
rlm@0 513 alSetError(Context, AL_INVALID_VALUE);
rlm@0 514 break;
rlm@0 515
rlm@0 516 case AL_REVERB_REFLECTIONS_DELAY:
rlm@0 517 if(flValue >= AL_REVERB_MIN_REFLECTIONS_DELAY &&
rlm@0 518 flValue <= AL_REVERB_MAX_REFLECTIONS_DELAY)
rlm@0 519 ALEffect->Params.Reverb.ReflectionsDelay = flValue;
rlm@0 520 else
rlm@0 521 alSetError(Context, AL_INVALID_VALUE);
rlm@0 522 break;
rlm@0 523
rlm@0 524 case AL_REVERB_LATE_REVERB_GAIN:
rlm@0 525 if(flValue >= AL_REVERB_MIN_LATE_REVERB_GAIN &&
rlm@0 526 flValue <= AL_REVERB_MAX_LATE_REVERB_GAIN)
rlm@0 527 ALEffect->Params.Reverb.LateReverbGain = flValue;
rlm@0 528 else
rlm@0 529 alSetError(Context, AL_INVALID_VALUE);
rlm@0 530 break;
rlm@0 531
rlm@0 532 case AL_REVERB_LATE_REVERB_DELAY:
rlm@0 533 if(flValue >= AL_REVERB_MIN_LATE_REVERB_DELAY &&
rlm@0 534 flValue <= AL_REVERB_MAX_LATE_REVERB_DELAY)
rlm@0 535 ALEffect->Params.Reverb.LateReverbDelay = flValue;
rlm@0 536 else
rlm@0 537 alSetError(Context, AL_INVALID_VALUE);
rlm@0 538 break;
rlm@0 539
rlm@0 540 case AL_REVERB_AIR_ABSORPTION_GAINHF:
rlm@0 541 if(flValue >= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF &&
rlm@0 542 flValue <= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF)
rlm@0 543 ALEffect->Params.Reverb.AirAbsorptionGainHF = flValue;
rlm@0 544 else
rlm@0 545 alSetError(Context, AL_INVALID_VALUE);
rlm@0 546 break;
rlm@0 547
rlm@0 548 case AL_REVERB_ROOM_ROLLOFF_FACTOR:
rlm@0 549 if(flValue >= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR &&
rlm@0 550 flValue <= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR)
rlm@0 551 ALEffect->Params.Reverb.RoomRolloffFactor = flValue;
rlm@0 552 else
rlm@0 553 alSetError(Context, AL_INVALID_VALUE);
rlm@0 554 break;
rlm@0 555
rlm@0 556 default:
rlm@0 557 alSetError(Context, AL_INVALID_ENUM);
rlm@0 558 break;
rlm@0 559 }
rlm@0 560 }
rlm@0 561 else if(ALEffect->type == AL_EFFECT_ECHO)
rlm@0 562 {
rlm@0 563 switch(param)
rlm@0 564 {
rlm@0 565 case AL_ECHO_DELAY:
rlm@0 566 if(flValue >= AL_ECHO_MIN_DELAY && flValue <= AL_ECHO_MAX_DELAY)
rlm@0 567 ALEffect->Params.Echo.Delay = flValue;
rlm@0 568 else
rlm@0 569 alSetError(Context, AL_INVALID_VALUE);
rlm@0 570 break;
rlm@0 571
rlm@0 572 case AL_ECHO_LRDELAY:
rlm@0 573 if(flValue >= AL_ECHO_MIN_LRDELAY && flValue <= AL_ECHO_MAX_LRDELAY)
rlm@0 574 ALEffect->Params.Echo.LRDelay = flValue;
rlm@0 575 else
rlm@0 576 alSetError(Context, AL_INVALID_VALUE);
rlm@0 577 break;
rlm@0 578
rlm@0 579 case AL_ECHO_DAMPING:
rlm@0 580 if(flValue >= AL_ECHO_MIN_DAMPING && flValue <= AL_ECHO_MAX_DAMPING)
rlm@0 581 ALEffect->Params.Echo.Damping = flValue;
rlm@0 582 else
rlm@0 583 alSetError(Context, AL_INVALID_VALUE);
rlm@0 584 break;
rlm@0 585
rlm@0 586 case AL_ECHO_FEEDBACK:
rlm@0 587 if(flValue >= AL_ECHO_MIN_FEEDBACK && flValue <= AL_ECHO_MAX_FEEDBACK)
rlm@0 588 ALEffect->Params.Echo.Feedback = flValue;
rlm@0 589 else
rlm@0 590 alSetError(Context, AL_INVALID_VALUE);
rlm@0 591 break;
rlm@0 592
rlm@0 593 case AL_ECHO_SPREAD:
rlm@0 594 if(flValue >= AL_ECHO_MIN_SPREAD && flValue <= AL_ECHO_MAX_SPREAD)
rlm@0 595 ALEffect->Params.Echo.Spread = flValue;
rlm@0 596 else
rlm@0 597 alSetError(Context, AL_INVALID_VALUE);
rlm@0 598 break;
rlm@0 599
rlm@0 600 default:
rlm@0 601 alSetError(Context, AL_INVALID_ENUM);
rlm@0 602 break;
rlm@0 603 }
rlm@0 604 }
rlm@0 605 else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
rlm@0 606 {
rlm@0 607 switch(param)
rlm@0 608 {
rlm@0 609 case AL_RING_MODULATOR_FREQUENCY:
rlm@0 610 if(flValue >= AL_RING_MODULATOR_MIN_FREQUENCY &&
rlm@0 611 flValue <= AL_RING_MODULATOR_MAX_FREQUENCY)
rlm@0 612 ALEffect->Params.Modulator.Frequency = flValue;
rlm@0 613 else
rlm@0 614 alSetError(Context, AL_INVALID_VALUE);
rlm@0 615 break;
rlm@0 616
rlm@0 617 case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
rlm@0 618 if(flValue >= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF &&
rlm@0 619 flValue <= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF)
rlm@0 620 ALEffect->Params.Modulator.HighPassCutoff = flValue;
rlm@0 621 else
rlm@0 622 alSetError(Context, AL_INVALID_VALUE);
rlm@0 623 break;
rlm@0 624
rlm@0 625 default:
rlm@0 626 alSetError(Context, AL_INVALID_ENUM);
rlm@0 627 break;
rlm@0 628 }
rlm@0 629 }
rlm@0 630 else if(ALEffect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
rlm@0 631 ALEffect->type == AL_EFFECT_DEDICATED_DIALOGUE)
rlm@0 632 {
rlm@0 633 switch(param)
rlm@0 634 {
rlm@0 635 case AL_DEDICATED_GAIN:
rlm@0 636 if(flValue >= 0.0f && isfinite(flValue))
rlm@0 637 ALEffect->Params.Dedicated.Gain = flValue;
rlm@0 638 else
rlm@0 639 alSetError(Context, AL_INVALID_VALUE);
rlm@0 640 break;
rlm@0 641
rlm@0 642 default:
rlm@0 643 alSetError(Context, AL_INVALID_ENUM);
rlm@0 644 break;
rlm@0 645 }
rlm@0 646 }
rlm@0 647 else
rlm@0 648 alSetError(Context, AL_INVALID_ENUM);
rlm@0 649 }
rlm@0 650 else
rlm@0 651 alSetError(Context, AL_INVALID_NAME);
rlm@0 652
rlm@0 653 UnlockContext(Context);
rlm@0 654 }
rlm@0 655
rlm@0 656 AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflValues)
rlm@0 657 {
rlm@0 658 ALCcontext *Context;
rlm@0 659 ALCdevice *Device;
rlm@0 660 ALeffect *ALEffect;
rlm@0 661
rlm@0 662 Context = GetLockedContext();
rlm@0 663 if(!Context) return;
rlm@0 664
rlm@0 665 Device = Context->Device;
rlm@0 666 if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
rlm@0 667 {
rlm@0 668 if(ALEffect->type == AL_EFFECT_EAXREVERB)
rlm@0 669 {
rlm@0 670 switch(param)
rlm@0 671 {
rlm@0 672 case AL_EAXREVERB_REFLECTIONS_PAN:
rlm@0 673 if(isfinite(pflValues[0]) && isfinite(pflValues[1]) && isfinite(pflValues[2]))
rlm@0 674 {
rlm@0 675 ALEffect->Params.Reverb.ReflectionsPan[0] = pflValues[0];
rlm@0 676 ALEffect->Params.Reverb.ReflectionsPan[1] = pflValues[1];
rlm@0 677 ALEffect->Params.Reverb.ReflectionsPan[2] = pflValues[2];
rlm@0 678 }
rlm@0 679 else
rlm@0 680 alSetError(Context, AL_INVALID_VALUE);
rlm@0 681 break;
rlm@0 682 case AL_EAXREVERB_LATE_REVERB_PAN:
rlm@0 683 if(isfinite(pflValues[0]) && isfinite(pflValues[1]) && isfinite(pflValues[2]))
rlm@0 684 {
rlm@0 685 ALEffect->Params.Reverb.LateReverbPan[0] = pflValues[0];
rlm@0 686 ALEffect->Params.Reverb.LateReverbPan[1] = pflValues[1];
rlm@0 687 ALEffect->Params.Reverb.LateReverbPan[2] = pflValues[2];
rlm@0 688 }
rlm@0 689 else
rlm@0 690 alSetError(Context, AL_INVALID_VALUE);
rlm@0 691 break;
rlm@0 692
rlm@0 693 default:
rlm@0 694 UnlockContext(Context);
rlm@0 695 alEffectf(effect, param, pflValues[0]);
rlm@0 696 return;
rlm@0 697 }
rlm@0 698 }
rlm@0 699 else
rlm@0 700 {
rlm@0 701 UnlockContext(Context);
rlm@0 702 alEffectf(effect, param, pflValues[0]);
rlm@0 703 return;
rlm@0 704 }
rlm@0 705 }
rlm@0 706 else
rlm@0 707 alSetError(Context, AL_INVALID_NAME);
rlm@0 708
rlm@0 709 UnlockContext(Context);
rlm@0 710 }
rlm@0 711
rlm@0 712 AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue)
rlm@0 713 {
rlm@0 714 ALCcontext *Context;
rlm@0 715 ALCdevice *Device;
rlm@0 716 ALeffect *ALEffect;
rlm@0 717
rlm@0 718 Context = GetLockedContext();
rlm@0 719 if(!Context) return;
rlm@0 720
rlm@0 721 Device = Context->Device;
rlm@0 722 if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
rlm@0 723 {
rlm@0 724 if(param == AL_EFFECT_TYPE)
rlm@0 725 {
rlm@0 726 *piValue = ALEffect->type;
rlm@0 727 }
rlm@0 728 else if(ALEffect->type == AL_EFFECT_EAXREVERB)
rlm@0 729 {
rlm@0 730 switch(param)
rlm@0 731 {
rlm@0 732 case AL_EAXREVERB_DECAY_HFLIMIT:
rlm@0 733 *piValue = ALEffect->Params.Reverb.DecayHFLimit;
rlm@0 734 break;
rlm@0 735
rlm@0 736 default:
rlm@0 737 alSetError(Context, AL_INVALID_ENUM);
rlm@0 738 break;
rlm@0 739 }
rlm@0 740 }
rlm@0 741 else if(ALEffect->type == AL_EFFECT_REVERB)
rlm@0 742 {
rlm@0 743 switch(param)
rlm@0 744 {
rlm@0 745 case AL_REVERB_DECAY_HFLIMIT:
rlm@0 746 *piValue = ALEffect->Params.Reverb.DecayHFLimit;
rlm@0 747 break;
rlm@0 748
rlm@0 749 default:
rlm@0 750 alSetError(Context, AL_INVALID_ENUM);
rlm@0 751 break;
rlm@0 752 }
rlm@0 753 }
rlm@0 754 else if(ALEffect->type == AL_EFFECT_ECHO)
rlm@0 755 {
rlm@0 756 switch(param)
rlm@0 757 {
rlm@0 758 default:
rlm@0 759 alSetError(Context, AL_INVALID_ENUM);
rlm@0 760 break;
rlm@0 761 }
rlm@0 762 }
rlm@0 763 else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
rlm@0 764 {
rlm@0 765 switch(param)
rlm@0 766 {
rlm@0 767 case AL_RING_MODULATOR_FREQUENCY:
rlm@0 768 *piValue = (ALint)ALEffect->Params.Modulator.Frequency;
rlm@0 769 break;
rlm@0 770 case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
rlm@0 771 *piValue = (ALint)ALEffect->Params.Modulator.HighPassCutoff;
rlm@0 772 break;
rlm@0 773 case AL_RING_MODULATOR_WAVEFORM:
rlm@0 774 *piValue = ALEffect->Params.Modulator.Waveform;
rlm@0 775 break;
rlm@0 776
rlm@0 777 default:
rlm@0 778 alSetError(Context, AL_INVALID_ENUM);
rlm@0 779 break;
rlm@0 780 }
rlm@0 781 }
rlm@0 782 else
rlm@0 783 alSetError(Context, AL_INVALID_ENUM);
rlm@0 784 }
rlm@0 785 else
rlm@0 786 alSetError(Context, AL_INVALID_NAME);
rlm@0 787
rlm@0 788 UnlockContext(Context);
rlm@0 789 }
rlm@0 790
rlm@0 791 AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues)
rlm@0 792 {
rlm@0 793 /* There are no multi-value int effect parameters */
rlm@0 794 alGetEffecti(effect, param, piValues);
rlm@0 795 }
rlm@0 796
rlm@0 797 AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue)
rlm@0 798 {
rlm@0 799 ALCcontext *Context;
rlm@0 800 ALCdevice *Device;
rlm@0 801 ALeffect *ALEffect;
rlm@0 802
rlm@0 803 Context = GetLockedContext();
rlm@0 804 if(!Context) return;
rlm@0 805
rlm@0 806 Device = Context->Device;
rlm@0 807 if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
rlm@0 808 {
rlm@0 809 if(ALEffect->type == AL_EFFECT_EAXREVERB)
rlm@0 810 {
rlm@0 811 switch(param)
rlm@0 812 {
rlm@0 813 case AL_EAXREVERB_DENSITY:
rlm@0 814 *pflValue = ALEffect->Params.Reverb.Density;
rlm@0 815 break;
rlm@0 816
rlm@0 817 case AL_EAXREVERB_DIFFUSION:
rlm@0 818 *pflValue = ALEffect->Params.Reverb.Diffusion;
rlm@0 819 break;
rlm@0 820
rlm@0 821 case AL_EAXREVERB_GAIN:
rlm@0 822 *pflValue = ALEffect->Params.Reverb.Gain;
rlm@0 823 break;
rlm@0 824
rlm@0 825 case AL_EAXREVERB_GAINHF:
rlm@0 826 *pflValue = ALEffect->Params.Reverb.GainHF;
rlm@0 827 break;
rlm@0 828
rlm@0 829 case AL_EAXREVERB_GAINLF:
rlm@0 830 *pflValue = ALEffect->Params.Reverb.GainLF;
rlm@0 831 break;
rlm@0 832
rlm@0 833 case AL_EAXREVERB_DECAY_TIME:
rlm@0 834 *pflValue = ALEffect->Params.Reverb.DecayTime;
rlm@0 835 break;
rlm@0 836
rlm@0 837 case AL_EAXREVERB_DECAY_HFRATIO:
rlm@0 838 *pflValue = ALEffect->Params.Reverb.DecayHFRatio;
rlm@0 839 break;
rlm@0 840
rlm@0 841 case AL_EAXREVERB_DECAY_LFRATIO:
rlm@0 842 *pflValue = ALEffect->Params.Reverb.DecayLFRatio;
rlm@0 843 break;
rlm@0 844
rlm@0 845 case AL_EAXREVERB_REFLECTIONS_GAIN:
rlm@0 846 *pflValue = ALEffect->Params.Reverb.ReflectionsGain;
rlm@0 847 break;
rlm@0 848
rlm@0 849 case AL_EAXREVERB_REFLECTIONS_DELAY:
rlm@0 850 *pflValue = ALEffect->Params.Reverb.ReflectionsDelay;
rlm@0 851 break;
rlm@0 852
rlm@0 853 case AL_EAXREVERB_LATE_REVERB_GAIN:
rlm@0 854 *pflValue = ALEffect->Params.Reverb.LateReverbGain;
rlm@0 855 break;
rlm@0 856
rlm@0 857 case AL_EAXREVERB_LATE_REVERB_DELAY:
rlm@0 858 *pflValue = ALEffect->Params.Reverb.LateReverbDelay;
rlm@0 859 break;
rlm@0 860
rlm@0 861 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF:
rlm@0 862 *pflValue = ALEffect->Params.Reverb.AirAbsorptionGainHF;
rlm@0 863 break;
rlm@0 864
rlm@0 865 case AL_EAXREVERB_ECHO_TIME:
rlm@0 866 *pflValue = ALEffect->Params.Reverb.EchoTime;
rlm@0 867 break;
rlm@0 868
rlm@0 869 case AL_EAXREVERB_ECHO_DEPTH:
rlm@0 870 *pflValue = ALEffect->Params.Reverb.EchoDepth;
rlm@0 871 break;
rlm@0 872
rlm@0 873 case AL_EAXREVERB_MODULATION_TIME:
rlm@0 874 *pflValue = ALEffect->Params.Reverb.ModulationTime;
rlm@0 875 break;
rlm@0 876
rlm@0 877 case AL_EAXREVERB_MODULATION_DEPTH:
rlm@0 878 *pflValue = ALEffect->Params.Reverb.ModulationDepth;
rlm@0 879 break;
rlm@0 880
rlm@0 881 case AL_EAXREVERB_HFREFERENCE:
rlm@0 882 *pflValue = ALEffect->Params.Reverb.HFReference;
rlm@0 883 break;
rlm@0 884
rlm@0 885 case AL_EAXREVERB_LFREFERENCE:
rlm@0 886 *pflValue = ALEffect->Params.Reverb.LFReference;
rlm@0 887 break;
rlm@0 888
rlm@0 889 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR:
rlm@0 890 *pflValue = ALEffect->Params.Reverb.RoomRolloffFactor;
rlm@0 891 break;
rlm@0 892
rlm@0 893 default:
rlm@0 894 alSetError(Context, AL_INVALID_ENUM);
rlm@0 895 break;
rlm@0 896 }
rlm@0 897 }
rlm@0 898 else if(ALEffect->type == AL_EFFECT_REVERB)
rlm@0 899 {
rlm@0 900 switch(param)
rlm@0 901 {
rlm@0 902 case AL_REVERB_DENSITY:
rlm@0 903 *pflValue = ALEffect->Params.Reverb.Density;
rlm@0 904 break;
rlm@0 905
rlm@0 906 case AL_REVERB_DIFFUSION:
rlm@0 907 *pflValue = ALEffect->Params.Reverb.Diffusion;
rlm@0 908 break;
rlm@0 909
rlm@0 910 case AL_REVERB_GAIN:
rlm@0 911 *pflValue = ALEffect->Params.Reverb.Gain;
rlm@0 912 break;
rlm@0 913
rlm@0 914 case AL_REVERB_GAINHF:
rlm@0 915 *pflValue = ALEffect->Params.Reverb.GainHF;
rlm@0 916 break;
rlm@0 917
rlm@0 918 case AL_REVERB_DECAY_TIME:
rlm@0 919 *pflValue = ALEffect->Params.Reverb.DecayTime;
rlm@0 920 break;
rlm@0 921
rlm@0 922 case AL_REVERB_DECAY_HFRATIO:
rlm@0 923 *pflValue = ALEffect->Params.Reverb.DecayHFRatio;
rlm@0 924 break;
rlm@0 925
rlm@0 926 case AL_REVERB_REFLECTIONS_GAIN:
rlm@0 927 *pflValue = ALEffect->Params.Reverb.ReflectionsGain;
rlm@0 928 break;
rlm@0 929
rlm@0 930 case AL_REVERB_REFLECTIONS_DELAY:
rlm@0 931 *pflValue = ALEffect->Params.Reverb.ReflectionsDelay;
rlm@0 932 break;
rlm@0 933
rlm@0 934 case AL_REVERB_LATE_REVERB_GAIN:
rlm@0 935 *pflValue = ALEffect->Params.Reverb.LateReverbGain;
rlm@0 936 break;
rlm@0 937
rlm@0 938 case AL_REVERB_LATE_REVERB_DELAY:
rlm@0 939 *pflValue = ALEffect->Params.Reverb.LateReverbDelay;
rlm@0 940 break;
rlm@0 941
rlm@0 942 case AL_REVERB_AIR_ABSORPTION_GAINHF:
rlm@0 943 *pflValue = ALEffect->Params.Reverb.AirAbsorptionGainHF;
rlm@0 944 break;
rlm@0 945
rlm@0 946 case AL_REVERB_ROOM_ROLLOFF_FACTOR:
rlm@0 947 *pflValue = ALEffect->Params.Reverb.RoomRolloffFactor;
rlm@0 948 break;
rlm@0 949
rlm@0 950 default:
rlm@0 951 alSetError(Context, AL_INVALID_ENUM);
rlm@0 952 break;
rlm@0 953 }
rlm@0 954 }
rlm@0 955 else if(ALEffect->type == AL_EFFECT_ECHO)
rlm@0 956 {
rlm@0 957 switch(param)
rlm@0 958 {
rlm@0 959 case AL_ECHO_DELAY:
rlm@0 960 *pflValue = ALEffect->Params.Echo.Delay;
rlm@0 961 break;
rlm@0 962
rlm@0 963 case AL_ECHO_LRDELAY:
rlm@0 964 *pflValue = ALEffect->Params.Echo.LRDelay;
rlm@0 965 break;
rlm@0 966
rlm@0 967 case AL_ECHO_DAMPING:
rlm@0 968 *pflValue = ALEffect->Params.Echo.Damping;
rlm@0 969 break;
rlm@0 970
rlm@0 971 case AL_ECHO_FEEDBACK:
rlm@0 972 *pflValue = ALEffect->Params.Echo.Feedback;
rlm@0 973 break;
rlm@0 974
rlm@0 975 case AL_ECHO_SPREAD:
rlm@0 976 *pflValue = ALEffect->Params.Echo.Spread;
rlm@0 977 break;
rlm@0 978
rlm@0 979 default:
rlm@0 980 alSetError(Context, AL_INVALID_ENUM);
rlm@0 981 break;
rlm@0 982 }
rlm@0 983 }
rlm@0 984 else if(ALEffect->type == AL_EFFECT_RING_MODULATOR)
rlm@0 985 {
rlm@0 986 switch(param)
rlm@0 987 {
rlm@0 988 case AL_RING_MODULATOR_FREQUENCY:
rlm@0 989 *pflValue = ALEffect->Params.Modulator.Frequency;
rlm@0 990 break;
rlm@0 991 case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
rlm@0 992 *pflValue = ALEffect->Params.Modulator.HighPassCutoff;
rlm@0 993 break;
rlm@0 994
rlm@0 995 default:
rlm@0 996 alSetError(Context, AL_INVALID_ENUM);
rlm@0 997 break;
rlm@0 998 }
rlm@0 999 }
rlm@0 1000 else if(ALEffect->type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT ||
rlm@0 1001 ALEffect->type == AL_EFFECT_DEDICATED_DIALOGUE)
rlm@0 1002 {
rlm@0 1003 switch(param)
rlm@0 1004 {
rlm@0 1005 case AL_DEDICATED_GAIN:
rlm@0 1006 *pflValue = ALEffect->Params.Dedicated.Gain;
rlm@0 1007 break;
rlm@0 1008
rlm@0 1009 default:
rlm@0 1010 alSetError(Context, AL_INVALID_ENUM);
rlm@0 1011 break;
rlm@0 1012 }
rlm@0 1013 }
rlm@0 1014 else
rlm@0 1015 alSetError(Context, AL_INVALID_ENUM);
rlm@0 1016 }
rlm@0 1017 else
rlm@0 1018 alSetError(Context, AL_INVALID_NAME);
rlm@0 1019
rlm@0 1020 UnlockContext(Context);
rlm@0 1021 }
rlm@0 1022
rlm@0 1023 AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues)
rlm@0 1024 {
rlm@0 1025 ALCcontext *Context;
rlm@0 1026 ALCdevice *Device;
rlm@0 1027 ALeffect *ALEffect;
rlm@0 1028
rlm@0 1029 Context = GetLockedContext();
rlm@0 1030 if(!Context) return;
rlm@0 1031
rlm@0 1032 Device = Context->Device;
rlm@0 1033 if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
rlm@0 1034 {
rlm@0 1035 if(ALEffect->type == AL_EFFECT_EAXREVERB)
rlm@0 1036 {
rlm@0 1037 switch(param)
rlm@0 1038 {
rlm@0 1039 case AL_EAXREVERB_REFLECTIONS_PAN:
rlm@0 1040 pflValues[0] = ALEffect->Params.Reverb.ReflectionsPan[0];
rlm@0 1041 pflValues[1] = ALEffect->Params.Reverb.ReflectionsPan[1];
rlm@0 1042 pflValues[2] = ALEffect->Params.Reverb.ReflectionsPan[2];
rlm@0 1043 break;
rlm@0 1044 case AL_EAXREVERB_LATE_REVERB_PAN:
rlm@0 1045 pflValues[0] = ALEffect->Params.Reverb.LateReverbPan[0];
rlm@0 1046 pflValues[1] = ALEffect->Params.Reverb.LateReverbPan[1];
rlm@0 1047 pflValues[2] = ALEffect->Params.Reverb.LateReverbPan[2];
rlm@0 1048 break;
rlm@0 1049
rlm@0 1050 default:
rlm@0 1051 UnlockContext(Context);
rlm@0 1052 alGetEffectf(effect, param, pflValues);
rlm@0 1053 return;
rlm@0 1054 }
rlm@0 1055 }
rlm@0 1056 else
rlm@0 1057 {
rlm@0 1058 UnlockContext(Context);
rlm@0 1059 alGetEffectf(effect, param, pflValues);
rlm@0 1060 return;
rlm@0 1061 }
rlm@0 1062 }
rlm@0 1063 else
rlm@0 1064 alSetError(Context, AL_INVALID_NAME);
rlm@0 1065
rlm@0 1066 UnlockContext(Context);
rlm@0 1067 }
rlm@0 1068
rlm@0 1069
rlm@0 1070 ALvoid ReleaseALEffects(ALCdevice *device)
rlm@0 1071 {
rlm@0 1072 ALsizei i;
rlm@0 1073 for(i = 0;i < device->EffectMap.size;i++)
rlm@0 1074 {
rlm@0 1075 ALeffect *temp = device->EffectMap.array[i].value;
rlm@0 1076 device->EffectMap.array[i].value = NULL;
rlm@0 1077
rlm@0 1078 // Release effect structure
rlm@0 1079 FreeThunkEntry(temp->effect);
rlm@0 1080 memset(temp, 0, sizeof(ALeffect));
rlm@0 1081 free(temp);
rlm@0 1082 }
rlm@0 1083 }
rlm@0 1084
rlm@0 1085
rlm@0 1086 static void InitEffectParams(ALeffect *effect, ALenum type)
rlm@0 1087 {
rlm@0 1088 effect->type = type;
rlm@0 1089 switch(type)
rlm@0 1090 {
rlm@0 1091 /* NOTE: Standard reverb and EAX reverb use the same defaults for the
rlm@0 1092 * shared parameters, and EAX's additional parameters default to
rlm@0 1093 * values assumed by standard reverb.
rlm@0 1094 */
rlm@0 1095 case AL_EFFECT_EAXREVERB:
rlm@0 1096 case AL_EFFECT_REVERB:
rlm@0 1097 effect->Params.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY;
rlm@0 1098 effect->Params.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION;
rlm@0 1099 effect->Params.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN;
rlm@0 1100 effect->Params.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF;
rlm@0 1101 effect->Params.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF;
rlm@0 1102 effect->Params.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME;
rlm@0 1103 effect->Params.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO;
rlm@0 1104 effect->Params.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO;
rlm@0 1105 effect->Params.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN;
rlm@0 1106 effect->Params.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY;
rlm@0 1107 effect->Params.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
rlm@0 1108 effect->Params.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
rlm@0 1109 effect->Params.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
rlm@0 1110 effect->Params.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN;
rlm@0 1111 effect->Params.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY;
rlm@0 1112 effect->Params.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
rlm@0 1113 effect->Params.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
rlm@0 1114 effect->Params.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
rlm@0 1115 effect->Params.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME;
rlm@0 1116 effect->Params.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH;
rlm@0 1117 effect->Params.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME;
rlm@0 1118 effect->Params.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH;
rlm@0 1119 effect->Params.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
rlm@0 1120 effect->Params.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE;
rlm@0 1121 effect->Params.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE;
rlm@0 1122 effect->Params.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
rlm@0 1123 effect->Params.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT;
rlm@0 1124 break;
rlm@0 1125 case AL_EFFECT_ECHO:
rlm@0 1126 effect->Params.Echo.Delay = AL_ECHO_DEFAULT_DELAY;
rlm@0 1127 effect->Params.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY;
rlm@0 1128 effect->Params.Echo.Damping = AL_ECHO_DEFAULT_DAMPING;
rlm@0 1129 effect->Params.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK;
rlm@0 1130 effect->Params.Echo.Spread = AL_ECHO_DEFAULT_SPREAD;
rlm@0 1131 break;
rlm@0 1132 case AL_EFFECT_RING_MODULATOR:
rlm@0 1133 effect->Params.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
rlm@0 1134 effect->Params.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
rlm@0 1135 effect->Params.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
rlm@0 1136 break;
rlm@0 1137 case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT:
rlm@0 1138 case AL_EFFECT_DEDICATED_DIALOGUE:
rlm@0 1139 effect->Params.Dedicated.Gain = 1.0f;
rlm@0 1140 break;
rlm@0 1141 }
rlm@0 1142 }