Use different parameters for HRTF mixers

This commit is contained in:
Chris Robinson 2014-05-18 09:31:08 -07:00
parent 29b5dae6aa
commit 5a1abf6918
6 changed files with 51 additions and 29 deletions

View File

@ -99,7 +99,7 @@ static ResamplerFunc SelectResampler(enum Resampler Resampler, ALuint increment)
}
static DryMixerFunc SelectHrtfMixer(void)
static HrtfMixerFunc SelectHrtfMixer(void)
{
#ifdef HAVE_SSE
if((CPUCapFlags&CPU_CAP_SSE))
@ -467,7 +467,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->Direct.Moving = AL_TRUE;
}
src->DryMix = SelectDirectMixer();
src->IsHrtf = AL_FALSE;
src->Dry.Mix = SelectDirectMixer();
}
else if(Device->Hrtf)
{
@ -498,7 +499,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->Direct.Moving = AL_TRUE;
src->Direct.Mix.Hrtf.IrSize = GetHrtfIrSize(Device->Hrtf);
src->DryMix = SelectHrtfMixer();
src->IsHrtf = AL_TRUE;
src->Dry.HrtfMix = SelectHrtfMixer();
}
else
{
@ -557,7 +559,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->Direct.Moving = AL_TRUE;
}
src->DryMix = SelectDirectMixer();
src->IsHrtf = AL_FALSE;
src->Dry.Mix = SelectDirectMixer();
}
for(i = 0;i < NumSends;i++)
{
@ -1020,7 +1023,8 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
}
src->Direct.Mix.Hrtf.IrSize = GetHrtfIrSize(Device->Hrtf);
src->DryMix = SelectHrtfMixer();
src->IsHrtf = AL_TRUE;
src->Dry.HrtfMix = SelectHrtfMixer();
}
else
{
@ -1088,7 +1092,8 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->Direct.Moving = AL_TRUE;
}
src->DryMix = SelectDirectMixer();
src->IsHrtf = AL_FALSE;
src->Dry.Mix = SelectDirectMixer();
}
for(i = 0;i < NumSends;i++)
{

View File

@ -350,9 +350,18 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo)
DoFilters(&directparms->LpFilter[chan], &directparms->HpFilter[chan],
SrcData, ResampledData, DstBufferSize,
directparms->Filters[chan]);
src->DryMix(directparms, directparms->OutBuffer, SrcData,
maxu(directparms->Counter, OutPos) - OutPos, chan,
OutPos, DstBufferSize);
if(!src->IsHrtf)
src->Dry.Mix(directparms, directparms->OutBuffer, SrcData,
maxu(directparms->Counter, OutPos) - OutPos, chan,
OutPos, DstBufferSize);
else
src->Dry.HrtfMix(directparms->OutBuffer, SrcData,
maxu(directparms->Counter, OutPos) - OutPos,
directparms->Offset + OutPos,
directparms->Mix.Hrtf.IrSize,
&directparms->Mix.Hrtf.Params[chan],
&directparms->Mix.Hrtf.State[chan],
OutPos, DstBufferSize);
}
for(j = 0;j < Device->NumAuxSends;j++)

View File

@ -8,6 +8,9 @@
struct DirectParams;
struct SendParams;
struct HrtfParams;
struct HrtfState;
/* C resamplers */
void Resample_copy32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
void Resample_point32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen);
@ -16,27 +19,30 @@ void Resample_cubic32_C(const ALfloat *src, ALuint frac, ALuint increment, ALflo
/* C mixers */
void MixDirect_Hrtf_C(struct DirectParams *params,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *restrict data,
ALuint Counter, ALuint srcchan, ALuint OutPos, ALuint BufferSize);
void MixDirect_Hrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, const ALuint IrSize,
const struct HrtfParams *hrtfparams, struct HrtfState *hrtfstate,
ALuint OutPos, ALuint BufferSize);
void MixDirect_C(struct DirectParams *params,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *restrict data,
ALuint Counter, ALuint srcchan, ALuint OutPos, ALuint BufferSize);
void MixSend_C(struct SendParams*,const ALfloat*restrict,ALuint,ALuint);
/* SSE mixers */
void MixDirect_Hrtf_SSE(struct DirectParams *params,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *restrict data,
ALuint Counter, ALuint srcchan, ALuint OutPos, ALuint BufferSize);
void MixDirect_Hrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, const ALuint IrSize,
const struct HrtfParams *hrtfparams, struct HrtfState *hrtfstate,
ALuint OutPos, ALuint BufferSize);
void MixDirect_SSE(struct DirectParams *params,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *restrict data,
ALuint Counter, ALuint srcchan, ALuint OutPos, ALuint BufferSize);
void MixSend_SSE(struct SendParams*,const ALfloat*restrict,ALuint,ALuint);
/* Neon mixers */
void MixDirect_Hrtf_Neon(struct DirectParams *params,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *restrict data,
ALuint Counter, ALuint srcchan, ALuint OutPos, ALuint BufferSize);
void MixDirect_Hrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, const ALuint IrSize,
const struct HrtfParams *hrtfparams, struct HrtfState *hrtfstate,
ALuint OutPos, ALuint BufferSize);
void MixDirect_Neon(struct DirectParams *params,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *restrict data,
ALuint Counter, ALuint srcchan, ALuint OutPos, ALuint BufferSize);

View File

@ -25,14 +25,11 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
ALfloat left, ALfloat right);
void MixDirect_Hrtf(DirectParams *params,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *restrict data,
ALuint Counter, ALuint srcchan, ALuint OutPos, ALuint BufferSize)
void MixDirect_Hrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, const ALuint IrSize,
const HrtfParams *hrtfparams, HrtfState *hrtfstate,
ALuint OutPos, ALuint BufferSize)
{
const ALuint IrSize = params->Mix.Hrtf.IrSize;
const HrtfParams *hrtfparams = &params->Mix.Hrtf.Params[srcchan];
HrtfState *hrtfstate = &params->Mix.Hrtf.State[srcchan];
ALuint Offset = params->Offset + OutPos;
alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
ALuint Delay[2];
ALfloat left, right;
@ -95,6 +92,3 @@ void MixDirect_Hrtf(DirectParams *params,
#undef MERGE2
#undef REAL_MERGE2
#undef UNLIKELY
#undef LIKELY

View File

@ -32,9 +32,13 @@ typedef struct ALactivesource {
/** Current target parameters used for mixing. */
ResamplerFunc Resample;
DryMixerFunc DryMix;
union {
DryMixerFunc Mix;
HrtfMixerFunc HrtfMix;
} Dry;
WetMixerFunc WetMix;
ALboolean IsHrtf;
ALint Step;
DirectParams Direct;

View File

@ -119,6 +119,10 @@ typedef ALvoid (*DryMixerFunc)(struct DirectParams *params,
ALfloat (*restrict OutBuffer)[BUFFERSIZE],
const ALfloat *restrict data, ALuint Counter,
ALuint srcchan, ALuint OutPos, ALuint BufferSize);
typedef void (*HrtfMixerFunc)(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, const ALuint IrSize,
const HrtfParams *hrtfparams, HrtfState *hrtfstate,
ALuint OutPos, ALuint BufferSize);
typedef ALvoid (*WetMixerFunc)(struct SendParams *params,
const ALfloat *restrict data,
ALuint OutPos, ALuint BufferSize);