From a4d357de06b3860f49f2f6f70899d825b920947b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 27 Aug 2017 10:16:36 -0700 Subject: Add a higher quality bsinc resampler using 24 sample points This improves the transition width, allowing more of the higher frequencies remain audible. It would be preferrable to have an upper limit of 32 points instead of 48, to reduce the overall table size and the CPU cost for down- sampling. --- OpenAL32/Include/alu.h | 15 ++++++++++----- OpenAL32/alState.c | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index e5fd8b09..b322995b 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -24,16 +24,17 @@ #define MAX_PITCH (255) /* Maximum number of buffer samples before the current pos needed for resampling. */ -#define MAX_PRE_SAMPLES 12 +#define MAX_PRE_SAMPLES 24 /* Maximum number of buffer samples after the current pos needed for resampling. */ -#define MAX_POST_SAMPLES 12 +#define MAX_POST_SAMPLES 24 #ifdef __cplusplus extern "C" { #endif +struct BSincTable; struct ALsource; struct ALbufferlistitem; struct ALvoice; @@ -54,8 +55,9 @@ enum Resampler { LinearResampler, FIR4Resampler, BSinc12Resampler, + BSinc24Resampler, - ResamplerMax = BSinc12Resampler + ResamplerMax = BSinc24Resampler }; extern enum Resampler ResamplerDefault; @@ -91,13 +93,16 @@ typedef union InterpState { Sinc4State sinc4; } InterpState; -ALboolean BsincPrepare(const ALuint increment, BsincState *state); - typedef const ALfloat* (*ResamplerFunc)(const InterpState *state, const ALfloat *restrict src, ALsizei frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen ); +ALboolean BsincPrepare(const ALuint increment, BsincState *state, const struct BSincTable *table); + +extern const struct BSincTable bsinc12; +extern const struct BSincTable bsinc24; + typedef union aluVector { alignas(16) ALfloat v[4]; diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index 19b0996c..f71f0eac 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -52,6 +52,7 @@ static const ALchar alPointResampler[] = "Nearest"; static const ALchar alLinearResampler[] = "Linear"; static const ALchar alSinc4Resampler[] = "4-Point Sinc"; static const ALchar alBSinc12Resampler[] = "Band-limited Sinc (12/24)"; +static const ALchar alBSinc24Resampler[] = "Band-limited Sinc (24/48)"; AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) { @@ -751,6 +752,7 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index) const char *ResamplerNames[] = { alPointResampler, alLinearResampler, alSinc4Resampler, alBSinc12Resampler, + alBSinc24Resampler, }; const ALchar *value = NULL; ALCcontext *context; -- cgit v1.2.3