Use FloatBufferLine with the HRTF mixer functions
This commit is contained in:
parent
838e2bae80
commit
b923eb1879
@ -133,9 +133,8 @@ void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo)
|
||||
ASSUME(lidx >= 0 && ridx >= 0);
|
||||
|
||||
DirectHrtfState *state{device->mHrtfState.get()};
|
||||
MixDirectHrtf(device->RealOut.Buffer[lidx].data(), device->RealOut.Buffer[ridx].data(),
|
||||
&reinterpret_cast<float(&)[BUFFERSIZE]>(device->Dry.Buffer[0]), device->HrtfAccumData,
|
||||
state, device->Dry.NumChannels, SamplesToDo);
|
||||
MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx],
|
||||
device->Dry.Buffer, device->HrtfAccumData, state, device->Dry.NumChannels, SamplesToDo);
|
||||
}
|
||||
|
||||
void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo)
|
||||
|
@ -35,11 +35,11 @@ template<typename InstTag>
|
||||
void MixRow_(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*data)[BUFFERSIZE], const ALsizei InChans, const ALsizei InPos, const ALsizei BufferSize);
|
||||
|
||||
template<typename InstTag>
|
||||
void MixHrtf_(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize, MixHrtfParams *hrtfparams, const ALsizei BufferSize);
|
||||
void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, MixHrtfParams *hrtfparams, const ALsizei BufferSize);
|
||||
template<typename InstTag>
|
||||
void MixHrtfBlend_(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize, const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize);
|
||||
void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize);
|
||||
template<typename InstTag>
|
||||
void MixDirectHrtf_(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat (*data)[BUFFERSIZE], float2 *RESTRICT AccumSamples, DirectHrtfState *State, const ALsizei NumChans, const ALsizei BufferSize);
|
||||
void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const FloatBufferLine *InSamples, float2 *AccumSamples, DirectHrtfState *State, const ALsizei NumChans, const ALsizei BufferSize);
|
||||
|
||||
/* Vectorized resampler helpers */
|
||||
inline void InitiatePositionArrays(ALsizei frac, ALint increment, ALsizei *RESTRICT frac_arr, ALsizei *RESTRICT pos_arr, ALsizei size)
|
||||
|
@ -12,9 +12,9 @@ using ApplyCoeffsT = void(ALsizei Offset, float2 *RESTRICT Values, const ALsizei
|
||||
const HrirArray<ALfloat> &Coeffs, const ALfloat left, const ALfloat right);
|
||||
|
||||
template<ApplyCoeffsT &ApplyCoeffs>
|
||||
inline void MixHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
|
||||
float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
MixHrtfParams *hrtfparams, const ALsizei BufferSize)
|
||||
inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *RESTRICT AccumSamples, const ALsizei OutPos,
|
||||
const ALsizei IrSize, MixHrtfParams *hrtfparams, const ALsizei BufferSize)
|
||||
{
|
||||
ASSUME(OutPos >= 0);
|
||||
ASSUME(IrSize >= 4);
|
||||
@ -33,8 +33,8 @@ inline void MixHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, c
|
||||
for(ALsizei i{0};i < BufferSize;++i)
|
||||
{
|
||||
const ALfloat g{gain + gainstep*stepcount};
|
||||
const ALfloat left{data[Delay[0]++] * g};
|
||||
const ALfloat right{data[Delay[1]++] * g};
|
||||
const ALfloat left{InSamples[Delay[0]++] * g};
|
||||
const ALfloat right{InSamples[Delay[1]++] * g};
|
||||
ApplyCoeffs(i, AccumSamples+i, IrSize, Coeffs, left, right);
|
||||
|
||||
stepcount += 1.0f;
|
||||
@ -48,9 +48,10 @@ inline void MixHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, c
|
||||
}
|
||||
|
||||
template<ApplyCoeffsT &ApplyCoeffs>
|
||||
inline void MixHrtfBlendBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat *data, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize)
|
||||
inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *RESTRICT AccumSamples, const ALsizei OutPos,
|
||||
const ALsizei IrSize, const HrtfParams *oldparams, MixHrtfParams *newparams,
|
||||
const ALsizei BufferSize)
|
||||
{
|
||||
const auto &OldCoeffs = oldparams->Coeffs;
|
||||
const ALfloat oldGain{oldparams->Gain};
|
||||
@ -75,13 +76,13 @@ inline void MixHrtfBlendBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightO
|
||||
for(ALsizei i{0};i < BufferSize;++i)
|
||||
{
|
||||
ALfloat g{oldGain + oldGainStep*stepcount};
|
||||
ALfloat left{data[OldDelay[0]++] * g};
|
||||
ALfloat right{data[OldDelay[1]++] * g};
|
||||
ALfloat left{InSamples[OldDelay[0]++] * g};
|
||||
ALfloat right{InSamples[OldDelay[1]++] * g};
|
||||
ApplyCoeffs(i, AccumSamples+i, IrSize, OldCoeffs, left, right);
|
||||
|
||||
g = newGainStep*stepcount;
|
||||
left = data[NewDelay[0]++] * g;
|
||||
right = data[NewDelay[1]++] * g;
|
||||
left = InSamples[NewDelay[0]++] * g;
|
||||
right = InSamples[NewDelay[1]++] * g;
|
||||
ApplyCoeffs(i, AccumSamples+i, IrSize, NewCoeffs, left, right);
|
||||
|
||||
stepcount += 1.0f;
|
||||
@ -95,8 +96,8 @@ inline void MixHrtfBlendBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightO
|
||||
}
|
||||
|
||||
template<ApplyCoeffsT &ApplyCoeffs>
|
||||
inline void MixDirectHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat (*data)[BUFFERSIZE], float2 *RESTRICT AccumSamples, DirectHrtfState *State,
|
||||
inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const FloatBufferLine *InSamples, float2 *RESTRICT AccumSamples, DirectHrtfState *State,
|
||||
const ALsizei NumChans, const ALsizei BufferSize)
|
||||
{
|
||||
ASSUME(NumChans > 0);
|
||||
@ -107,7 +108,7 @@ inline void MixDirectHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT Right
|
||||
|
||||
for(ALsizei c{0};c < NumChans;++c)
|
||||
{
|
||||
const ALfloat (&input)[BUFFERSIZE] = data[c];
|
||||
const FloatBufferLine &input = InSamples[c];
|
||||
const auto &Coeffs = State->Chan[c].Coeffs;
|
||||
|
||||
auto accum_iter = std::copy_n(State->Chan[c].Values.begin(),
|
||||
|
@ -117,29 +117,29 @@ static inline void ApplyCoeffs(ALsizei /*Offset*/, float2 *RESTRICT Values, cons
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixHrtf_<CTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
|
||||
float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
void MixHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
MixHrtfParams *hrtfparams, const ALsizei BufferSize)
|
||||
{
|
||||
MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, OutPos, IrSize, hrtfparams,
|
||||
BufferSize);
|
||||
MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize,
|
||||
hrtfparams, BufferSize);
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixHrtfBlend_<CTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat *data, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
void MixHrtfBlend_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize)
|
||||
{
|
||||
MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, OutPos, IrSize, oldparams,
|
||||
newparams, BufferSize);
|
||||
MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize,
|
||||
oldparams, newparams, BufferSize);
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixDirectHrtf_<CTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat (*data)[BUFFERSIZE], float2 *RESTRICT AccumSamples, DirectHrtfState *State,
|
||||
void MixDirectHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const FloatBufferLine *InSamples, float2 *AccumSamples, DirectHrtfState *State,
|
||||
const ALsizei NumChans, const ALsizei BufferSize)
|
||||
{
|
||||
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, State, NumChans,
|
||||
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, NumChans,
|
||||
BufferSize);
|
||||
}
|
||||
|
||||
|
@ -163,29 +163,29 @@ static inline void ApplyCoeffs(ALsizei /*Offset*/, float2 *RESTRICT Values, cons
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixHrtf_<NEONTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
|
||||
float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
void MixHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
MixHrtfParams *hrtfparams, const ALsizei BufferSize)
|
||||
{
|
||||
MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, OutPos, IrSize, hrtfparams,
|
||||
BufferSize);
|
||||
MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize,
|
||||
hrtfparams, BufferSize);
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixHrtfBlend_<NEONTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat *data, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
void MixHrtfBlend_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize)
|
||||
{
|
||||
MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, OutPos, IrSize, oldparams,
|
||||
newparams, BufferSize);
|
||||
MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize,
|
||||
oldparams, newparams, BufferSize);
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixDirectHrtf_<NEONTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat (*data)[BUFFERSIZE], float2 *RESTRICT AccumSamples, DirectHrtfState *State,
|
||||
void MixDirectHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const FloatBufferLine *InSamples, float2 *AccumSamples, DirectHrtfState *State,
|
||||
const ALsizei NumChans, const ALsizei BufferSize)
|
||||
{
|
||||
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, State, NumChans,
|
||||
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, NumChans,
|
||||
BufferSize);
|
||||
}
|
||||
|
||||
|
@ -120,29 +120,29 @@ static inline void ApplyCoeffs(ALsizei Offset, float2 *RESTRICT Values, const AL
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixHrtf_<SSETag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
|
||||
float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
void MixHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
MixHrtfParams *hrtfparams, const ALsizei BufferSize)
|
||||
{
|
||||
MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, OutPos, IrSize, hrtfparams,
|
||||
BufferSize);
|
||||
MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize,
|
||||
hrtfparams, BufferSize);
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixHrtfBlend_<SSETag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat *data, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
void MixHrtfBlend_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize)
|
||||
{
|
||||
MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, OutPos, IrSize, oldparams,
|
||||
newparams, BufferSize);
|
||||
MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize,
|
||||
oldparams, newparams, BufferSize);
|
||||
}
|
||||
|
||||
template<>
|
||||
void MixDirectHrtf_<SSETag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat (*data)[BUFFERSIZE], float2 *RESTRICT AccumSamples, DirectHrtfState *State,
|
||||
void MixDirectHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const FloatBufferLine *InSamples, float2 *AccumSamples, DirectHrtfState *State,
|
||||
const ALsizei NumChans, const ALsizei BufferSize)
|
||||
{
|
||||
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, AccumSamples, State, NumChans,
|
||||
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, NumChans,
|
||||
BufferSize);
|
||||
}
|
||||
|
||||
|
@ -744,9 +744,9 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
|
||||
hrtfparams.Gain = 0.0f;
|
||||
hrtfparams.GainStep = gain / static_cast<ALfloat>(fademix);
|
||||
|
||||
MixHrtfBlendSamples(voice->mDirect.Buffer[OutLIdx].data(),
|
||||
voice->mDirect.Buffer[OutRIdx].data(), HrtfSamples, AccumSamples,
|
||||
OutPos, IrSize, &parms.Hrtf.Old, &hrtfparams, fademix);
|
||||
MixHrtfBlendSamples(voice->mDirect.Buffer[OutLIdx],
|
||||
voice->mDirect.Buffer[OutRIdx], HrtfSamples, AccumSamples, OutPos,
|
||||
IrSize, &parms.Hrtf.Old, &hrtfparams, fademix);
|
||||
/* Update the old parameters with the result. */
|
||||
parms.Hrtf.Old = parms.Hrtf.Target;
|
||||
if(fademix < Counter)
|
||||
@ -777,8 +777,8 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
|
||||
hrtfparams.Gain = parms.Hrtf.Old.Gain;
|
||||
hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) /
|
||||
static_cast<ALfloat>(todo);
|
||||
MixHrtfSamples(voice->mDirect.Buffer[OutLIdx].data(),
|
||||
voice->mDirect.Buffer[OutRIdx].data(), HrtfSamples+fademix,
|
||||
MixHrtfSamples(voice->mDirect.Buffer[OutLIdx],
|
||||
voice->mDirect.Buffer[OutRIdx], HrtfSamples+fademix,
|
||||
AccumSamples+fademix, OutPos+fademix, IrSize, &hrtfparams, todo);
|
||||
/* Store the interpolated gain or the final target gain
|
||||
* depending if the fade is done.
|
||||
|
@ -297,14 +297,14 @@ using MixerFunc = void(*)(const ALfloat *data, const ALsizei OutChans,
|
||||
using RowMixerFunc = void(*)(ALfloat *OutBuffer, const ALfloat *gains,
|
||||
const ALfloat (*data)[BUFFERSIZE], const ALsizei InChans, const ALsizei InPos,
|
||||
const ALsizei BufferSize);
|
||||
using HrtfMixerFunc = void(*)(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat *data, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
using HrtfMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
MixHrtfParams *hrtfparams, const ALsizei BufferSize);
|
||||
using HrtfMixerBlendFunc = void(*)(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat *data, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
using HrtfMixerBlendFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
|
||||
const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize);
|
||||
using HrtfDirectMixerFunc = void(*)(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
|
||||
const ALfloat (*data)[BUFFERSIZE], float2 *RESTRICT AccumSamples, DirectHrtfState *State,
|
||||
using HrtfDirectMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
|
||||
const FloatBufferLine *InSamples, float2 *RESTRICT AccumSamples, DirectHrtfState *State,
|
||||
const ALsizei NumChans, const ALsizei BufferSize);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user