alEffect.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  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 <float.h>
  24. #include "AL/al.h"
  25. #include "AL/alc.h"
  26. #include "alMain.h"
  27. #include "alEffect.h"
  28. #include "alThunk.h"
  29. #include "alError.h"
  30. ALboolean DisabledEffects[MAX_EFFECTS];
  31. extern inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id);
  32. extern inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id);
  33. extern inline ALboolean IsReverbEffect(ALenum type);
  34. static void InitEffectParams(ALeffect *effect, ALenum type);
  35. AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
  36. {
  37. ALCdevice *device;
  38. ALCcontext *context;
  39. ALsizei cur;
  40. context = GetContextRef();
  41. if(!context) return;
  42. if(!(n >= 0))
  43. SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
  44. device = context->Device;
  45. for(cur = 0;cur < n;cur++)
  46. {
  47. ALeffect *effect = calloc(1, sizeof(ALeffect));
  48. ALenum err = AL_OUT_OF_MEMORY;
  49. if(!effect || (err=InitEffect(effect)) != AL_NO_ERROR)
  50. {
  51. free(effect);
  52. alDeleteEffects(cur, effects);
  53. SET_ERROR_AND_GOTO(context, err, done);
  54. }
  55. err = NewThunkEntry(&effect->id);
  56. if(err == AL_NO_ERROR)
  57. err = InsertUIntMapEntry(&device->EffectMap, effect->id, effect);
  58. if(err != AL_NO_ERROR)
  59. {
  60. FreeThunkEntry(effect->id);
  61. memset(effect, 0, sizeof(ALeffect));
  62. free(effect);
  63. alDeleteEffects(cur, effects);
  64. SET_ERROR_AND_GOTO(context, err, done);
  65. }
  66. effects[cur] = effect->id;
  67. }
  68. done:
  69. ALCcontext_DecRef(context);
  70. }
  71. AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects)
  72. {
  73. ALCdevice *device;
  74. ALCcontext *context;
  75. ALeffect *effect;
  76. ALsizei i;
  77. context = GetContextRef();
  78. if(!context) return;
  79. if(!(n >= 0))
  80. SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
  81. device = context->Device;
  82. for(i = 0;i < n;i++)
  83. {
  84. if(effects[i] && LookupEffect(device, effects[i]) == NULL)
  85. SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
  86. }
  87. for(i = 0;i < n;i++)
  88. {
  89. if((effect=RemoveEffect(device, effects[i])) == NULL)
  90. continue;
  91. FreeThunkEntry(effect->id);
  92. memset(effect, 0, sizeof(*effect));
  93. free(effect);
  94. }
  95. done:
  96. ALCcontext_DecRef(context);
  97. }
  98. AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
  99. {
  100. ALCcontext *Context;
  101. ALboolean result;
  102. Context = GetContextRef();
  103. if(!Context) return AL_FALSE;
  104. result = ((!effect || LookupEffect(Context->Device, effect)) ?
  105. AL_TRUE : AL_FALSE);
  106. ALCcontext_DecRef(Context);
  107. return result;
  108. }
  109. AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value)
  110. {
  111. ALCcontext *Context;
  112. ALCdevice *Device;
  113. ALeffect *ALEffect;
  114. Context = GetContextRef();
  115. if(!Context) return;
  116. Device = Context->Device;
  117. if((ALEffect=LookupEffect(Device, effect)) == NULL)
  118. alSetError(Context, AL_INVALID_NAME);
  119. else
  120. {
  121. if(param == AL_EFFECT_TYPE)
  122. {
  123. ALboolean isOk = (value == AL_EFFECT_NULL);
  124. ALint i;
  125. for(i = 0;!isOk && EffectList[i].val;i++)
  126. {
  127. if(value == EffectList[i].val &&
  128. !DisabledEffects[EffectList[i].type])
  129. isOk = AL_TRUE;
  130. }
  131. if(isOk)
  132. InitEffectParams(ALEffect, value);
  133. else
  134. alSetError(Context, AL_INVALID_VALUE);
  135. }
  136. else
  137. {
  138. /* Call the appropriate handler */
  139. V(ALEffect,setParami)(Context, param, value);
  140. }
  141. }
  142. ALCcontext_DecRef(Context);
  143. }
  144. AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *values)
  145. {
  146. ALCcontext *Context;
  147. ALCdevice *Device;
  148. ALeffect *ALEffect;
  149. switch(param)
  150. {
  151. case AL_EFFECT_TYPE:
  152. alEffecti(effect, param, values[0]);
  153. return;
  154. }
  155. Context = GetContextRef();
  156. if(!Context) return;
  157. Device = Context->Device;
  158. if((ALEffect=LookupEffect(Device, effect)) == NULL)
  159. alSetError(Context, AL_INVALID_NAME);
  160. else
  161. {
  162. /* Call the appropriate handler */
  163. V(ALEffect,setParamiv)(Context, param, values);
  164. }
  165. ALCcontext_DecRef(Context);
  166. }
  167. AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value)
  168. {
  169. ALCcontext *Context;
  170. ALCdevice *Device;
  171. ALeffect *ALEffect;
  172. Context = GetContextRef();
  173. if(!Context) return;
  174. Device = Context->Device;
  175. if((ALEffect=LookupEffect(Device, effect)) == NULL)
  176. alSetError(Context, AL_INVALID_NAME);
  177. else
  178. {
  179. /* Call the appropriate handler */
  180. V(ALEffect,setParamf)(Context, param, value);
  181. }
  182. ALCcontext_DecRef(Context);
  183. }
  184. AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *values)
  185. {
  186. ALCcontext *Context;
  187. ALCdevice *Device;
  188. ALeffect *ALEffect;
  189. Context = GetContextRef();
  190. if(!Context) return;
  191. Device = Context->Device;
  192. if((ALEffect=LookupEffect(Device, effect)) == NULL)
  193. alSetError(Context, AL_INVALID_NAME);
  194. else
  195. {
  196. /* Call the appropriate handler */
  197. V(ALEffect,setParamfv)(Context, param, values);
  198. }
  199. ALCcontext_DecRef(Context);
  200. }
  201. AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value)
  202. {
  203. ALCcontext *Context;
  204. ALCdevice *Device;
  205. ALeffect *ALEffect;
  206. Context = GetContextRef();
  207. if(!Context) return;
  208. Device = Context->Device;
  209. if((ALEffect=LookupEffect(Device, effect)) == NULL)
  210. alSetError(Context, AL_INVALID_NAME);
  211. else
  212. {
  213. if(param == AL_EFFECT_TYPE)
  214. *value = ALEffect->type;
  215. else
  216. {
  217. /* Call the appropriate handler */
  218. V(ALEffect,getParami)(Context, param, value);
  219. }
  220. }
  221. ALCcontext_DecRef(Context);
  222. }
  223. AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *values)
  224. {
  225. ALCcontext *Context;
  226. ALCdevice *Device;
  227. ALeffect *ALEffect;
  228. switch(param)
  229. {
  230. case AL_EFFECT_TYPE:
  231. alGetEffecti(effect, param, values);
  232. return;
  233. }
  234. Context = GetContextRef();
  235. if(!Context) return;
  236. Device = Context->Device;
  237. if((ALEffect=LookupEffect(Device, effect)) == NULL)
  238. alSetError(Context, AL_INVALID_NAME);
  239. else
  240. {
  241. /* Call the appropriate handler */
  242. V(ALEffect,getParamiv)(Context, param, values);
  243. }
  244. ALCcontext_DecRef(Context);
  245. }
  246. AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *value)
  247. {
  248. ALCcontext *Context;
  249. ALCdevice *Device;
  250. ALeffect *ALEffect;
  251. Context = GetContextRef();
  252. if(!Context) return;
  253. Device = Context->Device;
  254. if((ALEffect=LookupEffect(Device, effect)) == NULL)
  255. alSetError(Context, AL_INVALID_NAME);
  256. else
  257. {
  258. /* Call the appropriate handler */
  259. V(ALEffect,getParamf)(Context, param, value);
  260. }
  261. ALCcontext_DecRef(Context);
  262. }
  263. AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *values)
  264. {
  265. ALCcontext *Context;
  266. ALCdevice *Device;
  267. ALeffect *ALEffect;
  268. Context = GetContextRef();
  269. if(!Context) return;
  270. Device = Context->Device;
  271. if((ALEffect=LookupEffect(Device, effect)) == NULL)
  272. alSetError(Context, AL_INVALID_NAME);
  273. else
  274. {
  275. /* Call the appropriate handler */
  276. V(ALEffect,getParamfv)(Context, param, values);
  277. }
  278. ALCcontext_DecRef(Context);
  279. }
  280. ALenum InitEffect(ALeffect *effect)
  281. {
  282. InitEffectParams(effect, AL_EFFECT_NULL);
  283. return AL_NO_ERROR;
  284. }
  285. ALvoid ReleaseALEffects(ALCdevice *device)
  286. {
  287. ALsizei i;
  288. for(i = 0;i < device->EffectMap.size;i++)
  289. {
  290. ALeffect *temp = device->EffectMap.array[i].value;
  291. device->EffectMap.array[i].value = NULL;
  292. // Release effect structure
  293. FreeThunkEntry(temp->id);
  294. memset(temp, 0, sizeof(ALeffect));
  295. free(temp);
  296. }
  297. }
  298. static void InitEffectParams(ALeffect *effect, ALenum type)
  299. {
  300. switch(type)
  301. {
  302. case AL_EFFECT_EAXREVERB:
  303. effect->Props.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY;
  304. effect->Props.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION;
  305. effect->Props.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN;
  306. effect->Props.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF;
  307. effect->Props.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF;
  308. effect->Props.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME;
  309. effect->Props.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO;
  310. effect->Props.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO;
  311. effect->Props.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN;
  312. effect->Props.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY;
  313. effect->Props.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  314. effect->Props.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  315. effect->Props.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  316. effect->Props.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN;
  317. effect->Props.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY;
  318. effect->Props.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  319. effect->Props.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  320. effect->Props.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  321. effect->Props.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME;
  322. effect->Props.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH;
  323. effect->Props.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME;
  324. effect->Props.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH;
  325. effect->Props.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
  326. effect->Props.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE;
  327. effect->Props.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE;
  328. effect->Props.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
  329. effect->Props.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT;
  330. SET_VTABLE1(ALeaxreverb, effect);
  331. break;
  332. case AL_EFFECT_REVERB:
  333. effect->Props.Reverb.Density = AL_REVERB_DEFAULT_DENSITY;
  334. effect->Props.Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION;
  335. effect->Props.Reverb.Gain = AL_REVERB_DEFAULT_GAIN;
  336. effect->Props.Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF;
  337. effect->Props.Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME;
  338. effect->Props.Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO;
  339. effect->Props.Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN;
  340. effect->Props.Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY;
  341. effect->Props.Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN;
  342. effect->Props.Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY;
  343. effect->Props.Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
  344. effect->Props.Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
  345. effect->Props.Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT;
  346. SET_VTABLE1(ALreverb, effect);
  347. break;
  348. case AL_EFFECT_AUTOWAH:
  349. effect->Props.Autowah.AttackTime = AL_AUTOWAH_DEFAULT_ATTACK_TIME;
  350. effect->Props.Autowah.PeakGain = AL_AUTOWAH_DEFAULT_PEAK_GAIN;
  351. effect->Props.Autowah.ReleaseTime = AL_AUTOWAH_DEFAULT_RELEASE_TIME;
  352. effect->Props.Autowah.Resonance = AL_AUTOWAH_DEFAULT_RESONANCE;
  353. SET_VTABLE1(ALautowah, effect);
  354. break;
  355. case AL_EFFECT_CHORUS:
  356. effect->Props.Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM;
  357. effect->Props.Chorus.Phase = AL_CHORUS_DEFAULT_PHASE;
  358. effect->Props.Chorus.Rate = AL_CHORUS_DEFAULT_RATE;
  359. effect->Props.Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH;
  360. effect->Props.Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK;
  361. effect->Props.Chorus.Delay = AL_CHORUS_DEFAULT_DELAY;
  362. SET_VTABLE1(ALchorus, effect);
  363. break;
  364. case AL_EFFECT_COMPRESSOR:
  365. effect->Props.Compressor.OnOff = AL_COMPRESSOR_DEFAULT_ONOFF;
  366. SET_VTABLE1(ALcompressor, effect);
  367. break;
  368. case AL_EFFECT_DISTORTION:
  369. effect->Props.Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE;
  370. effect->Props.Distortion.Gain = AL_DISTORTION_DEFAULT_GAIN;
  371. effect->Props.Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF;
  372. effect->Props.Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER;
  373. effect->Props.Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH;
  374. SET_VTABLE1(ALdistortion, effect);
  375. break;
  376. case AL_EFFECT_ECHO:
  377. effect->Props.Echo.Delay = AL_ECHO_DEFAULT_DELAY;
  378. effect->Props.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY;
  379. effect->Props.Echo.Damping = AL_ECHO_DEFAULT_DAMPING;
  380. effect->Props.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK;
  381. effect->Props.Echo.Spread = AL_ECHO_DEFAULT_SPREAD;
  382. SET_VTABLE1(ALecho, effect);
  383. break;
  384. case AL_EFFECT_EQUALIZER:
  385. effect->Props.Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF;
  386. effect->Props.Equalizer.LowGain = AL_EQUALIZER_DEFAULT_LOW_GAIN;
  387. effect->Props.Equalizer.Mid1Center = AL_EQUALIZER_DEFAULT_MID1_CENTER;
  388. effect->Props.Equalizer.Mid1Gain = AL_EQUALIZER_DEFAULT_MID1_GAIN;
  389. effect->Props.Equalizer.Mid1Width = AL_EQUALIZER_DEFAULT_MID1_WIDTH;
  390. effect->Props.Equalizer.Mid2Center = AL_EQUALIZER_DEFAULT_MID2_CENTER;
  391. effect->Props.Equalizer.Mid2Gain = AL_EQUALIZER_DEFAULT_MID2_GAIN;
  392. effect->Props.Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH;
  393. effect->Props.Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF;
  394. effect->Props.Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN;
  395. SET_VTABLE1(ALequalizer, effect);
  396. break;
  397. case AL_EFFECT_FLANGER:
  398. effect->Props.Flanger.Waveform = AL_FLANGER_DEFAULT_WAVEFORM;
  399. effect->Props.Flanger.Phase = AL_FLANGER_DEFAULT_PHASE;
  400. effect->Props.Flanger.Rate = AL_FLANGER_DEFAULT_RATE;
  401. effect->Props.Flanger.Depth = AL_FLANGER_DEFAULT_DEPTH;
  402. effect->Props.Flanger.Feedback = AL_FLANGER_DEFAULT_FEEDBACK;
  403. effect->Props.Flanger.Delay = AL_FLANGER_DEFAULT_DELAY;
  404. SET_VTABLE1(ALflanger, effect);
  405. break;
  406. case AL_EFFECT_RING_MODULATOR:
  407. effect->Props.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
  408. effect->Props.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
  409. effect->Props.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM;
  410. SET_VTABLE1(ALmodulator, effect);
  411. break;
  412. case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT:
  413. case AL_EFFECT_DEDICATED_DIALOGUE:
  414. effect->Props.Dedicated.Gain = 1.0f;
  415. SET_VTABLE1(ALdedicated, effect);
  416. break;
  417. default:
  418. SET_VTABLE1(ALnull, effect);
  419. break;
  420. }
  421. effect->type = type;
  422. }
  423. #include "AL/efx-presets.h"
  424. #define DECL(x) { #x, EFX_REVERB_PRESET_##x }
  425. static const struct {
  426. const char name[32];
  427. EFXEAXREVERBPROPERTIES props;
  428. } reverblist[] = {
  429. DECL(GENERIC),
  430. DECL(PADDEDCELL),
  431. DECL(ROOM),
  432. DECL(BATHROOM),
  433. DECL(LIVINGROOM),
  434. DECL(STONEROOM),
  435. DECL(AUDITORIUM),
  436. DECL(CONCERTHALL),
  437. DECL(CAVE),
  438. DECL(ARENA),
  439. DECL(HANGAR),
  440. DECL(CARPETEDHALLWAY),
  441. DECL(HALLWAY),
  442. DECL(STONECORRIDOR),
  443. DECL(ALLEY),
  444. DECL(FOREST),
  445. DECL(CITY),
  446. DECL(MOUNTAINS),
  447. DECL(QUARRY),
  448. DECL(PLAIN),
  449. DECL(PARKINGLOT),
  450. DECL(SEWERPIPE),
  451. DECL(UNDERWATER),
  452. DECL(DRUGGED),
  453. DECL(DIZZY),
  454. DECL(PSYCHOTIC),
  455. DECL(CASTLE_SMALLROOM),
  456. DECL(CASTLE_SHORTPASSAGE),
  457. DECL(CASTLE_MEDIUMROOM),
  458. DECL(CASTLE_LARGEROOM),
  459. DECL(CASTLE_LONGPASSAGE),
  460. DECL(CASTLE_HALL),
  461. DECL(CASTLE_CUPBOARD),
  462. DECL(CASTLE_COURTYARD),
  463. DECL(CASTLE_ALCOVE),
  464. DECL(FACTORY_SMALLROOM),
  465. DECL(FACTORY_SHORTPASSAGE),
  466. DECL(FACTORY_MEDIUMROOM),
  467. DECL(FACTORY_LARGEROOM),
  468. DECL(FACTORY_LONGPASSAGE),
  469. DECL(FACTORY_HALL),
  470. DECL(FACTORY_CUPBOARD),
  471. DECL(FACTORY_COURTYARD),
  472. DECL(FACTORY_ALCOVE),
  473. DECL(ICEPALACE_SMALLROOM),
  474. DECL(ICEPALACE_SHORTPASSAGE),
  475. DECL(ICEPALACE_MEDIUMROOM),
  476. DECL(ICEPALACE_LARGEROOM),
  477. DECL(ICEPALACE_LONGPASSAGE),
  478. DECL(ICEPALACE_HALL),
  479. DECL(ICEPALACE_CUPBOARD),
  480. DECL(ICEPALACE_COURTYARD),
  481. DECL(ICEPALACE_ALCOVE),
  482. DECL(SPACESTATION_SMALLROOM),
  483. DECL(SPACESTATION_SHORTPASSAGE),
  484. DECL(SPACESTATION_MEDIUMROOM),
  485. DECL(SPACESTATION_LARGEROOM),
  486. DECL(SPACESTATION_LONGPASSAGE),
  487. DECL(SPACESTATION_HALL),
  488. DECL(SPACESTATION_CUPBOARD),
  489. DECL(SPACESTATION_ALCOVE),
  490. DECL(WOODEN_SMALLROOM),
  491. DECL(WOODEN_SHORTPASSAGE),
  492. DECL(WOODEN_MEDIUMROOM),
  493. DECL(WOODEN_LARGEROOM),
  494. DECL(WOODEN_LONGPASSAGE),
  495. DECL(WOODEN_HALL),
  496. DECL(WOODEN_CUPBOARD),
  497. DECL(WOODEN_COURTYARD),
  498. DECL(WOODEN_ALCOVE),
  499. DECL(SPORT_EMPTYSTADIUM),
  500. DECL(SPORT_SQUASHCOURT),
  501. DECL(SPORT_SMALLSWIMMINGPOOL),
  502. DECL(SPORT_LARGESWIMMINGPOOL),
  503. DECL(SPORT_GYMNASIUM),
  504. DECL(SPORT_FULLSTADIUM),
  505. DECL(SPORT_STADIUMTANNOY),
  506. DECL(PREFAB_WORKSHOP),
  507. DECL(PREFAB_SCHOOLROOM),
  508. DECL(PREFAB_PRACTISEROOM),
  509. DECL(PREFAB_OUTHOUSE),
  510. DECL(PREFAB_CARAVAN),
  511. DECL(DOME_TOMB),
  512. DECL(PIPE_SMALL),
  513. DECL(DOME_SAINTPAULS),
  514. DECL(PIPE_LONGTHIN),
  515. DECL(PIPE_LARGE),
  516. DECL(PIPE_RESONANT),
  517. DECL(OUTDOORS_BACKYARD),
  518. DECL(OUTDOORS_ROLLINGPLAINS),
  519. DECL(OUTDOORS_DEEPCANYON),
  520. DECL(OUTDOORS_CREEK),
  521. DECL(OUTDOORS_VALLEY),
  522. DECL(MOOD_HEAVEN),
  523. DECL(MOOD_HELL),
  524. DECL(MOOD_MEMORY),
  525. DECL(DRIVING_COMMENTATOR),
  526. DECL(DRIVING_PITGARAGE),
  527. DECL(DRIVING_INCAR_RACER),
  528. DECL(DRIVING_INCAR_SPORTS),
  529. DECL(DRIVING_INCAR_LUXURY),
  530. DECL(DRIVING_FULLGRANDSTAND),
  531. DECL(DRIVING_EMPTYGRANDSTAND),
  532. DECL(DRIVING_TUNNEL),
  533. DECL(CITY_STREETS),
  534. DECL(CITY_SUBWAY),
  535. DECL(CITY_MUSEUM),
  536. DECL(CITY_LIBRARY),
  537. DECL(CITY_UNDERPASS),
  538. DECL(CITY_ABANDONED),
  539. DECL(DUSTYROOM),
  540. DECL(CHAPEL),
  541. DECL(SMALLWATERROOM),
  542. };
  543. #undef DECL
  544. ALvoid LoadReverbPreset(const char *name, ALeffect *effect)
  545. {
  546. size_t i;
  547. if(strcasecmp(name, "NONE") == 0)
  548. {
  549. InitEffectParams(effect, AL_EFFECT_NULL);
  550. TRACE("Loading reverb '%s'\n", "NONE");
  551. return;
  552. }
  553. if(!DisabledEffects[EAXREVERB])
  554. InitEffectParams(effect, AL_EFFECT_EAXREVERB);
  555. else if(!DisabledEffects[REVERB])
  556. InitEffectParams(effect, AL_EFFECT_REVERB);
  557. else
  558. InitEffectParams(effect, AL_EFFECT_NULL);
  559. for(i = 0;i < COUNTOF(reverblist);i++)
  560. {
  561. const EFXEAXREVERBPROPERTIES *props;
  562. if(strcasecmp(name, reverblist[i].name) != 0)
  563. continue;
  564. TRACE("Loading reverb '%s'\n", reverblist[i].name);
  565. props = &reverblist[i].props;
  566. effect->Props.Reverb.Density = props->flDensity;
  567. effect->Props.Reverb.Diffusion = props->flDiffusion;
  568. effect->Props.Reverb.Gain = props->flGain;
  569. effect->Props.Reverb.GainHF = props->flGainHF;
  570. effect->Props.Reverb.GainLF = props->flGainLF;
  571. effect->Props.Reverb.DecayTime = props->flDecayTime;
  572. effect->Props.Reverb.DecayHFRatio = props->flDecayHFRatio;
  573. effect->Props.Reverb.DecayLFRatio = props->flDecayLFRatio;
  574. effect->Props.Reverb.ReflectionsGain = props->flReflectionsGain;
  575. effect->Props.Reverb.ReflectionsDelay = props->flReflectionsDelay;
  576. effect->Props.Reverb.ReflectionsPan[0] = props->flReflectionsPan[0];
  577. effect->Props.Reverb.ReflectionsPan[1] = props->flReflectionsPan[1];
  578. effect->Props.Reverb.ReflectionsPan[2] = props->flReflectionsPan[2];
  579. effect->Props.Reverb.LateReverbGain = props->flLateReverbGain;
  580. effect->Props.Reverb.LateReverbDelay = props->flLateReverbDelay;
  581. effect->Props.Reverb.LateReverbPan[0] = props->flLateReverbPan[0];
  582. effect->Props.Reverb.LateReverbPan[1] = props->flLateReverbPan[1];
  583. effect->Props.Reverb.LateReverbPan[2] = props->flLateReverbPan[2];
  584. effect->Props.Reverb.EchoTime = props->flEchoTime;
  585. effect->Props.Reverb.EchoDepth = props->flEchoDepth;
  586. effect->Props.Reverb.ModulationTime = props->flModulationTime;
  587. effect->Props.Reverb.ModulationDepth = props->flModulationDepth;
  588. effect->Props.Reverb.AirAbsorptionGainHF = props->flAirAbsorptionGainHF;
  589. effect->Props.Reverb.HFReference = props->flHFReference;
  590. effect->Props.Reverb.LFReference = props->flLFReference;
  591. effect->Props.Reverb.RoomRolloffFactor = props->flRoomRolloffFactor;
  592. effect->Props.Reverb.DecayHFLimit = props->iDecayHFLimit;
  593. return;
  594. }
  595. WARN("Reverb preset '%s' not found\n", name);
  596. }