aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-11-23 10:49:54 -0800
committerChris Robinson <[email protected]>2014-11-23 10:49:54 -0800
commit45d6bb58a4293c5b1ab229cea86e0ef24a2a084b (patch)
treeec03ad6eac812ae209f8d973687afa5b99616133 /OpenAL32
parentfc3608b381c0492674b4cfc1da0dcf5389ace722 (diff)
Partially revert "Use a different method for HRTF mixing"
The sound localization with virtual channel mixing was just too poor, so while it's more costly to do per-source HRTF mixing, it's unavoidable if you want good localization. This is only partially reverted because having the virtual channel is still beneficial, particularly with B-Format rendering and effect mixing which otherwise skip HRTF processing. As before, the number of virtual channels can potentially be customized, specifying more or less channels depending on the system's needs.
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h2
-rw-r--r--OpenAL32/Include/alu.h10
-rw-r--r--OpenAL32/alSource.c11
3 files changed, 22 insertions, 1 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 56df4db3..1afeb1e6 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -617,7 +617,9 @@ typedef struct HrtfState {
typedef struct HrtfParams {
alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
+ alignas(16) ALfloat CoeffStep[HRIR_LENGTH][2];
ALuint Delay[2];
+ ALint DelayStep[2];
} HrtfParams;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 56c37fe8..0462fda8 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -71,6 +71,13 @@ typedef struct DirectParams {
ALfilterState HighPass;
} Filters[MAX_INPUT_CHANNELS];
+ struct {
+ HrtfParams Params[MAX_INPUT_CHANNELS];
+ HrtfState State[MAX_INPUT_CHANNELS];
+ ALuint IrSize;
+ ALfloat Gain;
+ ALfloat Dir[3];
+ } Hrtf;
MixGains Gains[MAX_INPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
} DirectParams;
@@ -99,7 +106,8 @@ typedef void (*MixerFunc)(const ALfloat *data, ALuint OutChans,
ALfloat (*restrict OutBuffer)[BUFFERSIZE], struct MixGains *Gains,
ALuint Counter, ALuint OutPos, ALuint BufferSize);
typedef void (*HrtfMixerFunc)(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
- ALuint Offset, const ALuint IrSize, const HrtfParams *hrtfparams,
+ ALuint Counter, ALuint Offset, ALuint OutPos,
+ const ALuint IrSize, const HrtfParams *hrtfparams,
HrtfState *hrtfstate, ALuint BufferSize);
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 12bd9436..be3768f3 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -2599,6 +2599,17 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
voice->Direct.Moving = AL_FALSE;
voice->Direct.Counter = 0;
+ for(i = 0;i < MAX_INPUT_CHANNELS;i++)
+ {
+ ALsizei j;
+ for(j = 0;j < HRTF_HISTORY_LENGTH;j++)
+ voice->Direct.Hrtf.State[i].History[j] = 0.0f;
+ for(j = 0;j < HRIR_LENGTH;j++)
+ {
+ voice->Direct.Hrtf.State[i].Values[j][0] = 0.0f;
+ voice->Direct.Hrtf.State[i].Values[j][1] = 0.0f;
+ }
+ }
for(i = 0;i < (ALsizei)device->NumAuxSends;i++)
{
voice->Send[i].Moving = AL_FALSE;