10 #include "alc/inprogext.h"
11 #include "alnumeric.h"
13 #include "core/effects/base.h"
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
};
29 const EffectProps ConvolutionEffectProps
{genDefaultProps()};
31 void ConvolutionEffectHandler::SetParami(ConvolutionProps
& /*props*/, ALenum param
, int /*val*/)
36 throw effect_exception
{AL_INVALID_ENUM
, "Invalid convolution effect integer property 0x%04x",
40 void ConvolutionEffectHandler::SetParamiv(ConvolutionProps
&props
, ALenum param
, const int *vals
)
45 SetParami(props
, param
, *vals
);
48 void ConvolutionEffectHandler::SetParamf(ConvolutionProps
& /*props*/, ALenum param
, float /*val*/)
53 throw effect_exception
{AL_INVALID_ENUM
, "Invalid convolution effect float property 0x%04x",
57 void ConvolutionEffectHandler::SetParamfv(ConvolutionProps
&props
, ALenum param
, const float *values
)
59 static constexpr auto finite_checker
= [](float val
) -> bool { return std::isfinite(val
); };
60 al::span
<const float> vals
;
63 case AL_CONVOLUTION_ORIENTATION_SOFT
:
64 vals
= {values
, 6_uz
};
65 if(!std::all_of(vals
.cbegin(), vals
.cend(), finite_checker
))
66 throw effect_exception
{AL_INVALID_VALUE
, "Property 0x%04x value out of range", param
};
68 std::copy_n(vals
.cbegin(), props
.OrientAt
.size(), props
.OrientAt
.begin());
69 std::copy_n(vals
.cbegin()+3, props
.OrientUp
.size(), props
.OrientUp
.begin());
73 SetParamf(props
, param
, *values
);
77 void ConvolutionEffectHandler::GetParami(const ConvolutionProps
& /*props*/, ALenum param
, int* /*val*/)
82 throw effect_exception
{AL_INVALID_ENUM
, "Invalid convolution effect integer property 0x%04x",
86 void ConvolutionEffectHandler::GetParamiv(const ConvolutionProps
&props
, ALenum param
, int *vals
)
91 GetParami(props
, param
, vals
);
94 void ConvolutionEffectHandler::GetParamf(const ConvolutionProps
& /*props*/, ALenum param
, float* /*val*/)
99 throw effect_exception
{AL_INVALID_ENUM
, "Invalid convolution effect float property 0x%04x",
103 void ConvolutionEffectHandler::GetParamfv(const ConvolutionProps
&props
, ALenum param
, float *values
)
105 al::span
<float> vals
;
108 case AL_CONVOLUTION_ORIENTATION_SOFT
:
109 vals
= {values
, 6_uz
};
110 std::copy(props
.OrientAt
.cbegin(), props
.OrientAt
.cend(), vals
.begin());
111 std::copy(props
.OrientUp
.cbegin(), props
.OrientUp
.cend(), vals
.begin()+3);
115 GetParamf(props
, param
, values
);