reverb.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. #include "config.h"
  2. #include <cmath>
  3. #include "AL/al.h"
  4. #include "AL/efx.h"
  5. #include "effects.h"
  6. #include "effects/base.h"
  7. namespace {
  8. void Reverb_setParami(EffectProps *props, ALenum param, int val)
  9. {
  10. switch(param)
  11. {
  12. case AL_EAXREVERB_DECAY_HFLIMIT:
  13. if(!(val >= AL_EAXREVERB_MIN_DECAY_HFLIMIT && val <= AL_EAXREVERB_MAX_DECAY_HFLIMIT))
  14. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb decay hflimit out of range"};
  15. props->Reverb.DecayHFLimit = val != AL_FALSE;
  16. break;
  17. default:
  18. throw effect_exception{AL_INVALID_ENUM, "Invalid EAX reverb integer property 0x%04x",
  19. param};
  20. }
  21. }
  22. void Reverb_setParamiv(EffectProps *props, ALenum param, const int *vals)
  23. { Reverb_setParami(props, param, vals[0]); }
  24. void Reverb_setParamf(EffectProps *props, ALenum param, float val)
  25. {
  26. switch(param)
  27. {
  28. case AL_EAXREVERB_DENSITY:
  29. if(!(val >= AL_EAXREVERB_MIN_DENSITY && val <= AL_EAXREVERB_MAX_DENSITY))
  30. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb density out of range"};
  31. props->Reverb.Density = val;
  32. break;
  33. case AL_EAXREVERB_DIFFUSION:
  34. if(!(val >= AL_EAXREVERB_MIN_DIFFUSION && val <= AL_EAXREVERB_MAX_DIFFUSION))
  35. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb diffusion out of range"};
  36. props->Reverb.Diffusion = val;
  37. break;
  38. case AL_EAXREVERB_GAIN:
  39. if(!(val >= AL_EAXREVERB_MIN_GAIN && val <= AL_EAXREVERB_MAX_GAIN))
  40. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb gain out of range"};
  41. props->Reverb.Gain = val;
  42. break;
  43. case AL_EAXREVERB_GAINHF:
  44. if(!(val >= AL_EAXREVERB_MIN_GAINHF && val <= AL_EAXREVERB_MAX_GAINHF))
  45. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb gainhf out of range"};
  46. props->Reverb.GainHF = val;
  47. break;
  48. case AL_EAXREVERB_GAINLF:
  49. if(!(val >= AL_EAXREVERB_MIN_GAINLF && val <= AL_EAXREVERB_MAX_GAINLF))
  50. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb gainlf out of range"};
  51. props->Reverb.GainLF = val;
  52. break;
  53. case AL_EAXREVERB_DECAY_TIME:
  54. if(!(val >= AL_EAXREVERB_MIN_DECAY_TIME && val <= AL_EAXREVERB_MAX_DECAY_TIME))
  55. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb decay time out of range"};
  56. props->Reverb.DecayTime = val;
  57. break;
  58. case AL_EAXREVERB_DECAY_HFRATIO:
  59. if(!(val >= AL_EAXREVERB_MIN_DECAY_HFRATIO && val <= AL_EAXREVERB_MAX_DECAY_HFRATIO))
  60. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb decay hfratio out of range"};
  61. props->Reverb.DecayHFRatio = val;
  62. break;
  63. case AL_EAXREVERB_DECAY_LFRATIO:
  64. if(!(val >= AL_EAXREVERB_MIN_DECAY_LFRATIO && val <= AL_EAXREVERB_MAX_DECAY_LFRATIO))
  65. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb decay lfratio out of range"};
  66. props->Reverb.DecayLFRatio = val;
  67. break;
  68. case AL_EAXREVERB_REFLECTIONS_GAIN:
  69. if(!(val >= AL_EAXREVERB_MIN_REFLECTIONS_GAIN && val <= AL_EAXREVERB_MAX_REFLECTIONS_GAIN))
  70. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb reflections gain out of range"};
  71. props->Reverb.ReflectionsGain = val;
  72. break;
  73. case AL_EAXREVERB_REFLECTIONS_DELAY:
  74. if(!(val >= AL_EAXREVERB_MIN_REFLECTIONS_DELAY && val <= AL_EAXREVERB_MAX_REFLECTIONS_DELAY))
  75. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb reflections delay out of range"};
  76. props->Reverb.ReflectionsDelay = val;
  77. break;
  78. case AL_EAXREVERB_LATE_REVERB_GAIN:
  79. if(!(val >= AL_EAXREVERB_MIN_LATE_REVERB_GAIN && val <= AL_EAXREVERB_MAX_LATE_REVERB_GAIN))
  80. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb late reverb gain out of range"};
  81. props->Reverb.LateReverbGain = val;
  82. break;
  83. case AL_EAXREVERB_LATE_REVERB_DELAY:
  84. if(!(val >= AL_EAXREVERB_MIN_LATE_REVERB_DELAY && val <= AL_EAXREVERB_MAX_LATE_REVERB_DELAY))
  85. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb late reverb delay out of range"};
  86. props->Reverb.LateReverbDelay = val;
  87. break;
  88. case AL_EAXREVERB_AIR_ABSORPTION_GAINHF:
  89. if(!(val >= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF && val <= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF))
  90. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb air absorption gainhf out of range"};
  91. props->Reverb.AirAbsorptionGainHF = val;
  92. break;
  93. case AL_EAXREVERB_ECHO_TIME:
  94. if(!(val >= AL_EAXREVERB_MIN_ECHO_TIME && val <= AL_EAXREVERB_MAX_ECHO_TIME))
  95. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb echo time out of range"};
  96. props->Reverb.EchoTime = val;
  97. break;
  98. case AL_EAXREVERB_ECHO_DEPTH:
  99. if(!(val >= AL_EAXREVERB_MIN_ECHO_DEPTH && val <= AL_EAXREVERB_MAX_ECHO_DEPTH))
  100. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb echo depth out of range"};
  101. props->Reverb.EchoDepth = val;
  102. break;
  103. case AL_EAXREVERB_MODULATION_TIME:
  104. if(!(val >= AL_EAXREVERB_MIN_MODULATION_TIME && val <= AL_EAXREVERB_MAX_MODULATION_TIME))
  105. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb modulation time out of range"};
  106. props->Reverb.ModulationTime = val;
  107. break;
  108. case AL_EAXREVERB_MODULATION_DEPTH:
  109. if(!(val >= AL_EAXREVERB_MIN_MODULATION_DEPTH && val <= AL_EAXREVERB_MAX_MODULATION_DEPTH))
  110. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb modulation depth out of range"};
  111. props->Reverb.ModulationDepth = val;
  112. break;
  113. case AL_EAXREVERB_HFREFERENCE:
  114. if(!(val >= AL_EAXREVERB_MIN_HFREFERENCE && val <= AL_EAXREVERB_MAX_HFREFERENCE))
  115. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb hfreference out of range"};
  116. props->Reverb.HFReference = val;
  117. break;
  118. case AL_EAXREVERB_LFREFERENCE:
  119. if(!(val >= AL_EAXREVERB_MIN_LFREFERENCE && val <= AL_EAXREVERB_MAX_LFREFERENCE))
  120. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb lfreference out of range"};
  121. props->Reverb.LFReference = val;
  122. break;
  123. case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR:
  124. if(!(val >= AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR && val <= AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR))
  125. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb room rolloff factor out of range"};
  126. props->Reverb.RoomRolloffFactor = val;
  127. break;
  128. default:
  129. throw effect_exception{AL_INVALID_ENUM, "Invalid EAX reverb float property 0x%04x", param};
  130. }
  131. }
  132. void Reverb_setParamfv(EffectProps *props, ALenum param, const float *vals)
  133. {
  134. switch(param)
  135. {
  136. case AL_EAXREVERB_REFLECTIONS_PAN:
  137. if(!(std::isfinite(vals[0]) && std::isfinite(vals[1]) && std::isfinite(vals[2])))
  138. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb reflections pan out of range"};
  139. props->Reverb.ReflectionsPan[0] = vals[0];
  140. props->Reverb.ReflectionsPan[1] = vals[1];
  141. props->Reverb.ReflectionsPan[2] = vals[2];
  142. break;
  143. case AL_EAXREVERB_LATE_REVERB_PAN:
  144. if(!(std::isfinite(vals[0]) && std::isfinite(vals[1]) && std::isfinite(vals[2])))
  145. throw effect_exception{AL_INVALID_VALUE, "EAX Reverb late reverb pan out of range"};
  146. props->Reverb.LateReverbPan[0] = vals[0];
  147. props->Reverb.LateReverbPan[1] = vals[1];
  148. props->Reverb.LateReverbPan[2] = vals[2];
  149. break;
  150. default:
  151. Reverb_setParamf(props, param, vals[0]);
  152. break;
  153. }
  154. }
  155. void Reverb_getParami(const EffectProps *props, ALenum param, int *val)
  156. {
  157. switch(param)
  158. {
  159. case AL_EAXREVERB_DECAY_HFLIMIT:
  160. *val = props->Reverb.DecayHFLimit;
  161. break;
  162. default:
  163. throw effect_exception{AL_INVALID_ENUM, "Invalid EAX reverb integer property 0x%04x",
  164. param};
  165. }
  166. }
  167. void Reverb_getParamiv(const EffectProps *props, ALenum param, int *vals)
  168. { Reverb_getParami(props, param, vals); }
  169. void Reverb_getParamf(const EffectProps *props, ALenum param, float *val)
  170. {
  171. switch(param)
  172. {
  173. case AL_EAXREVERB_DENSITY:
  174. *val = props->Reverb.Density;
  175. break;
  176. case AL_EAXREVERB_DIFFUSION:
  177. *val = props->Reverb.Diffusion;
  178. break;
  179. case AL_EAXREVERB_GAIN:
  180. *val = props->Reverb.Gain;
  181. break;
  182. case AL_EAXREVERB_GAINHF:
  183. *val = props->Reverb.GainHF;
  184. break;
  185. case AL_EAXREVERB_GAINLF:
  186. *val = props->Reverb.GainLF;
  187. break;
  188. case AL_EAXREVERB_DECAY_TIME:
  189. *val = props->Reverb.DecayTime;
  190. break;
  191. case AL_EAXREVERB_DECAY_HFRATIO:
  192. *val = props->Reverb.DecayHFRatio;
  193. break;
  194. case AL_EAXREVERB_DECAY_LFRATIO:
  195. *val = props->Reverb.DecayLFRatio;
  196. break;
  197. case AL_EAXREVERB_REFLECTIONS_GAIN:
  198. *val = props->Reverb.ReflectionsGain;
  199. break;
  200. case AL_EAXREVERB_REFLECTIONS_DELAY:
  201. *val = props->Reverb.ReflectionsDelay;
  202. break;
  203. case AL_EAXREVERB_LATE_REVERB_GAIN:
  204. *val = props->Reverb.LateReverbGain;
  205. break;
  206. case AL_EAXREVERB_LATE_REVERB_DELAY:
  207. *val = props->Reverb.LateReverbDelay;
  208. break;
  209. case AL_EAXREVERB_AIR_ABSORPTION_GAINHF:
  210. *val = props->Reverb.AirAbsorptionGainHF;
  211. break;
  212. case AL_EAXREVERB_ECHO_TIME:
  213. *val = props->Reverb.EchoTime;
  214. break;
  215. case AL_EAXREVERB_ECHO_DEPTH:
  216. *val = props->Reverb.EchoDepth;
  217. break;
  218. case AL_EAXREVERB_MODULATION_TIME:
  219. *val = props->Reverb.ModulationTime;
  220. break;
  221. case AL_EAXREVERB_MODULATION_DEPTH:
  222. *val = props->Reverb.ModulationDepth;
  223. break;
  224. case AL_EAXREVERB_HFREFERENCE:
  225. *val = props->Reverb.HFReference;
  226. break;
  227. case AL_EAXREVERB_LFREFERENCE:
  228. *val = props->Reverb.LFReference;
  229. break;
  230. case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR:
  231. *val = props->Reverb.RoomRolloffFactor;
  232. break;
  233. default:
  234. throw effect_exception{AL_INVALID_ENUM, "Invalid EAX reverb float property 0x%04x", param};
  235. }
  236. }
  237. void Reverb_getParamfv(const EffectProps *props, ALenum param, float *vals)
  238. {
  239. switch(param)
  240. {
  241. case AL_EAXREVERB_REFLECTIONS_PAN:
  242. vals[0] = props->Reverb.ReflectionsPan[0];
  243. vals[1] = props->Reverb.ReflectionsPan[1];
  244. vals[2] = props->Reverb.ReflectionsPan[2];
  245. break;
  246. case AL_EAXREVERB_LATE_REVERB_PAN:
  247. vals[0] = props->Reverb.LateReverbPan[0];
  248. vals[1] = props->Reverb.LateReverbPan[1];
  249. vals[2] = props->Reverb.LateReverbPan[2];
  250. break;
  251. default:
  252. Reverb_getParamf(props, param, vals);
  253. break;
  254. }
  255. }
  256. EffectProps genDefaultProps() noexcept
  257. {
  258. EffectProps props{};
  259. props.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY;
  260. props.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION;
  261. props.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN;
  262. props.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF;
  263. props.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF;
  264. props.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME;
  265. props.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO;
  266. props.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO;
  267. props.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN;
  268. props.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY;
  269. props.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  270. props.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  271. props.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
  272. props.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN;
  273. props.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY;
  274. props.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  275. props.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  276. props.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
  277. props.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME;
  278. props.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH;
  279. props.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME;
  280. props.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH;
  281. props.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
  282. props.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE;
  283. props.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE;
  284. props.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
  285. props.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT;
  286. return props;
  287. }
  288. void StdReverb_setParami(EffectProps *props, ALenum param, int val)
  289. {
  290. switch(param)
  291. {
  292. case AL_REVERB_DECAY_HFLIMIT:
  293. if(!(val >= AL_REVERB_MIN_DECAY_HFLIMIT && val <= AL_REVERB_MAX_DECAY_HFLIMIT))
  294. throw effect_exception{AL_INVALID_VALUE, "Reverb decay hflimit out of range"};
  295. props->Reverb.DecayHFLimit = val != AL_FALSE;
  296. break;
  297. default:
  298. throw effect_exception{AL_INVALID_ENUM, "Invalid reverb integer property 0x%04x", param};
  299. }
  300. }
  301. void StdReverb_setParamiv(EffectProps *props, ALenum param, const int *vals)
  302. { StdReverb_setParami(props, param, vals[0]); }
  303. void StdReverb_setParamf(EffectProps *props, ALenum param, float val)
  304. {
  305. switch(param)
  306. {
  307. case AL_REVERB_DENSITY:
  308. if(!(val >= AL_REVERB_MIN_DENSITY && val <= AL_REVERB_MAX_DENSITY))
  309. throw effect_exception{AL_INVALID_VALUE, "Reverb density out of range"};
  310. props->Reverb.Density = val;
  311. break;
  312. case AL_REVERB_DIFFUSION:
  313. if(!(val >= AL_REVERB_MIN_DIFFUSION && val <= AL_REVERB_MAX_DIFFUSION))
  314. throw effect_exception{AL_INVALID_VALUE, "Reverb diffusion out of range"};
  315. props->Reverb.Diffusion = val;
  316. break;
  317. case AL_REVERB_GAIN:
  318. if(!(val >= AL_REVERB_MIN_GAIN && val <= AL_REVERB_MAX_GAIN))
  319. throw effect_exception{AL_INVALID_VALUE, "Reverb gain out of range"};
  320. props->Reverb.Gain = val;
  321. break;
  322. case AL_REVERB_GAINHF:
  323. if(!(val >= AL_REVERB_MIN_GAINHF && val <= AL_REVERB_MAX_GAINHF))
  324. throw effect_exception{AL_INVALID_VALUE, "Reverb gainhf out of range"};
  325. props->Reverb.GainHF = val;
  326. break;
  327. case AL_REVERB_DECAY_TIME:
  328. if(!(val >= AL_REVERB_MIN_DECAY_TIME && val <= AL_REVERB_MAX_DECAY_TIME))
  329. throw effect_exception{AL_INVALID_VALUE, "Reverb decay time out of range"};
  330. props->Reverb.DecayTime = val;
  331. break;
  332. case AL_REVERB_DECAY_HFRATIO:
  333. if(!(val >= AL_REVERB_MIN_DECAY_HFRATIO && val <= AL_REVERB_MAX_DECAY_HFRATIO))
  334. throw effect_exception{AL_INVALID_VALUE, "Reverb decay hfratio out of range"};
  335. props->Reverb.DecayHFRatio = val;
  336. break;
  337. case AL_REVERB_REFLECTIONS_GAIN:
  338. if(!(val >= AL_REVERB_MIN_REFLECTIONS_GAIN && val <= AL_REVERB_MAX_REFLECTIONS_GAIN))
  339. throw effect_exception{AL_INVALID_VALUE, "Reverb reflections gain out of range"};
  340. props->Reverb.ReflectionsGain = val;
  341. break;
  342. case AL_REVERB_REFLECTIONS_DELAY:
  343. if(!(val >= AL_REVERB_MIN_REFLECTIONS_DELAY && val <= AL_REVERB_MAX_REFLECTIONS_DELAY))
  344. throw effect_exception{AL_INVALID_VALUE, "Reverb reflections delay out of range"};
  345. props->Reverb.ReflectionsDelay = val;
  346. break;
  347. case AL_REVERB_LATE_REVERB_GAIN:
  348. if(!(val >= AL_REVERB_MIN_LATE_REVERB_GAIN && val <= AL_REVERB_MAX_LATE_REVERB_GAIN))
  349. throw effect_exception{AL_INVALID_VALUE, "Reverb late reverb gain out of range"};
  350. props->Reverb.LateReverbGain = val;
  351. break;
  352. case AL_REVERB_LATE_REVERB_DELAY:
  353. if(!(val >= AL_REVERB_MIN_LATE_REVERB_DELAY && val <= AL_REVERB_MAX_LATE_REVERB_DELAY))
  354. throw effect_exception{AL_INVALID_VALUE, "Reverb late reverb delay out of range"};
  355. props->Reverb.LateReverbDelay = val;
  356. break;
  357. case AL_REVERB_AIR_ABSORPTION_GAINHF:
  358. if(!(val >= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF && val <= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF))
  359. throw effect_exception{AL_INVALID_VALUE, "Reverb air absorption gainhf out of range"};
  360. props->Reverb.AirAbsorptionGainHF = val;
  361. break;
  362. case AL_REVERB_ROOM_ROLLOFF_FACTOR:
  363. if(!(val >= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR && val <= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR))
  364. throw effect_exception{AL_INVALID_VALUE, "Reverb room rolloff factor out of range"};
  365. props->Reverb.RoomRolloffFactor = val;
  366. break;
  367. default:
  368. throw effect_exception{AL_INVALID_ENUM, "Invalid reverb float property 0x%04x", param};
  369. }
  370. }
  371. void StdReverb_setParamfv(EffectProps *props, ALenum param, const float *vals)
  372. { StdReverb_setParamf(props, param, vals[0]); }
  373. void StdReverb_getParami(const EffectProps *props, ALenum param, int *val)
  374. {
  375. switch(param)
  376. {
  377. case AL_REVERB_DECAY_HFLIMIT:
  378. *val = props->Reverb.DecayHFLimit;
  379. break;
  380. default:
  381. throw effect_exception{AL_INVALID_ENUM, "Invalid reverb integer property 0x%04x", param};
  382. }
  383. }
  384. void StdReverb_getParamiv(const EffectProps *props, ALenum param, int *vals)
  385. { StdReverb_getParami(props, param, vals); }
  386. void StdReverb_getParamf(const EffectProps *props, ALenum param, float *val)
  387. {
  388. switch(param)
  389. {
  390. case AL_REVERB_DENSITY:
  391. *val = props->Reverb.Density;
  392. break;
  393. case AL_REVERB_DIFFUSION:
  394. *val = props->Reverb.Diffusion;
  395. break;
  396. case AL_REVERB_GAIN:
  397. *val = props->Reverb.Gain;
  398. break;
  399. case AL_REVERB_GAINHF:
  400. *val = props->Reverb.GainHF;
  401. break;
  402. case AL_REVERB_DECAY_TIME:
  403. *val = props->Reverb.DecayTime;
  404. break;
  405. case AL_REVERB_DECAY_HFRATIO:
  406. *val = props->Reverb.DecayHFRatio;
  407. break;
  408. case AL_REVERB_REFLECTIONS_GAIN:
  409. *val = props->Reverb.ReflectionsGain;
  410. break;
  411. case AL_REVERB_REFLECTIONS_DELAY:
  412. *val = props->Reverb.ReflectionsDelay;
  413. break;
  414. case AL_REVERB_LATE_REVERB_GAIN:
  415. *val = props->Reverb.LateReverbGain;
  416. break;
  417. case AL_REVERB_LATE_REVERB_DELAY:
  418. *val = props->Reverb.LateReverbDelay;
  419. break;
  420. case AL_REVERB_AIR_ABSORPTION_GAINHF:
  421. *val = props->Reverb.AirAbsorptionGainHF;
  422. break;
  423. case AL_REVERB_ROOM_ROLLOFF_FACTOR:
  424. *val = props->Reverb.RoomRolloffFactor;
  425. break;
  426. default:
  427. throw effect_exception{AL_INVALID_ENUM, "Invalid reverb float property 0x%04x", param};
  428. }
  429. }
  430. void StdReverb_getParamfv(const EffectProps *props, ALenum param, float *vals)
  431. { StdReverb_getParamf(props, param, vals); }
  432. EffectProps genDefaultStdProps() noexcept
  433. {
  434. EffectProps props{};
  435. props.Reverb.Density = AL_REVERB_DEFAULT_DENSITY;
  436. props.Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION;
  437. props.Reverb.Gain = AL_REVERB_DEFAULT_GAIN;
  438. props.Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF;
  439. props.Reverb.GainLF = 1.0f;
  440. props.Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME;
  441. props.Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO;
  442. props.Reverb.DecayLFRatio = 1.0f;
  443. props.Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN;
  444. props.Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY;
  445. props.Reverb.ReflectionsPan[0] = 0.0f;
  446. props.Reverb.ReflectionsPan[1] = 0.0f;
  447. props.Reverb.ReflectionsPan[2] = 0.0f;
  448. props.Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN;
  449. props.Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY;
  450. props.Reverb.LateReverbPan[0] = 0.0f;
  451. props.Reverb.LateReverbPan[1] = 0.0f;
  452. props.Reverb.LateReverbPan[2] = 0.0f;
  453. props.Reverb.EchoTime = 0.25f;
  454. props.Reverb.EchoDepth = 0.0f;
  455. props.Reverb.ModulationTime = 0.25f;
  456. props.Reverb.ModulationDepth = 0.0f;
  457. props.Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
  458. props.Reverb.HFReference = 5000.0f;
  459. props.Reverb.LFReference = 250.0f;
  460. props.Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
  461. props.Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT;
  462. return props;
  463. }
  464. } // namespace
  465. DEFINE_ALEFFECT_VTABLE(Reverb);
  466. const EffectProps ReverbEffectProps{genDefaultProps()};
  467. DEFINE_ALEFFECT_VTABLE(StdReverb);
  468. const EffectProps StdReverbEffectProps{genDefaultStdProps()};