diff options
author | Chris Robinson <[email protected]> | 2016-01-25 06:11:51 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-01-25 06:11:51 -0800 |
commit | f547ef6d391be5e0cd3e0477c3f8de859a47df69 (patch) | |
tree | d135e13f3a204af7eaac97a71744e308da661fe2 /OpenAL32/Include/alu.h | |
parent | 79e0f3e747880a3e7d8342a8602b796b84c0f322 (diff) |
Separate calculating ambisonic coefficients from the panning gains
Diffstat (limited to 'OpenAL32/Include/alu.h')
-rw-r--r-- | OpenAL32/Include/alu.h | 48 |
1 files changed, 34 insertions, 14 deletions
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); |