aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-03-11 20:59:12 -0800
committerChris Robinson <[email protected]>2016-03-11 20:59:12 -0800
commit22abaa287d7c10fb1ae8ae34b32d5e0ebbbfad78 (patch)
treed2bc8ff92512024e5fefae19ca6ed6208ad1e61d
parent532897219326e5ee47eb08810734b2f2ed4409a3 (diff)
Use the real output's left and right channels with HRTF
-rw-r--r--Alc/ALu.c29
-rw-r--r--Alc/mixer.c8
-rw-r--r--Alc/mixer_defs.h24
-rw-r--r--Alc/mixer_inc.c15
-rw-r--r--OpenAL32/Include/alu.h4
5 files changed, 46 insertions, 34 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 17c91e52..d139cb7b 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -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
{
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 779d69e0..44495d72 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -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);
}
diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h
index 3fecab87..5db804b1 100644
--- a/Alc/mixer_defs.h
+++ b/Alc/mixer_defs.h
@@ -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);
diff --git a/Alc/mixer_inc.c b/Alc/mixer_inc.c
index a57a3ecb..e9d81c2a 100644
--- a/Alc/mixer_inc.c
+++ b/Alc/mixer_inc.c
@@ -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;
}
}
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index af2ea857..08f25204 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -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);