dedicated.cpp 4.1 KB

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