dedicated.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include "config.h"
  2. #include <cmath>
  3. #include "AL/al.h"
  4. #include "AL/alext.h"
  5. #include "alc/effects/base.h"
  6. #include "effects.h"
  7. namespace {
  8. constexpr EffectProps genDefaultDialogProps() noexcept
  9. {
  10. DedicatedDialogProps props{};
  11. props.Gain = 1.0f;
  12. return props;
  13. }
  14. constexpr EffectProps genDefaultLfeProps() noexcept
  15. {
  16. DedicatedLfeProps props{};
  17. props.Gain = 1.0f;
  18. return props;
  19. }
  20. } // namespace
  21. const EffectProps DedicatedDialogEffectProps{genDefaultDialogProps()};
  22. void EffectHandler::SetParami(DedicatedDialogProps&, ALenum param, int)
  23. { throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param}; }
  24. void EffectHandler::SetParamiv(DedicatedDialogProps&, ALenum param, const int*)
  25. {
  26. throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x",
  27. param};
  28. }
  29. void EffectHandler::SetParamf(DedicatedDialogProps &props, ALenum param, float val)
  30. {
  31. switch(param)
  32. {
  33. case AL_DEDICATED_GAIN:
  34. if(!(val >= 0.0f && std::isfinite(val)))
  35. throw effect_exception{AL_INVALID_VALUE, "Dedicated gain out of range"};
  36. props.Gain = val;
  37. break;
  38. default:
  39. throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param};
  40. }
  41. }
  42. void EffectHandler::SetParamfv(DedicatedDialogProps &props, ALenum param, const float *vals)
  43. { SetParamf(props, param, *vals); }
  44. void EffectHandler::GetParami(const DedicatedDialogProps&, ALenum param, int*)
  45. { throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param}; }
  46. void EffectHandler::GetParamiv(const DedicatedDialogProps&, ALenum param, int*)
  47. {
  48. throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x",
  49. param};
  50. }
  51. void EffectHandler::GetParamf(const DedicatedDialogProps &props, ALenum param, float *val)
  52. {
  53. switch(param)
  54. {
  55. case AL_DEDICATED_GAIN: *val = props.Gain; break;
  56. default:
  57. throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param};
  58. }
  59. }
  60. void EffectHandler::GetParamfv(const DedicatedDialogProps &props, ALenum param, float *vals)
  61. { GetParamf(props, param, vals); }
  62. const EffectProps DedicatedLfeEffectProps{genDefaultLfeProps()};
  63. void EffectHandler::SetParami(DedicatedLfeProps&, ALenum param, int)
  64. { throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param}; }
  65. void EffectHandler::SetParamiv(DedicatedLfeProps&, ALenum param, const int*)
  66. {
  67. throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x",
  68. param};
  69. }
  70. void EffectHandler::SetParamf(DedicatedLfeProps &props, ALenum param, float val)
  71. {
  72. switch(param)
  73. {
  74. case AL_DEDICATED_GAIN:
  75. if(!(val >= 0.0f && std::isfinite(val)))
  76. throw effect_exception{AL_INVALID_VALUE, "Dedicated gain out of range"};
  77. props.Gain = val;
  78. break;
  79. default:
  80. throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param};
  81. }
  82. }
  83. void EffectHandler::SetParamfv(DedicatedLfeProps &props, ALenum param, const float *vals)
  84. { SetParamf(props, param, *vals); }
  85. void EffectHandler::GetParami(const DedicatedLfeProps&, ALenum param, int*)
  86. { throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param}; }
  87. void EffectHandler::GetParamiv(const DedicatedLfeProps&, ALenum param, int*)
  88. {
  89. throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x",
  90. param};
  91. }
  92. void EffectHandler::GetParamf(const DedicatedLfeProps &props, ALenum param, float *val)
  93. {
  94. switch(param)
  95. {
  96. case AL_DEDICATED_GAIN: *val = props.Gain; break;
  97. default:
  98. throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param};
  99. }
  100. }
  101. void EffectHandler::GetParamfv(const DedicatedLfeProps &props, ALenum param, float *vals)
  102. { GetParamf(props, param, vals); }