Move the input channel array out of the DirectParams and SendParams

This commit is contained in:
Chris Robinson 2016-07-13 01:39:44 -07:00
parent e8202b915d
commit 5106f035df
5 changed files with 90 additions and 93 deletions

111
Alc/ALu.c
View File

@ -548,7 +548,7 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
voice->DirectOut.Channels = Device->FOAOut.NumChannels; voice->DirectOut.Channels = Device->FOAOut.NumChannels;
for(c = 0;c < num_channels;c++) for(c = 0;c < num_channels;c++)
ComputeFirstOrderGains(Device->FOAOut, matrix.m[c], DryGain, ComputeFirstOrderGains(Device->FOAOut, matrix.m[c], DryGain,
voice->Direct.Gains[c].Target); voice->Chan[c].Direct.Gains.Target);
for(i = 0;i < NumSends;i++) for(i = 0;i < NumSends;i++)
{ {
@ -557,7 +557,7 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
for(c = 0;c < num_channels;c++) for(c = 0;c < num_channels;c++)
{ {
for(j = 0;j < MAX_EFFECT_CHANNELS;j++) for(j = 0;j < MAX_EFFECT_CHANNELS;j++)
voice->Send[i].Gains[c].Target[j] = 0.0f; voice->Chan[c].Send[i].Gains.Target[j] = 0.0f;
} }
} }
else else
@ -566,7 +566,7 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
{ {
const ALeffectslot *Slot = SendSlots[i]; const ALeffectslot *Slot = SendSlots[i];
ComputeFirstOrderGainsBF(Slot->ChanMap, Slot->NumChannels, matrix.m[c], ComputeFirstOrderGainsBF(Slot->ChanMap, Slot->NumChannels, matrix.m[c],
WetGain[i], voice->Send[i].Gains[c].Target); WetGain[i], voice->Chan[c].Send[i].Gains.Target);
} }
} }
} }
@ -586,9 +586,9 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
{ {
int idx; int idx;
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++) for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
voice->Direct.Gains[c].Target[j] = 0.0f; voice->Chan[c].Direct.Gains.Target[j] = 0.0f;
if((idx=GetChannelIdxByName(Device->RealOut, chans[c].channel)) != -1) if((idx=GetChannelIdxByName(Device->RealOut, chans[c].channel)) != -1)
voice->Direct.Gains[c].Target[idx] = DryGain; voice->Chan[c].Direct.Gains.Target[idx] = DryGain;
} }
/* Auxiliary sends still use normal panning since they mix to B-Format, which can't /* Auxiliary sends still use normal panning since they mix to B-Format, which can't
@ -602,13 +602,13 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
if(!SendSlots[i]) if(!SendSlots[i])
{ {
for(j = 0;j < MAX_EFFECT_CHANNELS;j++) for(j = 0;j < MAX_EFFECT_CHANNELS;j++)
voice->Send[i].Gains[c].Target[j] = 0.0f; voice->Chan[c].Send[i].Gains.Target[j] = 0.0f;
} }
else else
{ {
const ALeffectslot *Slot = SendSlots[i]; const ALeffectslot *Slot = SendSlots[i];
ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs,
WetGain[i], voice->Send[i].Gains[c].Target); WetGain[i], voice->Chan[c].Send[i].Gains.Target);
} }
} }
} }
@ -627,18 +627,18 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
if(chans[c].channel == LFE) if(chans[c].channel == LFE)
{ {
/* Skip LFE */ /* Skip LFE */
voice->Direct.Hrtf[c].Target.Delay[0] = 0; voice->Chan[c].Direct.Hrtf.Target.Delay[0] = 0;
voice->Direct.Hrtf[c].Target.Delay[1] = 0; voice->Chan[c].Direct.Hrtf.Target.Delay[1] = 0;
for(i = 0;i < HRIR_LENGTH;i++) for(i = 0;i < HRIR_LENGTH;i++)
{ {
voice->Direct.Hrtf[c].Target.Coeffs[i][0] = 0.0f; voice->Chan[c].Direct.Hrtf.Target.Coeffs[i][0] = 0.0f;
voice->Direct.Hrtf[c].Target.Coeffs[i][1] = 0.0f; voice->Chan[c].Direct.Hrtf.Target.Coeffs[i][1] = 0.0f;
} }
for(i = 0;i < NumSends;i++) for(i = 0;i < NumSends;i++)
{ {
for(j = 0;j < MAX_EFFECT_CHANNELS;j++) for(j = 0;j < MAX_EFFECT_CHANNELS;j++)
voice->Send[i].Gains[c].Target[j] = 0.0f; voice->Chan[c].Send[i].Gains.Target[j] = 0.0f;
} }
continue; continue;
@ -647,8 +647,8 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
/* Get the static HRIR coefficients and delays for this channel. */ /* Get the static HRIR coefficients and delays for this channel. */
GetLerpedHrtfCoeffs(Device->Hrtf, GetLerpedHrtfCoeffs(Device->Hrtf,
chans[c].elevation, chans[c].angle, 0.0f, DryGain, chans[c].elevation, chans[c].angle, 0.0f, DryGain,
voice->Direct.Hrtf[c].Target.Coeffs, voice->Chan[c].Direct.Hrtf.Target.Coeffs,
voice->Direct.Hrtf[c].Target.Delay voice->Chan[c].Direct.Hrtf.Target.Delay
); );
/* Normal panning for auxiliary sends. */ /* Normal panning for auxiliary sends. */
@ -659,13 +659,13 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
if(!SendSlots[i]) if(!SendSlots[i])
{ {
for(j = 0;j < MAX_EFFECT_CHANNELS;j++) for(j = 0;j < MAX_EFFECT_CHANNELS;j++)
voice->Send[i].Gains[c].Target[j] = 0.0f; voice->Chan[c].Send[i].Gains.Target[j] = 0.0f;
} }
else else
{ {
const ALeffectslot *Slot = SendSlots[i]; const ALeffectslot *Slot = SendSlots[i];
ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs,
WetGain[i], voice->Send[i].Gains[c].Target); WetGain[i], voice->Chan[c].Send[i].Gains.Target);
} }
} }
} }
@ -681,19 +681,19 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
if(chans[c].channel == LFE) if(chans[c].channel == LFE)
{ {
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++) for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
voice->Direct.Gains[c].Target[j] = 0.0f; voice->Chan[c].Direct.Gains.Target[j] = 0.0f;
if(Device->Dry.Buffer == Device->RealOut.Buffer) if(Device->Dry.Buffer == Device->RealOut.Buffer)
{ {
int idx; int idx;
if((idx=GetChannelIdxByName(Device->RealOut, chans[c].channel)) != -1) if((idx=GetChannelIdxByName(Device->RealOut, chans[c].channel)) != -1)
voice->Direct.Gains[c].Target[idx] = DryGain; voice->Chan[c].Direct.Gains.Target[idx] = DryGain;
} }
for(i = 0;i < NumSends;i++) for(i = 0;i < NumSends;i++)
{ {
ALuint j; ALuint j;
for(j = 0;j < MAX_EFFECT_CHANNELS;j++) for(j = 0;j < MAX_EFFECT_CHANNELS;j++)
voice->Send[i].Gains[c].Target[j] = 0.0f; voice->Chan[c].Send[i].Gains.Target[j] = 0.0f;
} }
continue; continue;
} }
@ -703,10 +703,10 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
/* Clamp X so it remains within 30 degrees of 0 or 180 degree azimuth. */ /* Clamp X so it remains within 30 degrees of 0 or 180 degree azimuth. */
ALfloat x = sinf(chans[c].angle) * cosf(chans[c].elevation); ALfloat x = sinf(chans[c].angle) * cosf(chans[c].elevation);
coeffs[0] = clampf(-x, -0.5f, 0.5f) + 0.5f; coeffs[0] = clampf(-x, -0.5f, 0.5f) + 0.5f;
voice->Direct.Gains[c].Target[0] = coeffs[0] * DryGain; voice->Chan[c].Direct.Gains.Target[0] = coeffs[0] * DryGain;
voice->Direct.Gains[c].Target[1] = (1.0f-coeffs[0]) * DryGain; voice->Chan[c].Direct.Gains.Target[1] = (1.0f-coeffs[0]) * DryGain;
for(j = 2;j < MAX_OUTPUT_CHANNELS;j++) for(j = 2;j < MAX_OUTPUT_CHANNELS;j++)
voice->Direct.Gains[c].Target[j] = 0.0f; voice->Chan[c].Direct.Gains.Target[j] = 0.0f;
CalcAngleCoeffs(chans[c].angle, chans[c].elevation, 0.0f, coeffs); CalcAngleCoeffs(chans[c].angle, chans[c].elevation, 0.0f, coeffs);
} }
@ -714,7 +714,7 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
{ {
CalcAngleCoeffs(chans[c].angle, chans[c].elevation, 0.0f, coeffs); CalcAngleCoeffs(chans[c].angle, chans[c].elevation, 0.0f, coeffs);
ComputePanningGains(Device->Dry, coeffs, DryGain, ComputePanningGains(Device->Dry, coeffs, DryGain,
voice->Direct.Gains[c].Target); voice->Chan[c].Direct.Gains.Target);
} }
for(i = 0;i < NumSends;i++) for(i = 0;i < NumSends;i++)
@ -723,13 +723,13 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
{ {
ALuint j; ALuint j;
for(j = 0;j < MAX_EFFECT_CHANNELS;j++) for(j = 0;j < MAX_EFFECT_CHANNELS;j++)
voice->Send[i].Gains[c].Target[j] = 0.0f; voice->Chan[c].Send[i].Gains.Target[j] = 0.0f;
} }
else else
{ {
const ALeffectslot *Slot = SendSlots[i]; const ALeffectslot *Slot = SendSlots[i];
ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs,
WetGain[i], voice->Send[i].Gains[c].Target); WetGain[i], voice->Chan[c].Send[i].Gains.Target);
} }
} }
} }
@ -747,15 +747,15 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
DryGainLF = maxf(DryGainLF, 0.0001f); DryGainLF = maxf(DryGainLF, 0.0001f);
for(c = 0;c < num_channels;c++) for(c = 0;c < num_channels;c++)
{ {
voice->Direct.Filters[c].ActiveType = AF_None; voice->Chan[c].Direct.FilterType = AF_None;
if(DryGainHF != 1.0f) voice->Direct.Filters[c].ActiveType |= AF_LowPass; if(DryGainHF != 1.0f) voice->Chan[c].Direct.FilterType |= AF_LowPass;
if(DryGainLF != 1.0f) voice->Direct.Filters[c].ActiveType |= AF_HighPass; if(DryGainLF != 1.0f) voice->Chan[c].Direct.FilterType |= AF_HighPass;
ALfilterState_setParams( ALfilterState_setParams(
&voice->Direct.Filters[c].LowPass, ALfilterType_HighShelf, &voice->Chan[c].Direct.LowPass, ALfilterType_HighShelf,
DryGainHF, hfscale, calc_rcpQ_from_slope(DryGainHF, 0.75f) DryGainHF, hfscale, calc_rcpQ_from_slope(DryGainHF, 0.75f)
); );
ALfilterState_setParams( ALfilterState_setParams(
&voice->Direct.Filters[c].HighPass, ALfilterType_LowShelf, &voice->Chan[c].Direct.HighPass, ALfilterType_LowShelf,
DryGainLF, lfscale, calc_rcpQ_from_slope(DryGainLF, 0.75f) DryGainLF, lfscale, calc_rcpQ_from_slope(DryGainLF, 0.75f)
); );
} }
@ -770,15 +770,15 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps *
WetGainLF[i] = maxf(WetGainLF[i], 0.0001f); WetGainLF[i] = maxf(WetGainLF[i], 0.0001f);
for(c = 0;c < num_channels;c++) for(c = 0;c < num_channels;c++)
{ {
voice->Send[i].Filters[c].ActiveType = AF_None; voice->Chan[c].Send[i].FilterType = AF_None;
if(WetGainHF[i] != 1.0f) voice->Send[i].Filters[c].ActiveType |= AF_LowPass; if(WetGainHF[i] != 1.0f) voice->Chan[c].Send[i].FilterType |= AF_LowPass;
if(WetGainLF[i] != 1.0f) voice->Send[i].Filters[c].ActiveType |= AF_HighPass; if(WetGainLF[i] != 1.0f) voice->Chan[c].Send[i].FilterType |= AF_HighPass;
ALfilterState_setParams( ALfilterState_setParams(
&voice->Send[i].Filters[c].LowPass, ALfilterType_HighShelf, &voice->Chan[c].Send[i].LowPass, ALfilterType_HighShelf,
WetGainHF[i], hfscale, calc_rcpQ_from_slope(WetGainHF[i], 0.75f) WetGainHF[i], hfscale, calc_rcpQ_from_slope(WetGainHF[i], 0.75f)
); );
ALfilterState_setParams( ALfilterState_setParams(
&voice->Send[i].Filters[c].HighPass, ALfilterType_LowShelf, &voice->Chan[c].Send[i].HighPass, ALfilterType_LowShelf,
WetGainLF[i], lfscale, calc_rcpQ_from_slope(WetGainLF[i], 0.75f) WetGainLF[i], lfscale, calc_rcpQ_from_slope(WetGainLF[i], 0.75f)
); );
} }
@ -1161,8 +1161,8 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro
/* Get the HRIR coefficients and delays. */ /* Get the HRIR coefficients and delays. */
GetLerpedHrtfCoeffs(Device->Hrtf, ev, az, spread, DryGain, GetLerpedHrtfCoeffs(Device->Hrtf, ev, az, spread, DryGain,
voice->Direct.Hrtf[0].Target.Coeffs, voice->Chan[0].Direct.Hrtf.Target.Coeffs,
voice->Direct.Hrtf[0].Target.Delay); voice->Chan[0].Direct.Hrtf.Target.Delay);
CalcDirectionCoeffs(dir, spread, coeffs); CalcDirectionCoeffs(dir, spread, coeffs);
@ -1172,13 +1172,13 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro
{ {
ALuint j; ALuint j;
for(j = 0;j < MAX_EFFECT_CHANNELS;j++) for(j = 0;j < MAX_EFFECT_CHANNELS;j++)
voice->Send[i].Gains[0].Target[j] = 0.0f; voice->Chan[0].Send[i].Gains.Target[j] = 0.0f;
} }
else else
{ {
const ALeffectslot *Slot = SendSlots[i]; const ALeffectslot *Slot = SendSlots[i];
ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs,
WetGain[i], voice->Send[i].Gains[0].Target); WetGain[i], voice->Chan[0].Send[i].Gains.Target);
} }
} }
@ -1209,17 +1209,18 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro
/* Clamp X so it remains within 30 degrees of 0 or 180 degree azimuth. */ /* Clamp X so it remains within 30 degrees of 0 or 180 degree azimuth. */
ALfloat x = -dir[0] * (0.5f * (cosf(spread*0.5f) + 1.0f)); ALfloat x = -dir[0] * (0.5f * (cosf(spread*0.5f) + 1.0f));
x = clampf(x, -0.5f, 0.5f) + 0.5f; x = clampf(x, -0.5f, 0.5f) + 0.5f;
voice->Direct.Gains[0].Target[0] = x * DryGain; voice->Chan[0].Direct.Gains.Target[0] = x * DryGain;
voice->Direct.Gains[0].Target[1] = (1.0f-x) * DryGain; voice->Chan[0].Direct.Gains.Target[1] = (1.0f-x) * DryGain;
for(i = 2;i < MAX_OUTPUT_CHANNELS;i++) for(i = 2;i < MAX_OUTPUT_CHANNELS;i++)
voice->Direct.Gains[0].Target[i] = 0.0f; voice->Chan[0].Direct.Gains.Target[i] = 0.0f;
CalcDirectionCoeffs(dir, spread, coeffs); CalcDirectionCoeffs(dir, spread, coeffs);
} }
else else
{ {
CalcDirectionCoeffs(dir, spread, coeffs); CalcDirectionCoeffs(dir, spread, coeffs);
ComputePanningGains(Device->Dry, coeffs, DryGain, voice->Direct.Gains[0].Target); ComputePanningGains(Device->Dry, coeffs, DryGain,
voice->Chan[0].Direct.Gains.Target);
} }
for(i = 0;i < NumSends;i++) for(i = 0;i < NumSends;i++)
@ -1228,13 +1229,13 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro
{ {
ALuint j; ALuint j;
for(j = 0;j < MAX_EFFECT_CHANNELS;j++) for(j = 0;j < MAX_EFFECT_CHANNELS;j++)
voice->Send[i].Gains[0].Target[j] = 0.0f; voice->Chan[0].Send[i].Gains.Target[j] = 0.0f;
} }
else else
{ {
const ALeffectslot *Slot = SendSlots[i]; const ALeffectslot *Slot = SendSlots[i];
ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs,
WetGain[i], voice->Send[i].Gains[0].Target); WetGain[i], voice->Chan[0].Send[i].Gains.Target);
} }
} }
@ -1248,15 +1249,15 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro
Frequency; Frequency;
DryGainHF = maxf(DryGainHF, 0.0001f); DryGainHF = maxf(DryGainHF, 0.0001f);
DryGainLF = maxf(DryGainLF, 0.0001f); DryGainLF = maxf(DryGainLF, 0.0001f);
voice->Direct.Filters[0].ActiveType = AF_None; voice->Chan[0].Direct.FilterType = AF_None;
if(DryGainHF != 1.0f) voice->Direct.Filters[0].ActiveType |= AF_LowPass; if(DryGainHF != 1.0f) voice->Chan[0].Direct.FilterType |= AF_LowPass;
if(DryGainLF != 1.0f) voice->Direct.Filters[0].ActiveType |= AF_HighPass; if(DryGainLF != 1.0f) voice->Chan[0].Direct.FilterType |= AF_HighPass;
ALfilterState_setParams( ALfilterState_setParams(
&voice->Direct.Filters[0].LowPass, ALfilterType_HighShelf, &voice->Chan[0].Direct.LowPass, ALfilterType_HighShelf,
DryGainHF, hfscale, calc_rcpQ_from_slope(DryGainHF, 0.75f) DryGainHF, hfscale, calc_rcpQ_from_slope(DryGainHF, 0.75f)
); );
ALfilterState_setParams( ALfilterState_setParams(
&voice->Direct.Filters[0].HighPass, ALfilterType_LowShelf, &voice->Chan[0].Direct.HighPass, ALfilterType_LowShelf,
DryGainLF, lfscale, calc_rcpQ_from_slope(DryGainLF, 0.75f) DryGainLF, lfscale, calc_rcpQ_from_slope(DryGainLF, 0.75f)
); );
} }
@ -1268,15 +1269,15 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro
Frequency; Frequency;
WetGainHF[i] = maxf(WetGainHF[i], 0.0001f); WetGainHF[i] = maxf(WetGainHF[i], 0.0001f);
WetGainLF[i] = maxf(WetGainLF[i], 0.0001f); WetGainLF[i] = maxf(WetGainLF[i], 0.0001f);
voice->Send[i].Filters[0].ActiveType = AF_None; voice->Chan[0].Send[i].FilterType = AF_None;
if(WetGainHF[i] != 1.0f) voice->Send[i].Filters[0].ActiveType |= AF_LowPass; if(WetGainHF[i] != 1.0f) voice->Chan[0].Send[i].FilterType |= AF_LowPass;
if(WetGainLF[i] != 1.0f) voice->Send[i].Filters[0].ActiveType |= AF_HighPass; if(WetGainLF[i] != 1.0f) voice->Chan[0].Send[i].FilterType |= AF_HighPass;
ALfilterState_setParams( ALfilterState_setParams(
&voice->Send[i].Filters[0].LowPass, ALfilterType_HighShelf, &voice->Chan[0].Send[i].LowPass, ALfilterType_HighShelf,
WetGainHF[i], hfscale, calc_rcpQ_from_slope(WetGainHF[i], 0.75f) WetGainHF[i], hfscale, calc_rcpQ_from_slope(WetGainHF[i], 0.75f)
); );
ALfilterState_setParams( ALfilterState_setParams(
&voice->Send[i].Filters[0].HighPass, ALfilterType_LowShelf, &voice->Chan[0].Send[i].HighPass, ALfilterType_LowShelf,
WetGainLF[i], lfscale, calc_rcpQ_from_slope(WetGainLF[i], 0.75f) WetGainLF[i], lfscale, calc_rcpQ_from_slope(WetGainLF[i], 0.75f)
); );
} }

View File

@ -553,18 +553,17 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
Device->ResampledData, DstBufferSize Device->ResampledData, DstBufferSize
); );
{ {
DirectParams *parms = &voice->Direct; DirectParams *parms = &voice->Chan[chan].Direct;
const ALfloat *samples; const ALfloat *samples;
samples = DoFilters( samples = DoFilters(
&parms->Filters[chan].LowPass, &parms->Filters[chan].HighPass, &parms->LowPass, &parms->HighPass, Device->FilteredData,
Device->FilteredData, ResampledData, DstBufferSize, ResampledData, DstBufferSize, parms->FilterType
parms->Filters[chan].ActiveType
); );
if(!voice->IsHrtf) if(!voice->IsHrtf)
{ {
ALfloat *restrict currents = parms->Gains[chan].Current; ALfloat *restrict currents = parms->Gains.Current;
const ALfloat *targets = parms->Gains[chan].Target; const ALfloat *targets = parms->Gains.Target;
MixGains gains[MAX_OUTPUT_CHANNELS]; MixGains gains[MAX_OUTPUT_CHANNELS];
if(!Counter) if(!Counter)
@ -607,7 +606,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
if(!Counter) if(!Counter)
{ {
parms->Hrtf[chan].Current = parms->Hrtf[chan].Target; parms->Hrtf.Current = parms->Hrtf.Target;
for(j = 0;j < HRIR_LENGTH;j++) for(j = 0;j < HRIR_LENGTH;j++)
{ {
hrtfparams.Steps.Coeffs[j][0] = 0.0f; hrtfparams.Steps.Coeffs[j][0] = 0.0f;
@ -622,18 +621,18 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
ALint delaydiff; ALint delaydiff;
for(j = 0;j < IrSize;j++) for(j = 0;j < IrSize;j++)
{ {
coeffdiff = parms->Hrtf[chan].Target.Coeffs[j][0] - parms->Hrtf[chan].Current.Coeffs[j][0]; coeffdiff = parms->Hrtf.Target.Coeffs[j][0] - parms->Hrtf.Current.Coeffs[j][0];
hrtfparams.Steps.Coeffs[j][0] = coeffdiff * Delta; hrtfparams.Steps.Coeffs[j][0] = coeffdiff * Delta;
coeffdiff = parms->Hrtf[chan].Target.Coeffs[j][1] - parms->Hrtf[chan].Current.Coeffs[j][1]; coeffdiff = parms->Hrtf.Target.Coeffs[j][1] - parms->Hrtf.Current.Coeffs[j][1];
hrtfparams.Steps.Coeffs[j][1] = coeffdiff * Delta; hrtfparams.Steps.Coeffs[j][1] = coeffdiff * Delta;
} }
delaydiff = (ALint)(parms->Hrtf[chan].Target.Delay[0] - parms->Hrtf[chan].Current.Delay[0]); delaydiff = (ALint)(parms->Hrtf.Target.Delay[0] - parms->Hrtf.Current.Delay[0]);
hrtfparams.Steps.Delay[0] = fastf2i((ALfloat)delaydiff * Delta); hrtfparams.Steps.Delay[0] = fastf2i((ALfloat)delaydiff * Delta);
delaydiff = (ALint)(parms->Hrtf[chan].Target.Delay[1] - parms->Hrtf[chan].Current.Delay[1]); delaydiff = (ALint)(parms->Hrtf.Target.Delay[1] - parms->Hrtf.Current.Delay[1]);
hrtfparams.Steps.Delay[1] = fastf2i((ALfloat)delaydiff * Delta); hrtfparams.Steps.Delay[1] = fastf2i((ALfloat)delaydiff * Delta);
} }
hrtfparams.Target = &parms->Hrtf[chan].Target; hrtfparams.Target = &parms->Hrtf.Target;
hrtfparams.Current = &parms->Hrtf[chan].Current; hrtfparams.Current = &parms->Hrtf.Current;
lidx = GetChannelIdxByName(Device->RealOut, FrontLeft); lidx = GetChannelIdxByName(Device->RealOut, FrontLeft);
ridx = GetChannelIdxByName(Device->RealOut, FrontRight); ridx = GetChannelIdxByName(Device->RealOut, FrontRight);
@ -641,15 +640,15 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
MixHrtfSamples(voice->DirectOut.Buffer, lidx, ridx, samples, Counter, MixHrtfSamples(voice->DirectOut.Buffer, lidx, ridx, samples, Counter,
voice->Offset, OutPos, IrSize, &hrtfparams, voice->Offset, OutPos, IrSize, &hrtfparams,
&parms->Hrtf[chan].State, DstBufferSize); &parms->Hrtf.State, DstBufferSize);
} }
} }
for(j = 0;j < Device->NumAuxSends;j++) for(j = 0;j < Device->NumAuxSends;j++)
{ {
SendParams *parms = &voice->Send[j]; SendParams *parms = &voice->Chan[chan].Send[j];
ALfloat *restrict currents = parms->Gains[chan].Current; ALfloat *restrict currents = parms->Gains.Current;
const ALfloat *targets = parms->Gains[chan].Target; const ALfloat *targets = parms->Gains.Target;
MixGains gains[MAX_OUTPUT_CHANNELS]; MixGains gains[MAX_OUTPUT_CHANNELS];
const ALfloat *samples; const ALfloat *samples;
@ -657,9 +656,8 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
continue; continue;
samples = DoFilters( samples = DoFilters(
&parms->Filters[chan].LowPass, &parms->Filters[chan].HighPass, &parms->LowPass, &parms->HighPass, Device->FilteredData,
Device->FilteredData, ResampledData, DstBufferSize, ResampledData, DstBufferSize, parms->FilterType
parms->Filters[chan].ActiveType
); );
if(!Counter) if(!Counter)

View File

@ -51,8 +51,10 @@ typedef struct ALvoice {
ALuint Channels; ALuint Channels;
} SendOut[MAX_SENDS]; } SendOut[MAX_SENDS];
DirectParams Direct; struct {
SendParams Send[MAX_SENDS]; DirectParams Direct;
SendParams Send[MAX_SENDS];
} Chan[MAX_INPUT_CHANNELS];
} ALvoice; } ALvoice;

View File

@ -125,35 +125,31 @@ typedef struct MixHrtfParams {
} MixHrtfParams; } MixHrtfParams;
typedef struct DirectParams { typedef struct DirectParams {
struct { enum ActiveFilters FilterType;
enum ActiveFilters ActiveType; ALfilterState LowPass;
ALfilterState LowPass; ALfilterState HighPass;
ALfilterState HighPass;
} Filters[MAX_INPUT_CHANNELS];
struct { struct {
HrtfParams Current; HrtfParams Current;
HrtfParams Target; HrtfParams Target;
HrtfState State; HrtfState State;
} Hrtf[MAX_INPUT_CHANNELS]; } Hrtf;
struct { struct {
ALfloat Current[MAX_OUTPUT_CHANNELS]; ALfloat Current[MAX_OUTPUT_CHANNELS];
ALfloat Target[MAX_OUTPUT_CHANNELS]; ALfloat Target[MAX_OUTPUT_CHANNELS];
} Gains[MAX_INPUT_CHANNELS]; } Gains;
} DirectParams; } DirectParams;
typedef struct SendParams { typedef struct SendParams {
struct { enum ActiveFilters FilterType;
enum ActiveFilters ActiveType; ALfilterState LowPass;
ALfilterState LowPass; ALfilterState HighPass;
ALfilterState HighPass;
} Filters[MAX_INPUT_CHANNELS];
struct { struct {
ALfloat Current[MAX_OUTPUT_CHANNELS]; ALfloat Current[MAX_OUTPUT_CHANNELS];
ALfloat Target[MAX_OUTPUT_CHANNELS]; ALfloat Target[MAX_OUTPUT_CHANNELS];
} Gains[MAX_INPUT_CHANNELS]; } Gains;
} SendParams; } SendParams;

View File

@ -3005,11 +3005,11 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
{ {
ALsizei j; ALsizei j;
for(j = 0;j < HRTF_HISTORY_LENGTH;j++) for(j = 0;j < HRTF_HISTORY_LENGTH;j++)
voice->Direct.Hrtf[i].State.History[j] = 0.0f; voice->Chan[i].Direct.Hrtf.State.History[j] = 0.0f;
for(j = 0;j < HRIR_LENGTH;j++) for(j = 0;j < HRIR_LENGTH;j++)
{ {
voice->Direct.Hrtf[i].State.Values[j][0] = 0.0f; voice->Chan[i].Direct.Hrtf.State.Values[j][0] = 0.0f;
voice->Direct.Hrtf[i].State.Values[j][1] = 0.0f; voice->Chan[i].Direct.Hrtf.State.Values[j][1] = 0.0f;
} }
} }