2021-01-26 19:01:35 +00:00
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2024-06-30 19:35:57 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
#include <array>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
2021-01-26 19:01:35 +00:00
|
|
|
#include "AL/al.h"
|
|
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
#include "alc/context.h"
|
2024-06-30 19:35:57 +00:00
|
|
|
#include "alc/inprogext.h"
|
|
|
|
|
#include "alnumeric.h"
|
|
|
|
|
#include "alspan.h"
|
2021-01-26 19:01:35 +00:00
|
|
|
#include "effects.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2024-06-30 19:35:57 +00:00
|
|
|
constexpr EffectProps genDefaultProps() noexcept
|
|
|
|
|
{
|
|
|
|
|
ConvolutionProps props{};
|
|
|
|
|
props.OrientAt = {0.0f, 0.0f, -1.0f};
|
|
|
|
|
props.OrientUp = {0.0f, 1.0f, 0.0f};
|
|
|
|
|
return props;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
const EffectProps ConvolutionEffectProps{genDefaultProps()};
|
|
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
void ConvolutionEffectHandler::SetParami(ALCcontext *context, ConvolutionProps& /*props*/, ALenum param, int /*val*/)
|
|
|
|
|
{ context->throw_error(AL_INVALID_ENUM, "Invalid convolution effect integer property {:#04x}", as_unsigned(param)); }
|
|
|
|
|
void ConvolutionEffectHandler::SetParamiv(ALCcontext *context, ConvolutionProps &props, ALenum param, const int *vals)
|
|
|
|
|
{ SetParami(context, props, param, *vals); }
|
|
|
|
|
|
|
|
|
|
void ConvolutionEffectHandler::SetParamf(ALCcontext *context, ConvolutionProps& /*props*/, ALenum param, float /*val*/)
|
|
|
|
|
{ context->throw_error(AL_INVALID_ENUM, "Invalid convolution effect float property {:#04x}", as_unsigned(param)); }
|
|
|
|
|
void ConvolutionEffectHandler::SetParamfv(ALCcontext *context, ConvolutionProps &props, ALenum param, const float *values)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
2024-06-30 19:35:57 +00:00
|
|
|
static constexpr auto finite_checker = [](float val) -> bool { return std::isfinite(val); };
|
2025-09-03 16:09:27 +00:00
|
|
|
|
2021-01-26 19:01:35 +00:00
|
|
|
switch(param)
|
|
|
|
|
{
|
2024-06-30 19:35:57 +00:00
|
|
|
case AL_CONVOLUTION_ORIENTATION_SOFT:
|
2025-09-03 16:09:27 +00:00
|
|
|
auto vals = al::span{values, 6_uz};
|
2024-06-30 19:35:57 +00:00
|
|
|
if(!std::all_of(vals.cbegin(), vals.cend(), finite_checker))
|
2025-09-03 16:09:27 +00:00
|
|
|
context->throw_error(AL_INVALID_VALUE, "Convolution orientation out of range", param);
|
2024-06-30 19:35:57 +00:00
|
|
|
|
|
|
|
|
std::copy_n(vals.cbegin(), props.OrientAt.size(), props.OrientAt.begin());
|
|
|
|
|
std::copy_n(vals.cbegin()+3, props.OrientUp.size(), props.OrientUp.begin());
|
2025-09-03 16:09:27 +00:00
|
|
|
return;
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-03 16:09:27 +00:00
|
|
|
SetParamf(context, props, param, *values);
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
2025-09-03 16:09:27 +00:00
|
|
|
|
|
|
|
|
void ConvolutionEffectHandler::GetParami(ALCcontext *context, const ConvolutionProps& /*props*/, ALenum param, int* /*val*/)
|
|
|
|
|
{ context->throw_error(AL_INVALID_ENUM, "Invalid convolution effect integer property {:#04x}", as_unsigned(param)); }
|
|
|
|
|
void ConvolutionEffectHandler::GetParamiv(ALCcontext *context, const ConvolutionProps &props, ALenum param, int *vals)
|
|
|
|
|
{ GetParami(context, props, param, vals); }
|
|
|
|
|
|
|
|
|
|
void ConvolutionEffectHandler::GetParamf(ALCcontext *context, const ConvolutionProps& /*props*/, ALenum param, float* /*val*/)
|
|
|
|
|
{ context->throw_error(AL_INVALID_ENUM, "Invalid convolution effect float property {:#04x}", as_unsigned(param)); }
|
|
|
|
|
void ConvolutionEffectHandler::GetParamfv(ALCcontext *context, const ConvolutionProps &props, ALenum param, float *values)
|
2021-01-26 19:01:35 +00:00
|
|
|
{
|
|
|
|
|
switch(param)
|
|
|
|
|
{
|
2024-06-30 19:35:57 +00:00
|
|
|
case AL_CONVOLUTION_ORIENTATION_SOFT:
|
2025-09-03 16:09:27 +00:00
|
|
|
auto vals = al::span{values, 6_uz};
|
2024-06-30 19:35:57 +00:00
|
|
|
std::copy(props.OrientAt.cbegin(), props.OrientAt.cend(), vals.begin());
|
|
|
|
|
std::copy(props.OrientUp.cbegin(), props.OrientUp.cend(), vals.begin()+3);
|
2025-09-03 16:09:27 +00:00
|
|
|
return;
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|
2025-09-03 16:09:27 +00:00
|
|
|
|
|
|
|
|
GetParamf(context, props, param, values);
|
2021-01-26 19:01:35 +00:00
|
|
|
}
|