diff options
author | Chris Robinson <[email protected]> | 2016-02-14 03:23:06 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-02-14 03:23:06 -0800 |
commit | ecdc93f3ca3b12ab0b226864cf8cd579140f1484 (patch) | |
tree | 9c5d34a6f9caaf163512908af0eb5da11dd90c60 /Alc/mixer.c | |
parent | 25732d0895cc4d320472fc50cd74302d91b24a0c (diff) |
Calculate HRTF stepping params right before mixing
This means we track the current params and the target params, rather than the
target params and the stepping. This closer matches the non-HRTF mixers.
Diffstat (limited to 'Alc/mixer.c')
-rw-r--r-- | Alc/mixer.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index 4688c89e..6b5272ea 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -601,9 +601,42 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam currents[j] = gains[j].Current; } else - MixHrtfSamples(parms->OutBuffer, samples, parms->HrtfCounter, voice->Offset, - OutPos, IrSize, &parms->Hrtf[chan].Params, - &parms->Hrtf[chan].State, DstBufferSize); + { + MixHrtfParams hrtfparams; + if(!Counter) + { + parms->Hrtf[chan].Current = parms->Hrtf[chan].Target; + for(j = 0;j < HRIR_LENGTH;j++) + { + hrtfparams.Steps.Coeffs[j][0] = 0.0f; + hrtfparams.Steps.Coeffs[j][1] = 0.0f; + } + hrtfparams.Steps.Delay[0] = 0; + hrtfparams.Steps.Delay[1] = 0; + } + else + { + ALfloat coeffdiff; + ALint delaydiff; + for(j = 0;j < HRIR_LENGTH;j++) + { + coeffdiff = parms->Hrtf[chan].Target.Coeffs[j][0] - parms->Hrtf[chan].Current.Coeffs[j][0]; + hrtfparams.Steps.Coeffs[j][0] = coeffdiff * Delta; + coeffdiff = parms->Hrtf[chan].Target.Coeffs[j][1] - parms->Hrtf[chan].Current.Coeffs[j][1]; + hrtfparams.Steps.Coeffs[j][1] = coeffdiff * Delta; + } + delaydiff = (ALint)(parms->Hrtf[chan].Target.Delay[0] - parms->Hrtf[chan].Current.Delay[0]); + hrtfparams.Steps.Delay[0] = fastf2i((ALfloat)delaydiff * Delta); + delaydiff = (ALint)(parms->Hrtf[chan].Target.Delay[1] - parms->Hrtf[chan].Current.Delay[1]); + hrtfparams.Steps.Delay[1] = fastf2i((ALfloat)delaydiff * Delta); + } + hrtfparams.Target = &parms->Hrtf[chan].Target; + hrtfparams.Current = &parms->Hrtf[chan].Current; + + MixHrtfSamples(parms->OutBuffer, samples, Counter, voice->Offset, + OutPos, IrSize, &hrtfparams, &parms->Hrtf[chan].State, + DstBufferSize); + } } for(j = 0;j < Device->NumAuxSends;j++) @@ -664,7 +697,6 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam OutPos += DstBufferSize; voice->Offset += DstBufferSize; - voice->Direct.HrtfCounter = maxu(voice->Direct.HrtfCounter, DstBufferSize) - DstBufferSize; /* Handle looping sources */ while(1) |