diff options
author | Chris Robinson <[email protected]> | 2017-05-03 03:29:21 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-05-03 03:29:21 -0700 |
commit | 444e9563b357b4e2af0d428afac9f87596aba9a6 (patch) | |
tree | 1fc1f56f2a748332ad21b482895ea1fff3f7f9f7 /Alc/mixer.c | |
parent | 4e5c4b8e01060bb34c58480895e70a0529d8a55e (diff) |
Add a mixing function to blend HRIRs
This is a bit more efficient than calling the normal HRTF mixing function
twice, and helps solve the problem of the values generated from convolution not
being consistent with the new HRIR.
Diffstat (limited to 'Alc/mixer.c')
-rw-r--r-- | Alc/mixer.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index a7adf9b6..6eaf4caf 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -53,6 +53,7 @@ enum Resampler ResamplerDefault = LinearResampler; static MixerFunc MixSamples = Mix_C; static HrtfMixerFunc MixHrtfSamples = MixHrtf_C; +HrtfMixerBlendFunc MixHrtfBlendSamples = MixHrtfBlend_C; MixerFunc SelectMixer(void) { @@ -90,10 +91,22 @@ static inline HrtfMixerFunc SelectHrtfMixer(void) if((CPUCapFlags&CPU_CAP_SSE)) return MixHrtf_SSE; #endif - return MixHrtf_C; } +static inline HrtfMixerBlendFunc SelectHrtfBlendMixer(void) +{ +#ifdef HAVE_NEON + if((CPUCapFlags&CPU_CAP_NEON)) + return MixHrtfBlend_Neon; +#endif +#ifdef HAVE_SSE + if((CPUCapFlags&CPU_CAP_SSE)) + return MixHrtfBlend_SSE; +#endif + return MixHrtfBlend_C; +} + ResamplerFunc SelectResampler(enum Resampler resampler) { switch(resampler) @@ -174,6 +187,7 @@ void aluInitMixer(void) } } + MixHrtfBlendSamples = SelectHrtfBlendMixer(); MixHrtfSamples = SelectHrtfMixer(); MixSamples = SelectMixer(); } @@ -511,25 +525,10 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei } else if(firstpass) { - HrtfState backupstate = parms->Hrtf.State; ALfloat gain; /* Fade between the coefficients over 64 samples. */ - fademix = mini(DstBufferSize, 64); - - /* The old coefficients need to fade to silence - * completely since they'll be replaced after this mix. - */ - 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)fademix; - MixHrtfSamples( - voice->Direct.Buffer[lidx], voice->Direct.Buffer[ridx], - samples, voice->Offset, OutPos, IrSize, &hrtfparams, - &backupstate, fademix - ); + fademix = mini(DstBufferSize, 64); /* The new coefficients need to fade in completely * since they're replacing the old ones. To keep the @@ -544,10 +543,11 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei hrtfparams.Delay[1] = parms->Hrtf.Target.Delay[1]; hrtfparams.Gain = 0.0f; hrtfparams.GainStep = gain / (ALfloat)fademix; - MixHrtfSamples( + + MixHrtfBlendSamples( voice->Direct.Buffer[lidx], voice->Direct.Buffer[ridx], - samples, voice->Offset, OutPos, IrSize, &hrtfparams, - &parms->Hrtf.State, fademix + samples, voice->Offset, OutPos, IrSize, &parms->Hrtf.Old, + &hrtfparams, &parms->Hrtf.State, fademix ); /* Update the old parameters with the result. */ parms->Hrtf.Old = parms->Hrtf.Target; |