alEffect.c 44 KB

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