mirror of
https://github.com/love2d/megasource.git
synced 2026-08-17 19:24:09 +02:00
update OpenAL-Soft to 1.24.3.
This commit is contained in:
@@ -7,13 +7,13 @@
|
||||
#include "AL/al.h"
|
||||
#include "AL/efx.h"
|
||||
|
||||
#include "alc/effects/base.h"
|
||||
#include "alc/context.h"
|
||||
#include "alnumeric.h"
|
||||
#include "core/logging.h"
|
||||
#include "effects.h"
|
||||
|
||||
#ifdef ALSOFT_EAX
|
||||
#if ALSOFT_EAX
|
||||
#include <cassert>
|
||||
#include "alnumeric.h"
|
||||
#include "al/eax/effect.h"
|
||||
#include "al/eax/exception.h"
|
||||
#include "al/eax/utils.h"
|
||||
@@ -44,7 +44,8 @@ constexpr ALenum EnumFromWaveform(ChorusWaveform type)
|
||||
case ChorusWaveform::Sinusoid: return AL_CHORUS_WAVEFORM_SINUSOID;
|
||||
case ChorusWaveform::Triangle: return AL_CHORUS_WAVEFORM_TRIANGLE;
|
||||
}
|
||||
throw std::runtime_error{"Invalid chorus waveform: "+std::to_string(static_cast<int>(type))};
|
||||
throw std::runtime_error{fmt::format("Invalid chorus waveform: {}",
|
||||
int{al::to_underlying(type)})};
|
||||
}
|
||||
|
||||
constexpr EffectProps genDefaultChorusProps() noexcept
|
||||
@@ -61,7 +62,7 @@ constexpr EffectProps genDefaultChorusProps() noexcept
|
||||
|
||||
constexpr EffectProps genDefaultFlangerProps() noexcept
|
||||
{
|
||||
FlangerProps props{};
|
||||
ChorusProps props{};
|
||||
props.Waveform = WaveformFromEnum(AL_FLANGER_DEFAULT_WAVEFORM).value();
|
||||
props.Phase = AL_FLANGER_DEFAULT_PHASE;
|
||||
props.Rate = AL_FLANGER_DEFAULT_RATE;
|
||||
@@ -75,7 +76,7 @@ constexpr EffectProps genDefaultFlangerProps() noexcept
|
||||
|
||||
const EffectProps ChorusEffectProps{genDefaultChorusProps()};
|
||||
|
||||
void EffectHandler::SetParami(ChorusProps &props, ALenum param, int val)
|
||||
void ChorusEffectHandler::SetParami(ALCcontext *context, ChorusProps &props, ALenum param, int val)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
@@ -83,89 +84,90 @@ void EffectHandler::SetParami(ChorusProps &props, ALenum param, int val)
|
||||
if(auto formopt = WaveformFromEnum(val))
|
||||
props.Waveform = *formopt;
|
||||
else
|
||||
throw effect_exception{AL_INVALID_VALUE, "Invalid chorus waveform: 0x%04x", val};
|
||||
break;
|
||||
context->throw_error(AL_INVALID_VALUE, "Invalid chorus waveform: {:#04x}",
|
||||
as_unsigned(val));
|
||||
return;
|
||||
|
||||
case AL_CHORUS_PHASE:
|
||||
if(!(val >= AL_CHORUS_MIN_PHASE && val <= AL_CHORUS_MAX_PHASE))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Chorus phase out of range: %d", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Chorus phase out of range: {}", val);
|
||||
props.Phase = val;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw effect_exception{AL_INVALID_ENUM, "Invalid chorus integer property 0x%04x", param};
|
||||
return;
|
||||
}
|
||||
|
||||
context->throw_error(AL_INVALID_ENUM, "Invalid chorus integer property {:#04x}",
|
||||
as_unsigned(param));
|
||||
}
|
||||
void EffectHandler::SetParamiv(ChorusProps &props, ALenum param, const int *vals)
|
||||
{ SetParami(props, param, *vals); }
|
||||
void EffectHandler::SetParamf(ChorusProps &props, ALenum param, float val)
|
||||
void ChorusEffectHandler::SetParamiv(ALCcontext *context, ChorusProps &props, ALenum param, const int *vals)
|
||||
{ SetParami(context, props, param, *vals); }
|
||||
void ChorusEffectHandler::SetParamf(ALCcontext *context, ChorusProps &props, ALenum param, float val)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_CHORUS_RATE:
|
||||
if(!(val >= AL_CHORUS_MIN_RATE && val <= AL_CHORUS_MAX_RATE))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Chorus rate out of range: %f", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Chorus rate out of range: {:f}", val);
|
||||
props.Rate = val;
|
||||
break;
|
||||
return;
|
||||
|
||||
case AL_CHORUS_DEPTH:
|
||||
if(!(val >= AL_CHORUS_MIN_DEPTH && val <= AL_CHORUS_MAX_DEPTH))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Chorus depth out of range: %f", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Chorus depth out of range: {:f}", val);
|
||||
props.Depth = val;
|
||||
break;
|
||||
return;
|
||||
|
||||
case AL_CHORUS_FEEDBACK:
|
||||
if(!(val >= AL_CHORUS_MIN_FEEDBACK && val <= AL_CHORUS_MAX_FEEDBACK))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Chorus feedback out of range: %f", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Chorus feedback out of range: {:f}", val);
|
||||
props.Feedback = val;
|
||||
break;
|
||||
return;
|
||||
|
||||
case AL_CHORUS_DELAY:
|
||||
if(!(val >= AL_CHORUS_MIN_DELAY && val <= AL_CHORUS_MAX_DELAY))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Chorus delay out of range: %f", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Chorus delay out of range: {:f}", val);
|
||||
props.Delay = val;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw effect_exception{AL_INVALID_ENUM, "Invalid chorus float property 0x%04x", param};
|
||||
return;
|
||||
}
|
||||
}
|
||||
void EffectHandler::SetParamfv(ChorusProps &props, ALenum param, const float *vals)
|
||||
{ SetParamf(props, param, *vals); }
|
||||
|
||||
void EffectHandler::GetParami(const ChorusProps &props, ALenum param, int *val)
|
||||
context->throw_error(AL_INVALID_ENUM, "Invalid chorus float property {:#04x}",
|
||||
as_unsigned(param));
|
||||
}
|
||||
void ChorusEffectHandler::SetParamfv(ALCcontext *context, ChorusProps &props, ALenum param, const float *vals)
|
||||
{ SetParamf(context, props, param, *vals); }
|
||||
|
||||
void ChorusEffectHandler::GetParami(ALCcontext *context, const ChorusProps &props, ALenum param, int *val)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_CHORUS_WAVEFORM: *val = EnumFromWaveform(props.Waveform); break;
|
||||
case AL_CHORUS_PHASE: *val = props.Phase; break;
|
||||
|
||||
default:
|
||||
throw effect_exception{AL_INVALID_ENUM, "Invalid chorus integer property 0x%04x", param};
|
||||
case AL_CHORUS_WAVEFORM: *val = EnumFromWaveform(props.Waveform); return;
|
||||
case AL_CHORUS_PHASE: *val = props.Phase; return;
|
||||
}
|
||||
|
||||
context->throw_error(AL_INVALID_ENUM, "Invalid chorus integer property {:#04x}",
|
||||
as_unsigned(param));
|
||||
}
|
||||
void EffectHandler::GetParamiv(const ChorusProps &props, ALenum param, int *vals)
|
||||
{ GetParami(props, param, vals); }
|
||||
void EffectHandler::GetParamf(const ChorusProps &props, ALenum param, float *val)
|
||||
void ChorusEffectHandler::GetParamiv(ALCcontext *context, const ChorusProps &props, ALenum param, int *vals)
|
||||
{ GetParami(context, props, param, vals); }
|
||||
void ChorusEffectHandler::GetParamf(ALCcontext *context, const ChorusProps &props, ALenum param, float *val)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_CHORUS_RATE: *val = props.Rate; break;
|
||||
case AL_CHORUS_DEPTH: *val = props.Depth; break;
|
||||
case AL_CHORUS_FEEDBACK: *val = props.Feedback; break;
|
||||
case AL_CHORUS_DELAY: *val = props.Delay; break;
|
||||
|
||||
default:
|
||||
throw effect_exception{AL_INVALID_ENUM, "Invalid chorus float property 0x%04x", param};
|
||||
case AL_CHORUS_RATE: *val = props.Rate; return;
|
||||
case AL_CHORUS_DEPTH: *val = props.Depth; return;
|
||||
case AL_CHORUS_FEEDBACK: *val = props.Feedback; return;
|
||||
case AL_CHORUS_DELAY: *val = props.Delay; return;
|
||||
}
|
||||
|
||||
context->throw_error(AL_INVALID_ENUM, "Invalid chorus float property {:#04x}",
|
||||
as_unsigned(param));
|
||||
}
|
||||
void EffectHandler::GetParamfv(const ChorusProps &props, ALenum param, float *vals)
|
||||
{ GetParamf(props, param, vals); }
|
||||
void ChorusEffectHandler::GetParamfv(ALCcontext *context, const ChorusProps &props, ALenum param, float *vals)
|
||||
{ GetParamf(context, props, param, vals); }
|
||||
|
||||
|
||||
const EffectProps FlangerEffectProps{genDefaultFlangerProps()};
|
||||
|
||||
void EffectHandler::SetParami(FlangerProps &props, ALenum param, int val)
|
||||
void FlangerEffectHandler::SetParami(ALCcontext *context, ChorusProps &props, ALenum param, int val)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
@@ -173,93 +175,93 @@ void EffectHandler::SetParami(FlangerProps &props, ALenum param, int val)
|
||||
if(auto formopt = WaveformFromEnum(val))
|
||||
props.Waveform = *formopt;
|
||||
else
|
||||
throw effect_exception{AL_INVALID_VALUE, "Invalid flanger waveform: 0x%04x", val};
|
||||
break;
|
||||
context->throw_error(AL_INVALID_VALUE, "Invalid flanger waveform: {:#04x}",
|
||||
as_unsigned(val));
|
||||
return;
|
||||
|
||||
case AL_FLANGER_PHASE:
|
||||
if(!(val >= AL_FLANGER_MIN_PHASE && val <= AL_FLANGER_MAX_PHASE))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Flanger phase out of range: %d", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Flanger phase out of range: {}", val);
|
||||
props.Phase = val;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw effect_exception{AL_INVALID_ENUM, "Invalid flanger integer property 0x%04x", param};
|
||||
return;
|
||||
}
|
||||
|
||||
context->throw_error(AL_INVALID_ENUM, "Invalid flanger integer property {:#04x}",
|
||||
as_unsigned(param));
|
||||
}
|
||||
void EffectHandler::SetParamiv(FlangerProps &props, ALenum param, const int *vals)
|
||||
{ SetParami(props, param, *vals); }
|
||||
void EffectHandler::SetParamf(FlangerProps &props, ALenum param, float val)
|
||||
void FlangerEffectHandler::SetParamiv(ALCcontext *context, ChorusProps &props, ALenum param, const int *vals)
|
||||
{ SetParami(context, props, param, *vals); }
|
||||
void FlangerEffectHandler::SetParamf(ALCcontext *context, ChorusProps &props, ALenum param, float val)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_FLANGER_RATE:
|
||||
if(!(val >= AL_FLANGER_MIN_RATE && val <= AL_FLANGER_MAX_RATE))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Flanger rate out of range: %f", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Flanger rate out of range: {:f}", val);
|
||||
props.Rate = val;
|
||||
break;
|
||||
return;
|
||||
|
||||
case AL_FLANGER_DEPTH:
|
||||
if(!(val >= AL_FLANGER_MIN_DEPTH && val <= AL_FLANGER_MAX_DEPTH))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Flanger depth out of range: %f", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Flanger depth out of range: {:f}", val);
|
||||
props.Depth = val;
|
||||
break;
|
||||
return;
|
||||
|
||||
case AL_FLANGER_FEEDBACK:
|
||||
if(!(val >= AL_FLANGER_MIN_FEEDBACK && val <= AL_FLANGER_MAX_FEEDBACK))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Flanger feedback out of range: %f", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Flanger feedback out of range: {:f}", val);
|
||||
props.Feedback = val;
|
||||
break;
|
||||
return;
|
||||
|
||||
case AL_FLANGER_DELAY:
|
||||
if(!(val >= AL_FLANGER_MIN_DELAY && val <= AL_FLANGER_MAX_DELAY))
|
||||
throw effect_exception{AL_INVALID_VALUE, "Flanger delay out of range: %f", val};
|
||||
context->throw_error(AL_INVALID_VALUE, "Flanger delay out of range: {:f}", val);
|
||||
props.Delay = val;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw effect_exception{AL_INVALID_ENUM, "Invalid flanger float property 0x%04x", param};
|
||||
return;
|
||||
}
|
||||
}
|
||||
void EffectHandler::SetParamfv(FlangerProps &props, ALenum param, const float *vals)
|
||||
{ SetParamf(props, param, *vals); }
|
||||
|
||||
void EffectHandler::GetParami(const FlangerProps &props, ALenum param, int *val)
|
||||
context->throw_error(AL_INVALID_ENUM, "Invalid flanger float property {:#04x}",
|
||||
as_unsigned(param));
|
||||
}
|
||||
void FlangerEffectHandler::SetParamfv(ALCcontext *context, ChorusProps &props, ALenum param, const float *vals)
|
||||
{ SetParamf(context, props, param, *vals); }
|
||||
|
||||
void FlangerEffectHandler::GetParami(ALCcontext *context, const ChorusProps &props, ALenum param, int *val)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_FLANGER_WAVEFORM: *val = EnumFromWaveform(props.Waveform); break;
|
||||
case AL_FLANGER_PHASE: *val = props.Phase; break;
|
||||
|
||||
default:
|
||||
throw effect_exception{AL_INVALID_ENUM, "Invalid flanger integer property 0x%04x", param};
|
||||
case AL_FLANGER_WAVEFORM: *val = EnumFromWaveform(props.Waveform); return;
|
||||
case AL_FLANGER_PHASE: *val = props.Phase; return;
|
||||
}
|
||||
|
||||
context->throw_error(AL_INVALID_ENUM, "Invalid flanger integer property {:#04x}",
|
||||
as_unsigned(param));
|
||||
}
|
||||
void EffectHandler::GetParamiv(const FlangerProps &props, ALenum param, int *vals)
|
||||
{ GetParami(props, param, vals); }
|
||||
void EffectHandler::GetParamf(const FlangerProps &props, ALenum param, float *val)
|
||||
void FlangerEffectHandler::GetParamiv(ALCcontext *context, const ChorusProps &props, ALenum param, int *vals)
|
||||
{ GetParami(context, props, param, vals); }
|
||||
void FlangerEffectHandler::GetParamf(ALCcontext *context, const ChorusProps &props, ALenum param, float *val)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_FLANGER_RATE: *val = props.Rate; break;
|
||||
case AL_FLANGER_DEPTH: *val = props.Depth; break;
|
||||
case AL_FLANGER_FEEDBACK: *val = props.Feedback; break;
|
||||
case AL_FLANGER_DELAY: *val = props.Delay; break;
|
||||
|
||||
default:
|
||||
throw effect_exception{AL_INVALID_ENUM, "Invalid flanger float property 0x%04x", param};
|
||||
case AL_FLANGER_RATE: *val = props.Rate; return;
|
||||
case AL_FLANGER_DEPTH: *val = props.Depth; return;
|
||||
case AL_FLANGER_FEEDBACK: *val = props.Feedback; return;
|
||||
case AL_FLANGER_DELAY: *val = props.Delay; return;
|
||||
}
|
||||
|
||||
context->throw_error(AL_INVALID_ENUM, "Invalid flanger float property {:#04x}",
|
||||
as_unsigned(param));
|
||||
}
|
||||
void EffectHandler::GetParamfv(const FlangerProps &props, ALenum param, float *vals)
|
||||
{ GetParamf(props, param, vals); }
|
||||
void FlangerEffectHandler::GetParamfv(ALCcontext *context, const ChorusProps &props, ALenum param, float *vals)
|
||||
{ GetParamf(context, props, param, vals); }
|
||||
|
||||
|
||||
#ifdef ALSOFT_EAX
|
||||
#if ALSOFT_EAX
|
||||
namespace {
|
||||
|
||||
struct EaxChorusTraits {
|
||||
using EaxProps = EAXCHORUSPROPERTIES;
|
||||
using Committer = EaxChorusCommitter;
|
||||
using AlProps = ChorusProps;
|
||||
|
||||
static constexpr auto efx_effect() { return AL_EFFECT_CHORUS; }
|
||||
|
||||
@@ -325,7 +327,6 @@ struct EaxChorusTraits {
|
||||
struct EaxFlangerTraits {
|
||||
using EaxProps = EAXFLANGERPROPERTIES;
|
||||
using Committer = EaxFlangerCommitter;
|
||||
using AlProps = FlangerProps;
|
||||
|
||||
static constexpr auto efx_effect() { return AL_EFFECT_FLANGER; }
|
||||
|
||||
@@ -393,7 +394,6 @@ struct ChorusFlangerEffect {
|
||||
using Traits = TTraits;
|
||||
using EaxProps = typename Traits::EaxProps;
|
||||
using Committer = typename Traits::Committer;
|
||||
using AlProps = typename Traits::AlProps;
|
||||
using Exception = typename Committer::Exception;
|
||||
|
||||
struct WaveformValidator {
|
||||
@@ -551,7 +551,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static bool Commit(const EaxProps &props, EaxEffectProps &props_, AlProps &al_props_)
|
||||
static bool Commit(const EaxProps &props, EaxEffectProps &props_, ChorusProps &al_props_)
|
||||
{
|
||||
if(auto *cur = std::get_if<EaxProps>(&props_); cur && *cur == props)
|
||||
return false;
|
||||
@@ -564,6 +564,17 @@ public:
|
||||
al_props_.Depth = props.flDepth;
|
||||
al_props_.Feedback = props.flFeedback;
|
||||
al_props_.Delay = props.flDelay;
|
||||
if(EaxTraceCommits) UNLIKELY
|
||||
{
|
||||
TRACE("Chorus/flanger commit:\n"
|
||||
" Waveform: {}\n"
|
||||
" Phase: {}\n"
|
||||
" Rate: {:f}\n"
|
||||
" Depth: {:f}\n"
|
||||
" Feedback: {:f}\n"
|
||||
" Delay: {:f}", al::to_underlying(al_props_.Waveform), al_props_.Phase,
|
||||
al_props_.Rate, al_props_.Depth, al_props_.Feedback, al_props_.Delay);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -628,7 +639,7 @@ template<>
|
||||
bool EaxFlangerCommitter::commit(const EAXFLANGERPROPERTIES &props)
|
||||
{
|
||||
using Committer = ChorusFlangerEffect<EaxFlangerTraits>;
|
||||
return Committer::Commit(props, mEaxProps, mAlProps.emplace<FlangerProps>());
|
||||
return Committer::Commit(props, mEaxProps, mAlProps.emplace<ChorusProps>());
|
||||
}
|
||||
|
||||
void EaxFlangerCommitter::SetDefaults(EaxEffectProps &props)
|
||||
|
||||
Reference in New Issue
Block a user