dedicated.cpp 4.5 KB

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