diff options
author | Chris Robinson <[email protected]> | 2011-06-03 01:06:00 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-06-03 01:06:00 -0700 |
commit | 7ddfacb58f941b21da26b2749d3204307e3a0bbd (patch) | |
tree | 2cb41f7de025705f38a634781e6413c7c004829e /OpenAL32 | |
parent | c7a80418d9291cad29dc293b95a5c328f4408b08 (diff) |
Use a minimum phase HRTF data set
This reduces the coefficient size from 128 down to 32, with a set of delays
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 9 | ||||
-rw-r--r-- | OpenAL32/Include/alSource.h | 14 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 7 |
3 files changed, 20 insertions, 10 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index b6986a07..8df5a4b9 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -567,10 +567,11 @@ const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans); ALboolean IsValidType(ALenum type); ALboolean IsValidChannels(ALenum type); -#define HRTF_BITS (7) -#define HRTF_LENGTH (1<<HRTF_BITS) -#define HRTF_LENGTH_MASK (HRTF_LENGTH-1) -void GetHrtfCoeffs(ALfloat elevation, ALfloat angle, const ALshort **left, const ALshort **right); +#define HRIR_BITS (5) +#define HRIR_LENGTH (1<<HRIR_BITS) +#define HRIR_LENGTH_MASK (HRIR_LENGTH-1) +void InitHrtf(void); +void GetHrtfCoeffs(ALfloat elevation, ALfloat angle, const ALshort **left, const ALshort **right, ALuint *ldelay, ALuint *rdelay); void al_print(const char *fname, unsigned int line, const char *fmt, ...) PRINTF_STYLE(3,4); diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 53d7f53c..0572cbc1 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -11,6 +11,10 @@ extern "C" { #endif +#define SRC_HISTORY_BITS (7) +#define SRC_HISTORY_LENGTH (1<<SRC_HISTORY_BITS) +#define SRC_HISTORY_MASK (SRC_HISTORY_LENGTH-1) + typedef enum { POINT_RESAMPLER = 0, LINEAR_RESAMPLER, @@ -90,20 +94,21 @@ typedef struct ALsource ALuint SampleSize; /* HRTF info */ - ALfloat HrtfHistory[MAXCHANNELS][HRTF_LENGTH]; + ALfloat HrtfHistory[MAXCHANNELS][SRC_HISTORY_LENGTH][2]; ALuint HrtfOffset; - // Current target parameters used for mixing - ALboolean NeedsUpdate; + /* Current target parameters used for mixing */ struct { ALint Step; - ALfloat HrtfCoeffs[MAXCHANNELS][HRTF_LENGTH][2]; + ALfloat HrtfCoeffs[MAXCHANNELS][HRIR_LENGTH][2]; + ALuint HrtfDelay[MAXCHANNELS][2]; /* A mixing matrix. First subscript is the channel number of the input * data (regardless of channel configuration) and the second is the * channel target (eg. FRONT_LEFT) */ ALfloat DryGains[MAXCHANNELS][MAXCHANNELS]; + FILTER iirFilter; ALfloat history[MAXCHANNELS*2]; @@ -113,6 +118,7 @@ typedef struct ALsource ALfloat history[MAXCHANNELS]; } Send[MAX_SENDS]; } Params; + ALboolean NeedsUpdate; ALvoid (*Update)(struct ALsource *self, const ALCcontext *context); ALvoid (*DoMix)(struct ALsource *self, ALCdevice *Device, diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 6c6bf44b..7dc4a2a9 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -1355,8 +1355,11 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) for(j = 0;j < MAXCHANNELS;j++) { ALuint k; - for(k = 0;k < HRTF_LENGTH;k++) - Source->HrtfHistory[j][k] = 0.0f; + for(k = 0;k < SRC_HISTORY_LENGTH;k++) + { + Source->HrtfHistory[j][k][0] = 0.0f; + Source->HrtfHistory[j][k][1] = 0.0f; + } } Source->HrtfOffset = 0; } |