aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mixer.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-11-23 10:49:54 -0800
committerChris Robinson <[email protected]>2014-11-23 10:49:54 -0800
commit45d6bb58a4293c5b1ab229cea86e0ef24a2a084b (patch)
treeec03ad6eac812ae209f8d973687afa5b99616133 /Alc/mixer.c
parentfc3608b381c0492674b4cfc1da0dcf5389ace722 (diff)
Partially revert "Use a different method for HRTF mixing"
The sound localization with virtual channel mixing was just too poor, so while it's more costly to do per-source HRTF mixing, it's unavoidable if you want good localization. This is only partially reverted because having the virtual channel is still beneficial, particularly with B-Format rendering and effect mixing which otherwise skip HRTF processing. As before, the number of virtual channels can potentially be customized, specifying more or less channels depending on the system's needs.
Diffstat (limited to 'Alc/mixer.c')
-rw-r--r--Alc/mixer.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 4a98ee8f..3f80434e 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -41,6 +41,20 @@
extern inline void InitiatePositionArrays(ALuint frac, ALuint increment, ALuint *frac_arr, ALuint *pos_arr, ALuint size);
+static inline HrtfMixerFunc SelectHrtfMixer(void)
+{
+#ifdef HAVE_SSE
+ if((CPUCapFlags&CPU_CAP_SSE))
+ return MixHrtf_SSE;
+#endif
+#ifdef HAVE_NEON
+ if((CPUCapFlags&CPU_CAP_NEON))
+ return MixHrtf_Neon;
+#endif
+
+ return MixHrtf_C;
+}
+
static inline MixerFunc SelectMixer(void)
{
#ifdef HAVE_SSE
@@ -165,6 +179,7 @@ static const ALfloat *DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter
ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
{
MixerFunc Mix;
+ HrtfMixerFunc HrtfMix;
ResamplerFunc Resample;
ALbufferlistitem *BufferListItem;
ALuint DataPosInt, DataPosFrac;
@@ -203,6 +218,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
}
Mix = SelectMixer();
+ HrtfMix = SelectHrtfMixer();
Resample = ((increment == FRACTIONONE && DataPosFrac == 0) ?
Resample_copy32_C : SelectResampler(Resampler));
@@ -415,8 +431,13 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
Device->FilteredData, ResampledData, DstBufferSize,
parms->Filters[chan].ActiveType
);
- Mix(samples, parms->OutChannels, parms->OutBuffer, parms->Gains[chan],
- parms->Counter, OutPos, DstBufferSize);
+ if(!voice->IsHrtf)
+ Mix(samples, parms->OutChannels, parms->OutBuffer, parms->Gains[chan],
+ parms->Counter, OutPos, DstBufferSize);
+ else
+ HrtfMix(parms->OutBuffer, samples, parms->Counter, voice->Offset,
+ OutPos, parms->Hrtf.IrSize, &parms->Hrtf.Params[chan],
+ &parms->Hrtf.State[chan], DstBufferSize);
}
/* Only the first channel for B-Format buffers (W channel) goes to