diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/hrtf.c | 8 | ||||
-rw-r--r-- | Alc/mixer.c | 24 |
2 files changed, 20 insertions, 12 deletions
@@ -170,10 +170,10 @@ void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azi // Calculate the HRIR delays using linear interpolation. delays[0] = fastf2u(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]), lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]), - mu[2]) * 65536.0f); + mu[2]) + 0.5f) << HRTFDELAY_BITS; delays[1] = fastf2u(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]), lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]), - mu[2]) * 65536.0f); + mu[2]) + 0.5f) << HRTFDELAY_BITS; } // Calculates the moving HRIR target coefficients, target delays, and @@ -267,10 +267,10 @@ ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat a delays[0] = fastf2u(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]), lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]), - mu[2]) * 65536.0f); + mu[2]) + 0.5f) << HRTFDELAY_BITS; delays[1] = fastf2u(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]), lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]), - mu[2]) * 65536.0f); + mu[2]) + 0.5f) << HRTFDELAY_BITS; delayStep[0] = fastf2i(step * (delays[0] - left)); delayStep[1] = fastf2i(step * (delays[1] - right)); diff --git a/Alc/mixer.c b/Alc/mixer.c index c4120908..79ee31d1 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -145,8 +145,8 @@ static void MixDirect_Hrtf_##sampler(ALsource *Source, ALCdevice *Device, \ Coeffs[c][1] = TargetCoeffs[c][1] - (CoeffStep[c][1]*Counter); \ } \ \ - Delay[0] = TargetDelay[0] - (DelayStep[0]*Counter) + 32768; \ - Delay[1] = TargetDelay[1] - (DelayStep[1]*Counter) + 32768; \ + Delay[0] = TargetDelay[0] - (DelayStep[0]*Counter); \ + Delay[1] = TargetDelay[1] - (DelayStep[1]*Counter); \ \ if(LIKELY(OutPos == 0)) \ { \ @@ -154,8 +154,12 @@ static void MixDirect_Hrtf_##sampler(ALsource *Source, ALCdevice *Device, \ value = lpFilter2PC(DryFilter, i, value); \ \ History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-(Delay[0]>>16))&SRC_HISTORY_MASK]; \ - right = History[(Offset-(Delay[1]>>16))&SRC_HISTORY_MASK]; \ + left = lerp(History[(Offset-(Delay[0]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], \ + History[(Offset-(Delay[0]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], \ + (Delay[0]&HRTFDELAY_MASK)/(ALfloat)HRTFDELAY_FRACONE); \ + right = lerp(History[(Offset-(Delay[1]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], \ + History[(Offset-(Delay[1]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], \ + (Delay[1]&HRTFDELAY_MASK)/(ALfloat)HRTFDELAY_FRACONE); \ \ ClickRemoval[FrontLeft] -= Values[(Offset+1)&HRIR_MASK][0] + \ Coeffs[0][0] * left; \ @@ -168,8 +172,12 @@ static void MixDirect_Hrtf_##sampler(ALsource *Source, ALCdevice *Device, \ value = lpFilter2P(DryFilter, i, value); \ \ History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-(Delay[0]>>16))&SRC_HISTORY_MASK]; \ - right = History[(Offset-(Delay[1]>>16))&SRC_HISTORY_MASK]; \ + left = lerp(History[(Offset-(Delay[0]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], \ + History[(Offset-(Delay[0]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], \ + (Delay[0]&HRTFDELAY_MASK)/(ALfloat)HRTFDELAY_FRACONE); \ + right = lerp(History[(Offset-(Delay[1]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], \ + History[(Offset-(Delay[1]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], \ + (Delay[1]&HRTFDELAY_MASK)/(ALfloat)HRTFDELAY_FRACONE); \ \ Delay[0] += DelayStep[0]; \ Delay[1] += DelayStep[1]; \ @@ -197,8 +205,8 @@ static void MixDirect_Hrtf_##sampler(ALsource *Source, ALCdevice *Device, \ Counter--; \ } \ \ - Delay[0] >>= 16; \ - Delay[1] >>= 16; \ + Delay[0] >>= HRTFDELAY_BITS; \ + Delay[1] >>= HRTFDELAY_BITS; \ for(;BufferIdx < BufferSize;BufferIdx++) \ { \ value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ |