Remove some unnecessary uses of mem_fn
[openal-soft.git] / al / effects / convolution.cpp
blob84de06c185376915ae85ae3cd73a397973e4121e
2 #include "config.h"
4 #include <algorithm>
5 #include <array>
6 #include <cmath>
8 #include "AL/al.h"
10 #include "alc/context.h"
11 #include "alc/inprogext.h"
12 #include "alnumeric.h"
13 #include "alspan.h"
14 #include "effects.h"
17 namespace {
19 constexpr EffectProps genDefaultProps() noexcept
21 ConvolutionProps props{};
22 props.OrientAt = {0.0f, 0.0f, -1.0f};
23 props.OrientUp = {0.0f, 1.0f, 0.0f};
24 return props;
27 } // namespace
29 const EffectProps ConvolutionEffectProps{genDefaultProps()};
31 void ConvolutionEffectHandler::SetParami(ALCcontext *context, ConvolutionProps& /*props*/, ALenum param, int /*val*/)
32 { context->throw_error(AL_INVALID_ENUM, "Invalid convolution effect integer property {:#04x}", as_unsigned(param)); }
33 void ConvolutionEffectHandler::SetParamiv(ALCcontext *context, ConvolutionProps &props, ALenum param, const int *vals)
34 { SetParami(context, props, param, *vals); }
36 void ConvolutionEffectHandler::SetParamf(ALCcontext *context, ConvolutionProps& /*props*/, ALenum param, float /*val*/)
37 { context->throw_error(AL_INVALID_ENUM, "Invalid convolution effect float property {:#04x}", as_unsigned(param)); }
38 void ConvolutionEffectHandler::SetParamfv(ALCcontext *context, ConvolutionProps &props, ALenum param, const float *values)
40 static constexpr auto finite_checker = [](float val) -> bool { return std::isfinite(val); };
42 switch(param)
44 case AL_CONVOLUTION_ORIENTATION_SOFT:
45 auto vals = al::span{values, 6_uz};
46 if(!std::all_of(vals.cbegin(), vals.cend(), finite_checker))
47 context->throw_error(AL_INVALID_VALUE, "Convolution orientation out of range", param);
49 std::copy_n(vals.cbegin(), props.OrientAt.size(), props.OrientAt.begin());
50 std::copy_n(vals.cbegin()+3, props.OrientUp.size(), props.OrientUp.begin());
51 return;
54 SetParamf(context, props, param, *values);
57 void ConvolutionEffectHandler::GetParami(ALCcontext *context, const ConvolutionProps& /*props*/, ALenum param, int* /*val*/)
58 { context->throw_error(AL_INVALID_ENUM, "Invalid convolution effect integer property {:#04x}", as_unsigned(param)); }
59 void ConvolutionEffectHandler::GetParamiv(ALCcontext *context, const ConvolutionProps &props, ALenum param, int *vals)
60 { GetParami(context, props, param, vals); }
62 void ConvolutionEffectHandler::GetParamf(ALCcontext *context, const ConvolutionProps& /*props*/, ALenum param, float* /*val*/)
63 { context->throw_error(AL_INVALID_ENUM, "Invalid convolution effect float property {:#04x}", as_unsigned(param)); }
64 void ConvolutionEffectHandler::GetParamfv(ALCcontext *context, const ConvolutionProps &props, ALenum param, float *values)
66 switch(param)
68 case AL_CONVOLUTION_ORIENTATION_SOFT:
69 auto vals = al::span{values, 6_uz};
70 std::copy(props.OrientAt.cbegin(), props.OrientAt.cend(), vals.begin());
71 std::copy(props.OrientUp.cbegin(), props.OrientUp.cend(), vals.begin()+3);
72 return;
75 GetParamf(context, props, param, values);