10 #include "alc/context.h"
11 #include "alc/inprogext.h"
12 #include "alnumeric.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(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
); };
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());
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
)
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);
75 GetParamf(context
, props
, param
, values
);