From 0ce0a88fd67ddcf7cb5248ac08d36cfa1c0013eb Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 23 Mar 2014 03:03:03 -0700 Subject: Move the step counter and moving flag to DirectParams --- Alc/ALu.c | 21 +++++++++++++++------ Alc/mixer.c | 6 +++--- Alc/mixer_inc.c | 2 +- OpenAL32/Include/alu.h | 6 ++++-- OpenAL32/alSource.c | 4 ++-- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index 384042c3..ca0c0be4 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -438,6 +438,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) } } } + src->Direct.Counter = 0; + src->Direct.Moving = AL_TRUE; src->DryMix = SelectDirectMixer(); } else if(Device->Hrtf) @@ -465,7 +467,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) src->Direct.Mix.Hrtf.Params.Delay[c]); } } - src->Direct.Mix.Hrtf.State.Counter = 0; + src->Direct.Counter = 0; + src->Direct.Moving = AL_TRUE; src->Direct.Mix.Hrtf.Params.IrSize = GetHrtfIrSize(Device->Hrtf); src->DryMix = SelectHrtfMixer(); @@ -491,6 +494,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) ComputeAngleGains(Device, chans[c].angle, hwidth, DryGain, SrcMatrix[c]); } + src->Direct.Counter = 0; + src->Direct.Moving = AL_TRUE; src->DryMix = SelectDirectMixer(); } for(i = 0;i < NumSends;i++) @@ -872,7 +877,7 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext) } /* Check to see if the HRIR is already moving. */ - if(src->Direct.Mix.Hrtf.State.Moving) + if(src->Direct.Moving) { /* Calculate the normalized HRTF transition factor (delta). */ delta = CalcHrtfDelta(src->Direct.Mix.Hrtf.Params.Gain, DryGain, @@ -883,12 +888,12 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext) { ALuint counter = GetMovingHrtfCoeffs(Device->Hrtf, ev, az, DryGain, delta, - src->Direct.Mix.Hrtf.State.Counter, + src->Direct.Counter, src->Direct.Mix.Hrtf.Params.Coeffs[0], src->Direct.Mix.Hrtf.Params.Delay[0], src->Direct.Mix.Hrtf.Params.CoeffStep, src->Direct.Mix.Hrtf.Params.DelayStep); - src->Direct.Mix.Hrtf.State.Counter = counter; + src->Direct.Counter = counter; src->Direct.Mix.Hrtf.Params.Gain = DryGain; src->Direct.Mix.Hrtf.Params.Dir[0] = Position[0]; src->Direct.Mix.Hrtf.Params.Dir[1] = Position[1]; @@ -901,8 +906,8 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext) GetLerpedHrtfCoeffs(Device->Hrtf, ev, az, DryGain, src->Direct.Mix.Hrtf.Params.Coeffs[0], src->Direct.Mix.Hrtf.Params.Delay[0]); - src->Direct.Mix.Hrtf.State.Counter = 0; - src->Direct.Mix.Hrtf.State.Moving = AL_TRUE; + src->Direct.Counter = 0; + src->Direct.Moving = AL_TRUE; src->Direct.Mix.Hrtf.Params.Gain = DryGain; src->Direct.Mix.Hrtf.Params.Dir[0] = Position[0]; src->Direct.Mix.Hrtf.Params.Dir[1] = Position[1]; @@ -945,6 +950,10 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext) enum Channel chan = Device->Speaker2Chan[i]; Matrix[0][chan] = maxf(Matrix[0][chan], AmbientGain); } + + src->Direct.Counter = 0; + src->Direct.Moving = AL_TRUE; + src->DryMix = SelectDirectMixer(); } for(i = 0;i < NumSends;i++) diff --git a/Alc/mixer.c b/Alc/mixer.c index 22c5aad7..8ce7d845 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -413,10 +413,10 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) Source->position_fraction = DataPosFrac; src->Direct.Mix.Hrtf.State.Offset += OutPos; if(State == AL_PLAYING) - src->Direct.Mix.Hrtf.State.Counter = maxu(src->Direct.Mix.Hrtf.State.Counter, OutPos) - OutPos; + src->Direct.Counter = maxu(src->Direct.Counter, OutPos) - OutPos; else { - src->Direct.Mix.Hrtf.State.Counter = 0; - src->Direct.Mix.Hrtf.State.Moving = AL_FALSE; + src->Direct.Counter = 0; + src->Direct.Moving = AL_FALSE; } } diff --git a/Alc/mixer_inc.c b/Alc/mixer_inc.c index c9c9bd6b..1cb1967d 100644 --- a/Alc/mixer_inc.c +++ b/Alc/mixer_inc.c @@ -43,8 +43,8 @@ void MixDirect_Hrtf(DirectParams *params, const ALfloat *restrict data, ALuint s const ALuint *restrict TargetDelay = params->Mix.Hrtf.Params.Delay[srcchan]; ALfloat *restrict History = params->Mix.Hrtf.State.History[srcchan]; ALfloat (*restrict Values)[2] = params->Mix.Hrtf.State.Values[srcchan]; - ALint Counter = maxu(params->Mix.Hrtf.State.Counter, OutPos) - OutPos; ALuint Offset = params->Mix.Hrtf.State.Offset + OutPos; + ALint Counter = maxu(params->Counter, OutPos) - OutPos; ALIGN(16) ALfloat Coeffs[HRIR_LENGTH][2]; ALuint Delay[2]; ALfloat left, right; diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index c4baed83..3ec16565 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -38,8 +38,6 @@ extern "C" { #endif typedef struct HrtfState { - ALboolean Moving; - ALuint Counter; ALIGN(16) ALfloat History[MAX_INPUT_CHANNELS][SRC_HISTORY_LENGTH]; ALIGN(16) ALfloat Values[MAX_INPUT_CHANNELS][HRIR_LENGTH][2]; ALuint Offset; @@ -71,6 +69,10 @@ typedef struct DirectParams { * channel target (eg. FrontLeft). Not used with HRTF. */ ALfloat Gains[MAX_INPUT_CHANNELS][MaxChannels]; } Mix; + /* If not 'moving', gain/coefficients are set directly without fading. */ + ALboolean Moving; + /* Stepping counter for gain/coefficient fading. */ + ALuint Counter; ALfilterState LpFilter[MAX_INPUT_CHANNELS]; } DirectParams; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index e12c9b35..082d8f54 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -2339,8 +2339,8 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state) } else { - src->Direct.Mix.Hrtf.State.Moving = AL_FALSE; - src->Direct.Mix.Hrtf.State.Counter = 0; + src->Direct.Moving = AL_FALSE; + src->Direct.Counter = 0; for(j = 0;j < MAX_INPUT_CHANNELS;j++) { for(k = 0;k < SRC_HISTORY_LENGTH;k++) -- cgit v1.2.3