Use the real output's left and right channels with HRTF

This commit is contained in:
Chris Robinson
2016-03-11 20:59:12 -08:00
parent 5328972193
commit 22abaa287d
5 changed files with 46 additions and 34 deletions
+17 -12
View File
@@ -1454,20 +1454,25 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
if(device->Hrtf)
{
HrtfMixerFunc HrtfMix = SelectHrtfMixer();
ALuint irsize = GetHrtfIrSize(device->Hrtf);
MixHrtfParams hrtfparams;
memset(&hrtfparams, 0, sizeof(hrtfparams));
for(c = 0;c < device->VirtOut.NumChannels;c++)
int lidx = GetChannelIdxByName(device->RealOut, FrontLeft);
int ridx = GetChannelIdxByName(device->RealOut, FrontRight);
if(lidx != -1 && ridx != -1)
{
hrtfparams.Current = &device->Hrtf_Params[c];
hrtfparams.Target = &device->Hrtf_Params[c];
HrtfMix(device->RealOut.Buffer, device->VirtOut.Buffer[c], 0,
device->Hrtf_Offset, 0, irsize, &hrtfparams,
&device->Hrtf_State[c], SamplesToDo
);
HrtfMixerFunc HrtfMix = SelectHrtfMixer();
ALuint irsize = GetHrtfIrSize(device->Hrtf);
MixHrtfParams hrtfparams;
memset(&hrtfparams, 0, sizeof(hrtfparams));
for(c = 0;c < device->VirtOut.NumChannels;c++)
{
hrtfparams.Current = &device->Hrtf_Params[c];
hrtfparams.Target = &device->Hrtf_Params[c];
HrtfMix(device->RealOut.Buffer, lidx, ridx,
device->VirtOut.Buffer[c], 0, device->Hrtf_Offset, 0,
irsize, &hrtfparams, &device->Hrtf_State[c], SamplesToDo
);
}
device->Hrtf_Offset += SamplesToDo;
}
device->Hrtf_Offset += SamplesToDo;
}
else
{
+7 -1
View File
@@ -603,6 +603,8 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
else
{
MixHrtfParams hrtfparams;
int lidx, ridx;
if(!Counter)
{
parms->Hrtf[chan].Current = parms->Hrtf[chan].Target;
@@ -633,7 +635,11 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
hrtfparams.Target = &parms->Hrtf[chan].Target;
hrtfparams.Current = &parms->Hrtf[chan].Current;
MixHrtfSamples(parms->OutBuffer, samples, Counter, voice->Offset,
lidx = GetChannelIdxByName(Device->RealOut, FrontLeft);
ridx = GetChannelIdxByName(Device->RealOut, FrontRight);
assert(lidx != -1 && ridx != -1);
MixHrtfSamples(parms->OutBuffer, lidx, ridx, samples, Counter, voice->Offset,
OutPos, IrSize, &hrtfparams, &parms->Hrtf[chan].State,
DstBufferSize);
}
+12 -12
View File
@@ -21,18 +21,18 @@ const ALfloat *Resample_bsinc32_C(const BsincState *state, const ALfloat *src, A
/* C mixers */
void MixHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, ALuint OutPos, const ALuint IrSize,
const struct MixHrtfParams *hrtfparams, struct HrtfState *hrtfstate,
ALuint BufferSize);
void MixHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx,
const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos,
const ALuint IrSize, const struct MixHrtfParams *hrtfparams,
struct HrtfState *hrtfstate, ALuint BufferSize);
void Mix_C(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize);
/* SSE mixers */
void MixHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, ALuint OutPos, const ALuint IrSize,
const struct MixHrtfParams *hrtfparams, struct HrtfState *hrtfstate,
ALuint BufferSize);
void MixHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx,
const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos,
const ALuint IrSize, const struct MixHrtfParams *hrtfparams,
struct HrtfState *hrtfstate, ALuint BufferSize);
void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize);
@@ -70,10 +70,10 @@ const ALfloat *Resample_fir8_32_SSE41(const BsincState *state, const ALfloat *sr
ALfloat *restrict dst, ALuint numsamples);
/* Neon mixers */
void MixHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, ALuint OutPos, const ALuint IrSize,
const struct MixHrtfParams *hrtfparams, struct HrtfState *hrtfstate,
ALuint BufferSize);
void MixHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx,
const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos,
const ALuint IrSize, const struct MixHrtfParams *hrtfparams,
struct HrtfState *hrtfstate, ALuint BufferSize);
void Mix_Neon(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE],
struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize);
+8 -7
View File
@@ -23,9 +23,10 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
ALfloat left, ALfloat right);
void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, ALuint OutPos, const ALuint IrSize,
const MixHrtfParams *hrtfparams, HrtfState *hrtfstate, ALuint BufferSize)
void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx,
const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos,
const ALuint IrSize, const MixHrtfParams *hrtfparams, HrtfState *hrtfstate,
ALuint BufferSize)
{
ALfloat (*Coeffs)[2] = hrtfparams->Current->Coeffs;
ALuint Delay[2] = { hrtfparams->Current->Delay[0], hrtfparams->Current->Delay[1] };
@@ -66,9 +67,9 @@ void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
}
for(i = 0;i < todo;i++)
OutBuffer[0][OutPos+i] += out[i][0];
OutBuffer[lidx][OutPos+i] += out[i][0];
for(i = 0;i < todo;i++)
OutBuffer[1][OutPos+i] += out[i][1];
OutBuffer[ridx][OutPos+i] += out[i][1];
OutPos += todo;
}
@@ -107,9 +108,9 @@ skip_stepping:
}
for(i = 0;i < todo;i++)
OutBuffer[0][OutPos+i] += out[i][0];
OutBuffer[lidx][OutPos+i] += out[i][0];
for(i = 0;i < todo;i++)
OutBuffer[1][OutPos+i] += out[i][1];
OutBuffer[ridx][OutPos+i] += out[i][1];
OutPos += todo;
}
}
+2 -2
View File
@@ -193,8 +193,8 @@ typedef const ALfloat* (*ResamplerFunc)(const BsincState *state,
typedef void (*MixerFunc)(const ALfloat *data, ALuint OutChans,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], struct MixGains *Gains,
ALuint Counter, ALuint OutPos, ALuint BufferSize);
typedef void (*HrtfMixerFunc)(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Counter, ALuint Offset, ALuint OutPos,
typedef void (*HrtfMixerFunc)(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint lidx, ALuint ridx,
const ALfloat *data, ALuint Counter, ALuint Offset, ALuint OutPos,
const ALuint IrSize, const MixHrtfParams *hrtfparams,
HrtfState *hrtfstate, ALuint BufferSize);