aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h7
-rw-r--r--OpenAL32/Include/alu.h9
-rw-r--r--OpenAL32/alSource.c12
3 files changed, 27 insertions, 1 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index cc30dcef..e4c5b94a 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -726,6 +726,7 @@ struct ALCdevice_struct
alignas(16) ALfloat SourceData[BUFFERSIZE];
alignas(16) ALfloat ResampledData[BUFFERSIZE];
alignas(16) ALfloat FilteredData[BUFFERSIZE];
+ alignas(16) ALfloat NFCtrlData[BUFFERSIZE];
/* The "dry" path corresponds to the main output. */
struct {
@@ -738,6 +739,7 @@ struct ALCdevice_struct
ALfloat (*Buffer)[BUFFERSIZE];
ALsizei NumChannels;
+ ALsizei NumChannelsPerOrder[MAX_AMBI_ORDER+1];
} Dry;
/* First-order ambisonics output, to be upsampled to the dry buffer if different. */
@@ -760,6 +762,11 @@ struct ALCdevice_struct
ALsizei NumChannels;
} RealOut;
+ /* The average speaker distance as determined by the ambdec configuration
+ * (or alternatively, by the NFC-HOA reference delay). Only used for NFC.
+ */
+ ALfloat AvgSpeakerDist;
+
/* Delay buffers used to compensate for speaker distances. */
DistanceComp ChannelDelay[MAX_OUTPUT_CHANNELS];
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 03f0090d..6c374ebc 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -17,6 +17,7 @@
#include "hrtf.h"
#include "align.h"
+#include "nfcfilter.h"
#include "math_defs.h"
@@ -129,6 +130,8 @@ typedef struct DirectParams {
ALfilterState LowPass;
ALfilterState HighPass;
+ NfcFilter NFCtrlFilter[MAX_AMBI_ORDER];
+
struct {
HrtfParams Current;
HrtfParams Target;
@@ -152,6 +155,9 @@ typedef struct SendParams {
} Gains;
} SendParams;
+#define VOICE_IS_HRTF (1<<0)
+#define VOICE_HAS_NFC (1<<1)
+
typedef struct ALvoice {
struct ALsourceProps *Props;
@@ -182,7 +188,7 @@ typedef struct ALvoice {
/* If not 'moving', gain/coefficients are set directly without fading. */
ALboolean Moving;
- ALboolean IsHrtf;
+ ALuint Flags;
ALuint Offset; /* Number of output samples mixed since starting. */
@@ -195,6 +201,7 @@ typedef struct ALvoice {
ALfloat (*Buffer)[BUFFERSIZE];
ALsizei Channels;
+ ALsizei ChannelsPerOrder[MAX_AMBI_ORDER+1];
} Direct;
struct {
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index c4c0bfb1..55a4aae1 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -3084,6 +3084,7 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
voice->Step = 0;
voice->Moving = AL_FALSE;
+ voice->Flags = 0;
for(i = 0;i < MAX_INPUT_CHANNELS;i++)
{
ALsizei j;
@@ -3095,6 +3096,17 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
voice->Direct.Params[i].Hrtf.State.Values[j][1] = 0.0f;
}
}
+ if(device->AvgSpeakerDist > 0.0f)
+ {
+ ALfloat w1 = SPEEDOFSOUNDMETRESPERSEC /
+ (device->AvgSpeakerDist * device->Frequency);
+ for(i = 0;i < voice->NumChannels;i++)
+ {
+ NfcFilterCreate1(&voice->Direct.Params[i].NFCtrlFilter[0], 0.0f, w1);
+ NfcFilterCreate2(&voice->Direct.Params[i].NFCtrlFilter[1], 0.0f, w1);
+ NfcFilterCreate3(&voice->Direct.Params[i].NFCtrlFilter[2], 0.0f, w1);
+ }
+ }
ATOMIC_STORE(&voice->Source, Source, almemory_order_relaxed);
ATOMIC_STORE(&voice->Playing, true, almemory_order_release);