Simplify post-mix HRTF gain storage
This commit is contained in:
parent
05abcbc600
commit
54b49594e6
@ -42,10 +42,10 @@ void MixRow_(const al::span<float> OutBuffer, const al::span<const float> Gains,
|
||||
|
||||
template<InstSetType InstTag>
|
||||
void MixHrtf_(const float *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
MixHrtfFilter *hrtfparams, const size_t BufferSize);
|
||||
const MixHrtfFilter *hrtfparams, const size_t BufferSize);
|
||||
template<InstSetType InstTag>
|
||||
void MixHrtfBlend_(const float *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize);
|
||||
const HrtfFilter *oldparams, const MixHrtfFilter *newparams, const size_t BufferSize);
|
||||
template<InstSetType InstTag>
|
||||
void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State,
|
||||
|
@ -14,7 +14,7 @@ using ApplyCoeffsT = void(&)(float2 *RESTRICT Values, const ALuint irSize, const
|
||||
|
||||
template<ApplyCoeffsT ApplyCoeffs>
|
||||
inline void MixHrtfBase(const float *InSamples, float2 *RESTRICT AccumSamples, const ALuint IrSize,
|
||||
MixHrtfFilter *hrtfparams, const size_t BufferSize)
|
||||
const MixHrtfFilter *hrtfparams, const size_t BufferSize)
|
||||
{
|
||||
ASSUME(BufferSize > 0);
|
||||
|
||||
@ -35,13 +35,11 @@ inline void MixHrtfBase(const float *InSamples, float2 *RESTRICT AccumSamples, c
|
||||
|
||||
stepcount += 1.0f;
|
||||
}
|
||||
|
||||
hrtfparams->Gain = gain + gainstep*stepcount;
|
||||
}
|
||||
|
||||
template<ApplyCoeffsT ApplyCoeffs>
|
||||
inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSamples,
|
||||
const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams,
|
||||
const ALuint IrSize, const HrtfFilter *oldparams, const MixHrtfFilter *newparams,
|
||||
const size_t BufferSize)
|
||||
{
|
||||
const auto &OldCoeffs = oldparams->Coeffs;
|
||||
@ -78,8 +76,6 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl
|
||||
|
||||
stepcount += 1.0f;
|
||||
}
|
||||
|
||||
newparams->Gain = newGainStep*stepcount;
|
||||
}
|
||||
|
||||
template<ApplyCoeffsT ApplyCoeffs>
|
||||
|
@ -137,12 +137,12 @@ const ALfloat *Resample_<FastBSincTag,CTag>(const InterpState *state, const ALfl
|
||||
|
||||
template<>
|
||||
void MixHrtf_<CTag>(const float *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
MixHrtfFilter *hrtfparams, const size_t BufferSize)
|
||||
const MixHrtfFilter *hrtfparams, const size_t BufferSize)
|
||||
{ MixHrtfBase<ApplyCoeffs>(InSamples, AccumSamples, IrSize, hrtfparams, BufferSize); }
|
||||
|
||||
template<>
|
||||
void MixHrtfBlend_<CTag>(const float *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize)
|
||||
const HrtfFilter *oldparams, const MixHrtfFilter *newparams, const size_t BufferSize)
|
||||
{
|
||||
MixHrtfBlendBase<ApplyCoeffs>(InSamples, AccumSamples, IrSize, oldparams, newparams,
|
||||
BufferSize);
|
||||
|
@ -191,12 +191,12 @@ const ALfloat *Resample_<FastBSincTag,NEONTag>(const InterpState *state,
|
||||
|
||||
template<>
|
||||
void MixHrtf_<NEONTag>(const float *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
MixHrtfFilter *hrtfparams, const size_t BufferSize)
|
||||
const MixHrtfFilter *hrtfparams, const size_t BufferSize)
|
||||
{ MixHrtfBase<ApplyCoeffs>(InSamples, AccumSamples, IrSize, hrtfparams, BufferSize); }
|
||||
|
||||
template<>
|
||||
void MixHrtfBlend_<NEONTag>(const float *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize)
|
||||
const HrtfFilter *oldparams, const MixHrtfFilter *newparams, const size_t BufferSize)
|
||||
{
|
||||
MixHrtfBlendBase<ApplyCoeffs>(InSamples, AccumSamples, IrSize, oldparams, newparams,
|
||||
BufferSize);
|
||||
|
@ -167,12 +167,12 @@ const ALfloat *Resample_<FastBSincTag,SSETag>(const InterpState *state,
|
||||
|
||||
template<>
|
||||
void MixHrtf_<SSETag>(const float *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
MixHrtfFilter *hrtfparams, const size_t BufferSize)
|
||||
const MixHrtfFilter *hrtfparams, const size_t BufferSize)
|
||||
{ MixHrtfBase<ApplyCoeffs>(InSamples, AccumSamples, IrSize, hrtfparams, BufferSize); }
|
||||
|
||||
template<>
|
||||
void MixHrtfBlend_<SSETag>(const float *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize)
|
||||
const HrtfFilter *oldparams, const MixHrtfFilter *newparams, const size_t BufferSize)
|
||||
{
|
||||
MixHrtfBlendBase<ApplyCoeffs>(InSamples, AccumSamples, IrSize, oldparams, newparams,
|
||||
BufferSize);
|
||||
|
@ -73,9 +73,9 @@ Resampler ResamplerDefault{Resampler::Linear};
|
||||
namespace {
|
||||
|
||||
using HrtfMixerFunc = void(*)(const ALfloat *InSamples, float2 *AccumSamples, const ALuint IrSize,
|
||||
MixHrtfFilter *hrtfparams, const size_t BufferSize);
|
||||
const MixHrtfFilter *hrtfparams, const size_t BufferSize);
|
||||
using HrtfMixerBlendFunc = void(*)(const ALfloat *InSamples, float2 *AccumSamples,
|
||||
const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams,
|
||||
const ALuint IrSize, const HrtfFilter *oldparams, const MixHrtfFilter *newparams,
|
||||
const size_t BufferSize);
|
||||
|
||||
HrtfMixerFunc MixHrtfSamples = MixHrtf_<CTag>;
|
||||
@ -468,10 +468,7 @@ void DoHrtfMix(const float *samples, const ALuint DstBufferSize, DirectParams &p
|
||||
fademix);
|
||||
/* Update the old parameters with the result. */
|
||||
parms.Hrtf.Old = parms.Hrtf.Target;
|
||||
if(fademix < Counter)
|
||||
parms.Hrtf.Old.Gain = hrtfparams.Gain;
|
||||
else
|
||||
parms.Hrtf.Old.Gain = TargetGain;
|
||||
parms.Hrtf.Old.Gain = gain;
|
||||
OutPos += fademix;
|
||||
}
|
||||
|
||||
@ -496,13 +493,8 @@ void DoHrtfMix(const float *samples, const ALuint DstBufferSize, DirectParams &p
|
||||
hrtfparams.Gain = parms.Hrtf.Old.Gain;
|
||||
hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) / static_cast<float>(todo);
|
||||
MixHrtfSamples(HrtfSamples+fademix, AccumSamples+OutPos, IrSize, &hrtfparams, todo);
|
||||
/* Store the interpolated gain or the final target gain depending if
|
||||
* the fade is done.
|
||||
*/
|
||||
if(DstBufferSize < Counter)
|
||||
parms.Hrtf.Old.Gain = gain;
|
||||
else
|
||||
parms.Hrtf.Old.Gain = TargetGain;
|
||||
/* Store the now-current gain for next time. */
|
||||
parms.Hrtf.Old.Gain = gain;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user