Store the HRIR coeff pointer and delays directly in MixHrtfParams

This commit is contained in:
Chris Robinson
2017-03-12 06:58:27 -07:00
parent 96aaab9366
commit 7b4645f5f8
5 changed files with 18 additions and 11 deletions
-1
View File
@@ -1504,7 +1504,6 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
state = device->Hrtf;
for(c = 0;c < device->Dry.NumChannels;c++)
{
typedef ALfloat ALfloat2[2];
HrtfMix(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx],
device->Dry.Buffer[c], state->Offset, state->IrSize,
SAFE_CONST(ALfloat2*,state->Chan[c].Coeffs),
+10 -4
View File
@@ -612,7 +612,9 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
if(!Counter)
{
parms->Hrtf.Old = parms->Hrtf.Target;
hrtfparams.Current = &parms->Hrtf.Target;
hrtfparams.Coeffs = SAFE_CONST(ALfloat2*,parms->Hrtf.Target.Coeffs);
hrtfparams.Delay[0] = parms->Hrtf.Target.Delay[0];
hrtfparams.Delay[1] = parms->Hrtf.Target.Delay[1];
hrtfparams.Gain = parms->Hrtf.Target.Gain;
hrtfparams.GainStep = 0.0f;
MixHrtfSamples(
@@ -631,7 +633,9 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
* So it needs to fade out over DstBufferSize instead
* of Counter.
*/
hrtfparams.Current = &parms->Hrtf.Old;
hrtfparams.Coeffs = SAFE_CONST(ALfloat2*,parms->Hrtf.Old.Coeffs);
hrtfparams.Delay[0] = parms->Hrtf.Old.Delay[0];
hrtfparams.Delay[1] = parms->Hrtf.Old.Delay[1];
hrtfparams.Gain = parms->Hrtf.Old.Gain;
hrtfparams.GainStep = -hrtfparams.Gain /
(ALfloat)DstBufferSize;
@@ -648,8 +652,10 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
* fade time this mix handles.
*/
gain = lerp(parms->Hrtf.Old.Gain, parms->Hrtf.Target.Gain,
minf(1.0f, (ALfloat)Counter / (ALfloat)DstBufferSize));
hrtfparams.Current = &parms->Hrtf.Target;
minf(1.0f, (ALfloat)Counter/DstBufferSize));
hrtfparams.Coeffs = SAFE_CONST(ALfloat2*,parms->Hrtf.Target.Coeffs);
hrtfparams.Delay[0] = parms->Hrtf.Target.Delay[0];
hrtfparams.Delay[1] = parms->Hrtf.Target.Delay[1];
hrtfparams.Gain = 0.0f;
hrtfparams.GainStep = gain / (ALfloat)DstBufferSize;
MixHrtfSamples(
+2 -2
View File
@@ -23,8 +23,8 @@ void MixHrtf(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALsizei IrSize, MixHrtfParams *hrtfparams, HrtfState *hrtfstate,
ALsizei BufferSize)
{
const ALfloat (*Coeffs)[2] = hrtfparams->Current->Coeffs;
ALsizei Delay[2] = { hrtfparams->Current->Delay[0], hrtfparams->Current->Delay[1] };
const ALfloat (*Coeffs)[2] = ASSUME_ALIGNED(hrtfparams->Coeffs, 16);
const ALsizei Delay[2] = { hrtfparams->Delay[0], hrtfparams->Delay[1] };
ALfloat gainstep = hrtfparams->GainStep;
ALfloat gain = hrtfparams->Gain;
ALfloat left, right;
+4 -3
View File
@@ -1024,10 +1024,11 @@ void FillCPUCaps(ALuint capfilter);
vector_al_string SearchDataFiles(const char *match, const char *subdir);
/* Small hack to use a pointer-to-array type as a normal argument type.
* Shouldn't be used directly. */
/* Small hack to use a pointer-to-array types as a normal argument type.
* Shouldn't be used directly.
*/
typedef ALfloat ALfloatBUFFERSIZE[BUFFERSIZE];
typedef ALfloat ALfloat2[2];
#ifdef __cplusplus
}
+2 -1
View File
@@ -116,7 +116,8 @@ enum ActiveFilters {
typedef struct MixHrtfParams {
const HrtfParams *Current;
const ALfloat (*Coeffs)[2];
ALsizei Delay[2];
ALfloat Gain;
ALfloat GainStep;
} MixHrtfParams;