Store the HrtfState directly in the DirectParams

This commit is contained in:
Chris Robinson 2014-03-23 02:45:50 -07:00
parent cc599333a8
commit b0d511a860
10 changed files with 49 additions and 63 deletions

View File

@ -465,10 +465,9 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
src->Direct.Mix.Hrtf.Params.Delay[c]);
}
}
ALSource->Hrtf.Counter = 0;
src->Direct.Mix.Hrtf.State.Counter = 0;
src->Direct.Mix.Hrtf.Params.IrSize = GetHrtfIrSize(Device->Hrtf);
src->Direct.Mix.Hrtf.State = &ALSource->Hrtf;
src->DryMix = SelectHrtfMixer();
}
else
@ -873,7 +872,7 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
}
/* Check to see if the HRIR is already moving. */
if(ALSource->Hrtf.Moving)
if(src->Direct.Mix.Hrtf.State.Moving)
{
/* Calculate the normalized HRTF transition factor (delta). */
delta = CalcHrtfDelta(src->Direct.Mix.Hrtf.Params.Gain, DryGain,
@ -882,13 +881,14 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
* coefficients, target delays, steppping values, and counter. */
if(delta > 0.001f)
{
ALSource->Hrtf.Counter = GetMovingHrtfCoeffs(Device->Hrtf,
ALuint counter = GetMovingHrtfCoeffs(Device->Hrtf,
ev, az, DryGain, delta,
ALSource->Hrtf.Counter,
src->Direct.Mix.Hrtf.State.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.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 +901,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]);
ALSource->Hrtf.Counter = 0;
ALSource->Hrtf.Moving = AL_TRUE;
src->Direct.Mix.Hrtf.State.Counter = 0;
src->Direct.Mix.Hrtf.State.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];
@ -910,7 +910,6 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
}
src->Direct.Mix.Hrtf.Params.IrSize = GetHrtfIrSize(Device->Hrtf);
src->Direct.Mix.Hrtf.State = &ALSource->Hrtf;
src->DryMix = SelectHrtfMixer();
}
else

View File

@ -411,12 +411,12 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo)
Source->BuffersPlayed = BuffersPlayed;
Source->position = DataPosInt;
Source->position_fraction = DataPosFrac;
Source->Hrtf.Offset += OutPos;
src->Direct.Mix.Hrtf.State.Offset += OutPos;
if(State == AL_PLAYING)
Source->Hrtf.Counter = maxu(Source->Hrtf.Counter, OutPos) - OutPos;
src->Direct.Mix.Hrtf.State.Counter = maxu(src->Direct.Mix.Hrtf.State.Counter, OutPos) - OutPos;
else
{
Source->Hrtf.Counter = 0;
Source->Hrtf.Moving = AL_FALSE;
src->Direct.Mix.Hrtf.State.Counter = 0;
src->Direct.Mix.Hrtf.State.Moving = AL_FALSE;
}
}

View File

@ -82,7 +82,7 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
#undef SUFFIX
void MixDirect_C(const DirectParams *params, const ALfloat *restrict data, ALuint srcchan,
void MixDirect_C(DirectParams *params, const ALfloat *restrict data, ALuint srcchan,
ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
{
ALfloat (*restrict OutBuffer)[BUFFERSIZE] = params->OutBuffer;
@ -108,7 +108,7 @@ void MixDirect_C(const DirectParams *params, const ALfloat *restrict data, ALuin
}
void MixSend_C(const SendParams *params, const ALfloat *restrict data,
void MixSend_C(SendParams *params, const ALfloat *restrict data,
ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
{
ALfloat (*restrict OutBuffer)[BUFFERSIZE] = params->OutBuffer;

View File

@ -16,18 +16,18 @@ void Resample_cubic32_C(const ALfloat *src, ALuint frac, ALuint increment, ALflo
/* C mixers */
void MixDirect_Hrtf_C(const struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixDirect_C(const struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixSend_C(const struct SendParams*,const ALfloat*restrict,ALuint,ALuint,ALuint);
void MixDirect_Hrtf_C(struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixDirect_C(struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixSend_C(struct SendParams*,const ALfloat*restrict,ALuint,ALuint,ALuint);
/* SSE mixers */
void MixDirect_Hrtf_SSE(const struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixDirect_SSE(const struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixSend_SSE(const struct SendParams*,const ALfloat*restrict,ALuint,ALuint,ALuint);
void MixDirect_Hrtf_SSE(struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixDirect_SSE(struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixSend_SSE(struct SendParams*,const ALfloat*restrict,ALuint,ALuint,ALuint);
/* Neon mixers */
void MixDirect_Hrtf_Neon(const struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixDirect_Neon(const struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixSend_Neon(const struct SendParams*,const ALfloat*restrict,ALuint,ALuint,ALuint);
void MixDirect_Hrtf_Neon(struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixDirect_Neon(struct DirectParams*,const ALfloat*restrict,ALuint,ALuint,ALuint,ALuint);
void MixSend_Neon(struct SendParams*,const ALfloat*restrict,ALuint,ALuint,ALuint);
#endif /* MIXER_DEFS_H */

View File

@ -30,7 +30,7 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
ALfloat left, ALfloat right);
void MixDirect_Hrtf(const DirectParams *params, const ALfloat *restrict data, ALuint srcchan,
void MixDirect_Hrtf(DirectParams *params, const ALfloat *restrict data, ALuint srcchan,
ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
{
ALfloat (*restrict DryBuffer)[BUFFERSIZE] = params->OutBuffer;
@ -41,10 +41,10 @@ void MixDirect_Hrtf(const DirectParams *params, const ALfloat *restrict data, AL
const ALfloat (*restrict CoeffStep)[2] = params->Mix.Hrtf.Params.CoeffStep;
const ALfloat (*restrict TargetCoeffs)[2] = params->Mix.Hrtf.Params.Coeffs[srcchan];
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;
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;
ALIGN(16) ALfloat Coeffs[HRIR_LENGTH][2];
ALuint Delay[2];
ALfloat left, right;

View File

@ -77,7 +77,7 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
#undef SUFFIX
void MixDirect_Neon(const DirectParams *params, const ALfloat *restrict data, ALuint srcchan,
void MixDirect_Neon(DirectParams *params, const ALfloat *restrict data, ALuint srcchan,
ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
{
ALfloat (*restrict OutBuffer)[BUFFERSIZE] = params->OutBuffer;
@ -114,7 +114,7 @@ void MixDirect_Neon(const DirectParams *params, const ALfloat *restrict data, AL
}
void MixSend_Neon(const SendParams *params, const ALfloat *restrict data,
void MixSend_Neon(SendParams *params, const ALfloat *restrict data,
ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
{
ALfloat (*restrict OutBuffer)[BUFFERSIZE] = params->OutBuffer;

View File

@ -140,7 +140,7 @@ static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
#undef SUFFIX
void MixDirect_SSE(const DirectParams *params, const ALfloat *restrict data, ALuint srcchan,
void MixDirect_SSE(DirectParams *params, const ALfloat *restrict data, ALuint srcchan,
ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
{
ALfloat (*restrict OutBuffer)[BUFFERSIZE] = params->OutBuffer;
@ -177,7 +177,7 @@ void MixDirect_SSE(const DirectParams *params, const ALfloat *restrict data, ALu
}
void MixSend_SSE(const SendParams *params, const ALfloat *restrict data,
void MixSend_SSE(SendParams *params, const ALfloat *restrict data,
ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
{
ALfloat (*restrict OutBuffer)[BUFFERSIZE] = params->OutBuffer;

View File

@ -114,9 +114,6 @@ typedef struct ALsource {
ALfloat GainHF;
} Send[MAX_SENDS];
/** HRTF info. */
HrtfState Hrtf;
/** Source needs to update its mixing parameters. */
volatile ALenum NeedsUpdate;

View File

@ -63,7 +63,7 @@ typedef struct DirectParams {
union {
struct {
HrtfParams Params;
HrtfState *State;
HrtfState State;
} Hrtf;
/* A mixing matrix. First subscript is the channel number of the input
@ -91,11 +91,11 @@ typedef struct SendParams {
typedef void (*ResamplerFunc)(const ALfloat *src, ALuint frac, ALuint increment,
ALfloat *restrict dst, ALuint dstlen);
typedef ALvoid (*DryMixerFunc)(const struct DirectParams *params,
typedef ALvoid (*DryMixerFunc)(struct DirectParams *params,
const ALfloat *restrict data, ALuint srcchan,
ALuint OutPos, ALuint SamplesToDo,
ALuint BufferSize);
typedef ALvoid (*WetMixerFunc)(const struct SendParams *params,
typedef ALvoid (*WetMixerFunc)(struct SendParams *params,
const ALfloat *restrict data,
ALuint OutPos, ALuint SamplesToDo,
ALuint BufferSize);

View File

@ -2265,9 +2265,6 @@ static ALvoid InitSourceParams(ALsource *Source)
}
Source->NeedsUpdate = AL_TRUE;
Source->Hrtf.Moving = AL_FALSE;
Source->Hrtf.Counter = 0;
}
@ -2293,20 +2290,6 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
BufferList = BufferList->next;
}
if(Source->state != AL_PLAYING)
{
for(j = 0;j < MAX_INPUT_CHANNELS;j++)
{
for(k = 0;k < SRC_HISTORY_LENGTH;k++)
Source->Hrtf.History[j][k] = 0.0f;
for(k = 0;k < HRIR_LENGTH;k++)
{
Source->Hrtf.Values[j][k][0] = 0.0f;
Source->Hrtf.Values[j][k][1] = 0.0f;
}
}
}
if(Source->state != AL_PAUSED)
{
Source->state = AL_PLAYING;
@ -2354,16 +2337,27 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
src->Update = CalcNonAttnSourceParams;
Context->ActiveSourceCount++;
}
else
{
src->Direct.Mix.Hrtf.State.Moving = AL_FALSE;
src->Direct.Mix.Hrtf.State.Counter = 0;
for(j = 0;j < MAX_INPUT_CHANNELS;j++)
{
for(k = 0;k < SRC_HISTORY_LENGTH;k++)
src->Direct.Mix.Hrtf.State.History[j][k] = 0.0f;
for(k = 0;k < HRIR_LENGTH;k++)
{
src->Direct.Mix.Hrtf.State.Values[j][k][0] = 0.0f;
src->Direct.Mix.Hrtf.State.Values[j][k][1] = 0.0f;
}
}
}
Source->NeedsUpdate = AL_TRUE;
}
else if(state == AL_PAUSED)
{
if(Source->state == AL_PLAYING)
{
Source->state = AL_PAUSED;
Source->Hrtf.Moving = AL_FALSE;
Source->Hrtf.Counter = 0;
}
}
else if(state == AL_STOPPED)
{
@ -2371,8 +2365,6 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
{
Source->state = AL_STOPPED;
Source->BuffersPlayed = Source->BuffersInQueue;
Source->Hrtf.Moving = AL_FALSE;
Source->Hrtf.Counter = 0;
}
Source->Offset = -1.0;
}
@ -2384,8 +2376,6 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
Source->position = 0;
Source->position_fraction = 0;
Source->BuffersPlayed = 0;
Source->Hrtf.Moving = AL_FALSE;
Source->Hrtf.Counter = 0;
}
Source->Offset = -1.0;
}