aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-01-25 06:11:51 -0800
committerChris Robinson <[email protected]>2016-01-25 06:11:51 -0800
commitf547ef6d391be5e0cd3e0477c3f8de859a47df69 (patch)
treed135e13f3a204af7eaac97a71744e308da661fe2 /OpenAL32
parent79e0f3e747880a3e7d8342a8602b796b84c0f322 (diff)
Separate calculating ambisonic coefficients from the panning gains
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h4
-rw-r--r--OpenAL32/Include/alu.h48
2 files changed, 36 insertions, 16 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 0f0d3ef8..bc768406 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -21,7 +21,7 @@ struct ALeffectStateVtable {
void (*const Destruct)(ALeffectState *state);
ALboolean (*const deviceUpdate)(ALeffectState *state, ALCdevice *device);
- void (*const update)(ALeffectState *state, ALCdevice *device, const struct ALeffectslot *slot);
+ void (*const update)(ALeffectState *state, const ALCdevice *device, const struct ALeffectslot *slot);
void (*const process)(ALeffectState *state, ALuint samplesToDo, const ALfloat *restrict samplesIn, ALfloat (*restrict samplesOut)[BUFFERSIZE], ALuint numChannels);
void (*const Delete)(void *ptr);
@@ -30,7 +30,7 @@ struct ALeffectStateVtable {
#define DEFINE_ALEFFECTSTATE_VTABLE(T) \
DECLARE_THUNK(T, ALeffectState, void, Destruct) \
DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \
-DECLARE_THUNK2(T, ALeffectState, void, update, ALCdevice*, const ALeffectslot*) \
+DECLARE_THUNK2(T, ALeffectState, void, update, const ALCdevice*, const ALeffectslot*) \
DECLARE_THUNK4(T, ALeffectState, void, process, ALuint, const ALfloat*restrict, ALfloatBUFFERSIZE*restrict, ALuint) \
static void T##_ALeffectState_Delete(void *ptr) \
{ return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index a309c4ab..5f5493c5 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -277,36 +277,56 @@ void aluInitMixer(void);
ALvoid aluInitPanning(ALCdevice *Device);
/**
- * ComputeDirectionalGains
+ * CalcDirectionCoeffs
*
- * Sets channel gains based on a direction. The direction must be a 3-component
- * vector no longer than 1 unit.
+ * Calculates ambisonic coefficients based on a direction vector. The vector
+ * must not be longer than 1 unit.
*/
-void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+void CalcDirectionCoeffs(const ALfloat dir[3], ALfloat coeffs[MAX_AMBI_COEFFS]);
/**
- * ComputeAngleGains
+ * CalcXYZCoeffs
*
- * Sets channel gains based on angle and elevation. The angle and elevation
- * parameters are in radians, going right and up respectively.
+ * Same as CalcDirectionCoeffs except the direction is specified as separate x,
+ * y, and z parameters instead of an array.
*/
-void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+inline void CalcXYZCoeffs(ALfloat x, ALfloat y, ALfloat z, ALfloat coeffs[MAX_AMBI_COEFFS])
+{
+ ALfloat dir[3] = { x, y, z };
+ CalcDirectionCoeffs(dir, coeffs);
+}
+
+/**
+ * CalcAngleCoeffs
+ *
+ * Calculates ambisonic coefficients based on angle and elevation. The angle
+ * and elevation parameters are in radians, going right and up respectively.
+ */
+void CalcAngleCoeffs(ALfloat angle, ALfloat elevation, ALfloat coeffs[MAX_AMBI_COEFFS]);
/**
* ComputeAmbientGains
*
- * Sets channel gains for ambient, omni-directional sounds.
+ * Computes channel gains for ambient, omni-directional sounds.
+ */
+void ComputeAmbientGains(const ChannelConfig *chancoeffs, ALuint numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+
+/**
+ * ComputePanningGains
+ *
+ * Computes panning gains using the given channel decoder coefficients and the
+ * pre-calculated direction or angle coefficients.
*/
-void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+void ComputePanningGains(const ChannelConfig *chancoeffs, ALuint numchans, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
* ComputeBFormatGains
*
- * Sets channel gains for a given (first-order) B-Format channel. The matrix is
- * a 1x4 'slice' of the rotation matrix for a given channel used to orient the
- * coefficients.
+ * Sets channel gains for a given (first-order) B-Format input channel. The
+ * matrix is a 1x4 'slice' of the rotation matrix for the given channel used to
+ * orient the soundfield.
*/
-void ComputeBFormatGains(const ALCdevice *device, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+void ComputeBFormatGains(const ChannelConfig *chancoeffs, ALuint numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
ALvoid UpdateContextSources(ALCcontext *context);