diff options
-rw-r--r-- | Alc/ALu.c | 2 | ||||
-rw-r--r-- | Alc/hrtf.c | 6 | ||||
-rw-r--r-- | Alc/hrtf.h | 2 | ||||
-rw-r--r-- | Alc/panning.c | 9 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 6 |
5 files changed, 14 insertions, 11 deletions
@@ -1504,7 +1504,7 @@ void aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) { HrtfMix(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], device->Dry.Buffer[c], state->Offset, state->IrSize, - state->Coeffs[c], state->Values[c], SamplesToDo + state->Chan[c].Coeffs, state->Chan[c].Values, SamplesToDo ); } state->Offset += SamplesToDo; @@ -136,7 +136,7 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, } -ALsizei BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][2], ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[2][MAX_AMBI_COEFFS], ALsizei AmbiCount) +ALsizei BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[2][MAX_AMBI_COEFFS], ALsizei AmbiCount) { /* Set this to 2 for dual-band HRTF processing. May require a higher quality * band-splitter, or better calculation of the new IR length to deal with the @@ -206,7 +206,7 @@ ALsizei BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH] { ALsizei k = 0; for(j = delay;j < HRIR_LENGTH;++j) - coeffs[i][j][0] += temps[b][k++] * AmbiMatrix[c][b][i]; + state->Chan[i].Coeffs[j][0] += temps[b][k++] * AmbiMatrix[c][b][i]; } } max_length = maxi(max_length, mini(delay + Hrtf->irSize, HRIR_LENGTH)); @@ -235,7 +235,7 @@ ALsizei BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH] { ALuint k = 0; for(j = delay;j < HRIR_LENGTH;++j) - coeffs[i][j][1] += temps[b][k++] * AmbiMatrix[c][b][i]; + state->Chan[i].Coeffs[j][1] += temps[b][k++] * AmbiMatrix[c][b][i]; } } max_length = maxi(max_length, mini(delay + Hrtf->irSize, HRIR_LENGTH)); @@ -44,6 +44,6 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, * returned coefficients are ordered and scaled according to the matrices. * Returns the maximum impulse-response length of the generated coefficients. */ -ALsizei BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][2], ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[2][MAX_AMBI_COEFFS], ALsizei AmbiCount); +ALsizei BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[2][MAX_AMBI_COEFFS], ALsizei AmbiCount); #endif /* ALC_HRTF_H */ diff --git a/Alc/panning.c b/Alc/panning.c index 728001c2..0ff58c3a 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -927,11 +927,14 @@ static void InitHrtfPanning(ALCdevice *device, bool hoa_mode) }; const ALfloat (*AmbiMatrix)[2][MAX_AMBI_COEFFS] = hoa_mode ? AmbiMatrixHOA : AmbiMatrixFOA; ALsizei count = hoa_mode ? 9 : 4; + size_t sizeof_hrtfstate; ALsizei i; - static_assert(9 <= COUNTOF(device->Hrtf->Coeffs), "ALCdevice::Hrtf.Values/Coeffs size is too small"); static_assert(COUNTOF(AmbiPoints) <= HRTF_AMBI_MAX_CHANNELS, "HRTF_AMBI_MAX_CHANNELS is too small"); + sizeof_hrtfstate = offsetof(DirectHrtfState, Chan[count]); + device->Hrtf = al_calloc(16, sizeof_hrtfstate); + for(i = 0;i < count;i++) { device->Dry.Ambi.Map[i].Scale = 1.0f; @@ -962,9 +965,8 @@ static void InitHrtfPanning(ALCdevice *device, bool hoa_mode) device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans); - memset(device->Hrtf->Coeffs, 0, sizeof(device->Hrtf->Coeffs)); device->Hrtf->IrSize = BuildBFormatHrtf(device->HrtfHandle, - device->Hrtf->Coeffs, device->Dry.NumChannels, + device->Hrtf, device->Dry.NumChannels, AmbiPoints, AmbiMatrix, COUNTOF(AmbiPoints) ); @@ -1196,7 +1198,6 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf device->AmbiUp = ambiup_alloc(); hoa_mode = true; } - device->Hrtf = al_calloc(16, sizeof(device->Hrtf[0])); TRACE("%s HRTF rendering enabled, using \"%s\"\n", ((device->Render_Mode == HrtfRender) ? "Full" : "Basic"), diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index b2e1bfcf..04fb7239 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -624,10 +624,12 @@ typedef struct HrtfParams { typedef struct DirectHrtfState { /* HRTF filter state for dry buffer content */ - alignas(16) ALfloat Values[9][HRIR_LENGTH][2]; - alignas(16) ALfloat Coeffs[9][HRIR_LENGTH][2]; ALsizei Offset; ALsizei IrSize; + struct { + alignas(16) ALfloat Values[HRIR_LENGTH][2]; + alignas(16) ALfloat Coeffs[HRIR_LENGTH][2]; + } Chan[]; } DirectHrtfState; typedef struct HrtfEntry { |