diff options
author | Chris Robinson <[email protected]> | 2016-01-28 00:02:46 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-01-28 00:02:46 -0800 |
commit | c1f87414c5452f595f78b7a52a7063a023ce2982 (patch) | |
tree | 7a8b3007d1cf3ff7b05edc45c5ac7962c3dbbbaf /OpenAL32 | |
parent | 2fa3ae85c9a4050eab3a4f140fb6accd0a02ce85 (diff) |
Mix to multichannel for effects
This mixes to a 4-channel first-order ambisonics buffer. With ACN ordering and
N3D scaling, this makes it easy to remain compatible with effects that only
care about mono input since channel 0 is an unattenuated mono signal.
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alAuxEffectSlot.h | 19 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 10 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 2 |
3 files changed, 25 insertions, 6 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index bbb112be..3f677fd1 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -64,6 +64,9 @@ static const struct ALeffectStateFactoryVtable T##_ALeffectStateFactory_vtable = } +#define MAX_EFFECT_CHANNELS (4) + + typedef struct ALeffectslot { ALenum EffectType; ALeffectProps EffectProps; @@ -74,12 +77,24 @@ typedef struct ALeffectslot { ATOMIC(ALenum) NeedsUpdate; ALeffectState *EffectState; - alignas(16) ALfloat WetBuffer[1][BUFFERSIZE]; - RefCount ref; /* Self ID */ ALuint id; + + ALuint NumChannels; + ChannelConfig AmbiCoeffs[MAX_EFFECT_CHANNELS]; + /* Wet buffer configuration is ACN channel order with N3D scaling: + * * Channel 0 is the unattenuated mono signal. + * * Channel 1 is OpenAL -X + * * Channel 2 is OpenAL Y + * * Channel 3 is OpenAL -Z + * Consequently, effects that only want to work with mono input can use + * channel 0 by itself. Effects that want multichannel can process the + * ambisonics signal and create a B-Format pan (ComputeBFormatGains) for + * the device output. + */ + alignas(16) ALfloat WetBuffer[MAX_EFFECT_CHANNELS][BUFFERSIZE]; } ALeffectslot; inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 5f5493c5..63a03adc 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -13,6 +13,7 @@ #include "alMain.h" #include "alBuffer.h" #include "alFilter.h" +#include "alAuxEffectSlot.h" #include "hrtf.h" #include "align.h" @@ -34,6 +35,7 @@ extern "C" { struct ALsource; struct ALvoice; +struct ALeffectslot; /* The number of distinct scale and phase intervals within the filter table. */ @@ -164,6 +166,7 @@ typedef struct DirectParams { typedef struct SendParams { ALfloat (*OutBuffer)[BUFFERSIZE]; + ALuint OutChannels; ALboolean Moving; ALuint Counter; @@ -173,10 +176,7 @@ typedef struct SendParams { ALfilterState LowPass; ALfilterState HighPass; } Filters[MAX_INPUT_CHANNELS]; - - /* Gain control, which applies to each input channel to a single (mono) - * output buffer. */ - MixGains Gains[MAX_INPUT_CHANNELS]; + MixGains Gains[MAX_INPUT_CHANNELS][MAX_EFFECT_CHANNELS]; } SendParams; @@ -276,6 +276,8 @@ void aluInitMixer(void); ALvoid aluInitPanning(ALCdevice *Device); +void aluInitEffectPanning(struct ALeffectslot *slot); + /** * CalcDirectionCoeffs * diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index c1314301..b0dba25d 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -90,6 +90,8 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo SET_ERROR_AND_GOTO(context, err, done); } + aluInitEffectPanning(slot); + VECTOR_PUSH_BACK(slotvec, slot); effectslots[cur] = slot->id; |