1 /* FAudio - XAudio Reimplementation for FNA
3 * Copyright (c) 2011-2022 Ethan Lee, Luigi Auriemma, and the MonoGame Team
5 * This software is provided 'as-is', without any express or implied warranty.
6 * In no event will the authors be held liable for any damages arising from
7 * the use of this software.
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software in a
15 * product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
21 * 3. This notice may not be removed or altered from any source distribution.
23 * Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
29 uint32_t FACT3DInitialize(
30 FACTAudioEngine
*pEngine
,
31 F3DAUDIO_HANDLE F3DInstance
34 FAudioWaveFormatExtensible wfxFinalMixFormat
;
41 FACTAudioEngine_GetGlobalVariable(
43 FACTAudioEngine_GetGlobalVariableIndex(
49 FACTAudioEngine_GetFinalMixFormat(
54 wfxFinalMixFormat
.dwChannelMask
,
61 uint32_t FACT3DCalculate(
62 F3DAUDIO_HANDLE F3DInstance
,
63 const F3DAUDIO_LISTENER
*pListener
,
64 F3DAUDIO_EMITTER
*pEmitter
,
65 F3DAUDIO_DSP_SETTINGS
*pDSPSettings
67 static F3DAUDIO_DISTANCE_CURVE_POINT DefaultCurvePoints
[2] =
72 static F3DAUDIO_DISTANCE_CURVE DefaultCurve
=
74 (F3DAUDIO_DISTANCE_CURVE_POINT
*) &DefaultCurvePoints
[0], 2
77 if (pListener
== NULL
|| pEmitter
== NULL
|| pDSPSettings
== NULL
)
82 if (pEmitter
->ChannelCount
> 1 && pEmitter
->pChannelAzimuths
== NULL
)
84 pEmitter
->ChannelRadius
= 1.0f
;
86 if (pEmitter
->ChannelCount
== 2)
88 pEmitter
->pChannelAzimuths
= (float*) &aStereoLayout
[0];
90 else if (pEmitter
->ChannelCount
== 3)
92 pEmitter
->pChannelAzimuths
= (float*) &a2Point1Layout
[0];
94 else if (pEmitter
->ChannelCount
== 4)
96 pEmitter
->pChannelAzimuths
= (float*) &aQuadLayout
[0];
98 else if (pEmitter
->ChannelCount
== 5)
100 pEmitter
->pChannelAzimuths
= (float*) &a4Point1Layout
[0];
102 else if (pEmitter
->ChannelCount
== 6)
104 pEmitter
->pChannelAzimuths
= (float*) &a5Point1Layout
[0];
106 else if (pEmitter
->ChannelCount
== 8)
108 pEmitter
->pChannelAzimuths
= (float*) &a7Point1Layout
[0];
116 if (pEmitter
->pVolumeCurve
== NULL
)
118 pEmitter
->pVolumeCurve
= &DefaultCurve
;
120 if (pEmitter
->pLFECurve
== NULL
)
122 pEmitter
->pLFECurve
= &DefaultCurve
;
130 F3DAUDIO_CALCULATE_MATRIX
|
131 F3DAUDIO_CALCULATE_DOPPLER
|
132 F3DAUDIO_CALCULATE_EMITTER_ANGLE
139 uint32_t FACT3DApply(
140 F3DAUDIO_DSP_SETTINGS
*pDSPSettings
,
143 if (pDSPSettings
== NULL
|| pCue
== NULL
)
148 FACTCue_SetMatrixCoefficients(
150 pDSPSettings
->SrcChannelCount
,
151 pDSPSettings
->DstChannelCount
,
152 pDSPSettings
->pMatrixCoefficients
156 FACTCue_GetVariableIndex(pCue
, "Distance"),
157 pDSPSettings
->EmitterToListenerDistance
161 FACTCue_GetVariableIndex(pCue
, "DopplerPitchScalar"),
162 pDSPSettings
->DopplerFactor
166 FACTCue_GetVariableIndex(pCue
, "OrientationAngle"),
167 pDSPSettings
->EmitterToListenerAngle
* (180.0f
/ F3DAUDIO_PI
)
172 /* vim: set noexpandtab shiftwidth=8 tabstop=8: */