AkSpeakerConfig.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. #ifndef _AK_SPEAKERCONFIG_H_
  21. #define _AK_SPEAKERCONFIG_H_
  22. #include <AK/SoundEngine/Common/AkTypes.h>
  23. #include <AK/Tools/Common/AkPlatformFuncs.h>
  24. /// Standard speakers (channel mask):
  25. #define AK_SPEAKER_FRONT_LEFT 0x1 ///< Front left speaker bit mask
  26. #define AK_SPEAKER_FRONT_RIGHT 0x2 ///< Front right speaker bit mask
  27. #define AK_SPEAKER_FRONT_CENTER 0x4 ///< Front center speaker bit mask
  28. #define AK_SPEAKER_LOW_FREQUENCY 0x8 ///< Low-frequency speaker bit mask
  29. #define AK_SPEAKER_BACK_LEFT 0x10 ///< Rear left speaker bit mask
  30. #define AK_SPEAKER_BACK_RIGHT 0x20 ///< Rear right speaker bit mask
  31. #define AK_SPEAKER_BACK_CENTER 0x100 ///< Rear center speaker ("surround speaker") bit mask
  32. #define AK_SPEAKER_SIDE_LEFT 0x200 ///< Side left speaker bit mask
  33. #define AK_SPEAKER_SIDE_RIGHT 0x400 ///< Side right speaker bit mask
  34. /// "Height" speakers.
  35. #define AK_SPEAKER_TOP 0x800 ///< Top speaker bit mask
  36. #define AK_SPEAKER_HEIGHT_FRONT_LEFT 0x1000 ///< Front left speaker bit mask
  37. #define AK_SPEAKER_HEIGHT_FRONT_CENTER 0x2000 ///< Front center speaker bit mask
  38. #define AK_SPEAKER_HEIGHT_FRONT_RIGHT 0x4000 ///< Front right speaker bit mask
  39. #define AK_SPEAKER_HEIGHT_BACK_LEFT 0x8000 ///< Rear left speaker bit mask
  40. #define AK_SPEAKER_HEIGHT_BACK_CENTER 0x10000 ///< Rear center speaker bit mask
  41. #define AK_SPEAKER_HEIGHT_BACK_RIGHT 0x20000 ///< Rear right speaker bit mask
  42. //
  43. // Supported speaker setups. Those are the ones that can be used in the Wwise Sound Engine audio pipeline.
  44. //
  45. #define AK_SPEAKER_SETUP_MONO AK_SPEAKER_FRONT_CENTER ///< 1.0 setup channel mask
  46. #define AK_SPEAKER_SETUP_0POINT1 AK_SPEAKER_LOW_FREQUENCY ///< 0.1 setup channel mask
  47. #define AK_SPEAKER_SETUP_1POINT1 (AK_SPEAKER_FRONT_CENTER | AK_SPEAKER_LOW_FREQUENCY) ///< 1.1 setup channel mask
  48. #define AK_SPEAKER_SETUP_STEREO (AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT) ///< 2.0 setup channel mask
  49. #define AK_SPEAKER_SETUP_2POINT1 (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_LOW_FREQUENCY) ///< 2.1 setup channel mask
  50. #define AK_SPEAKER_SETUP_3STEREO (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_FRONT_CENTER) ///< 3.0 setup channel mask
  51. #define AK_SPEAKER_SETUP_3POINT1 (AK_SPEAKER_SETUP_3STEREO | AK_SPEAKER_LOW_FREQUENCY) ///< 3.1 setup channel mask
  52. #define AK_SPEAKER_SETUP_4 (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT) ///< 4.0 setup channel mask
  53. #define AK_SPEAKER_SETUP_4POINT1 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_LOW_FREQUENCY) ///< 4.1 setup channel mask
  54. #define AK_SPEAKER_SETUP_5 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_FRONT_CENTER) ///< 5.0 setup channel mask
  55. #define AK_SPEAKER_SETUP_5POINT1 (AK_SPEAKER_SETUP_5 | AK_SPEAKER_LOW_FREQUENCY) ///< 5.1 setup channel mask
  56. #define AK_SPEAKER_SETUP_6 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT) ///< 6.0 setup channel mask
  57. #define AK_SPEAKER_SETUP_6POINT1 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_LOW_FREQUENCY) ///< 6.1 setup channel mask
  58. #define AK_SPEAKER_SETUP_7 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_FRONT_CENTER) ///< 7.0 setup channel mask
  59. #define AK_SPEAKER_SETUP_7POINT1 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_LOW_FREQUENCY) ///< 7.1 setup channel mask
  60. #define AK_SPEAKER_SETUP_SURROUND (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_BACK_CENTER) ///< Legacy surround setup channel mask
  61. // Note. DPL2 does not really have 4 channels, but it is used by plugins to differentiate from stereo setup.
  62. #define AK_SPEAKER_SETUP_DPL2 (AK_SPEAKER_SETUP_4) ///< Legacy DPL2 setup channel mask
  63. #define AK_SPEAKER_SETUP_HEIGHT_2 (AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT) ///< 2 speaker height layer.
  64. #define AK_SPEAKER_SETUP_HEIGHT_4 (AK_SPEAKER_SETUP_HEIGHT_2 | AK_SPEAKER_HEIGHT_BACK_LEFT | AK_SPEAKER_HEIGHT_BACK_RIGHT) ///< 4 speaker height layer.
  65. #define AK_SPEAKER_SETUP_HEIGHT_5 (AK_SPEAKER_SETUP_HEIGHT_4 | AK_SPEAKER_HEIGHT_FRONT_CENTER) ///< 5 speaker height layer.
  66. #define AK_SPEAKER_SETUP_HEIGHT_ALL (AK_SPEAKER_SETUP_HEIGHT_5 | AK_SPEAKER_HEIGHT_BACK_CENTER) ///< All height speaker layer.
  67. #define AK_SPEAKER_SETUP_HEIGHT_4_TOP (AK_SPEAKER_SETUP_HEIGHT_4 | AK_SPEAKER_TOP) ///< 4 speaker height layer + top.
  68. #define AK_SPEAKER_SETUP_HEIGHT_5_TOP (AK_SPEAKER_SETUP_HEIGHT_5 | AK_SPEAKER_TOP) ///< 5 speaker height layer + top.
  69. // Auro speaker setups
  70. #define AK_SPEAKER_SETUP_AURO_222 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT) ///< Auro-222 setup channel mask (4.0.2)
  71. #define AK_SPEAKER_SETUP_AURO_8 (AK_SPEAKER_SETUP_AURO_222 | AK_SPEAKER_HEIGHT_BACK_LEFT | AK_SPEAKER_HEIGHT_BACK_RIGHT) ///< Auro-8 setup channel mask (4.0.4)
  72. #define AK_SPEAKER_SETUP_AURO_9 (AK_SPEAKER_SETUP_AURO_8 | AK_SPEAKER_FRONT_CENTER) ///< Auro-9.0 setup channel mask (5.0.4)
  73. #define AK_SPEAKER_SETUP_AURO_9POINT1 (AK_SPEAKER_SETUP_AURO_9 | AK_SPEAKER_LOW_FREQUENCY) ///< Auro-9.1 setup channel mask (5.1.4)
  74. #define AK_SPEAKER_SETUP_AURO_10 (AK_SPEAKER_SETUP_AURO_9 | AK_SPEAKER_TOP) ///< Auro-10.0 setup channel mask (5.0.4+top)
  75. #define AK_SPEAKER_SETUP_AURO_10POINT1 (AK_SPEAKER_SETUP_AURO_10 | AK_SPEAKER_LOW_FREQUENCY) ///< Auro-10.1 setup channel mask (5.1.4+top)
  76. #define AK_SPEAKER_SETUP_AURO_11 (AK_SPEAKER_SETUP_AURO_10 | AK_SPEAKER_HEIGHT_FRONT_CENTER) ///< Auro-11.0 setup channel mask (5.0.5+top)
  77. #define AK_SPEAKER_SETUP_AURO_11POINT1 (AK_SPEAKER_SETUP_AURO_11 | AK_SPEAKER_LOW_FREQUENCY) ///< Auro-11.1 setup channel mask (5.1.5+top)
  78. #define AK_SPEAKER_SETUP_AURO_11_740 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_SETUP_HEIGHT_4) ///< Auro-11.0 (7+4) setup channel mask (7.0.4)
  79. #define AK_SPEAKER_SETUP_AURO_11POINT1_740 (AK_SPEAKER_SETUP_AURO_11_740 | AK_SPEAKER_LOW_FREQUENCY) ///< Auro-11.1 (7+4) setup channel mask (7.1.4)
  80. #define AK_SPEAKER_SETUP_AURO_13_751 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_SETUP_HEIGHT_5 | AK_SPEAKER_TOP) ///< Auro-13.0 setup channel mask (7.0.5+top)
  81. #define AK_SPEAKER_SETUP_AURO_13POINT1_751 (AK_SPEAKER_SETUP_AURO_13_751 | AK_SPEAKER_LOW_FREQUENCY) ///< Auro-13.1 setup channel mask (7.1.5+top)
  82. // Dolby speaker setups: in Dolby nomenclature, [#plane].[lfe].[#height]
  83. #define AK_SPEAKER_SETUP_DOLBY_5_0_2 (AK_SPEAKER_SETUP_5 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT ) ///< Dolby 5.0.2 setup channel mask
  84. #define AK_SPEAKER_SETUP_DOLBY_5_1_2 (AK_SPEAKER_SETUP_DOLBY_5_0_2 | AK_SPEAKER_LOW_FREQUENCY ) ///< Dolby 5.1.2 setup channel mask
  85. #define AK_SPEAKER_SETUP_DOLBY_6_0_2 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT ) ///< Dolby 6.0.2 setup channel mask
  86. #define AK_SPEAKER_SETUP_DOLBY_6_1_2 (AK_SPEAKER_SETUP_DOLBY_6_0_2 | AK_SPEAKER_LOW_FREQUENCY ) ///< Dolby 6.1.2 setup channel mask
  87. #define AK_SPEAKER_SETUP_DOLBY_6_0_4 (AK_SPEAKER_SETUP_DOLBY_6_0_2 | AK_SPEAKER_HEIGHT_BACK_LEFT | AK_SPEAKER_HEIGHT_BACK_RIGHT ) ///< Dolby 6.0.4 setup channel mask
  88. #define AK_SPEAKER_SETUP_DOLBY_6_1_4 (AK_SPEAKER_SETUP_DOLBY_6_0_4 | AK_SPEAKER_LOW_FREQUENCY ) ///< Dolby 6.1.4 setup channel mask
  89. #define AK_SPEAKER_SETUP_DOLBY_7_0_2 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT ) ///< Dolby 7.0.2 setup channel mask
  90. #define AK_SPEAKER_SETUP_DOLBY_7_1_2 (AK_SPEAKER_SETUP_DOLBY_7_0_2 | AK_SPEAKER_LOW_FREQUENCY ) ///< Dolby 7.1.2 setup channel mask
  91. #define AK_SPEAKER_SETUP_DOLBY_7_0_4 (AK_SPEAKER_SETUP_DOLBY_7_0_2 | AK_SPEAKER_HEIGHT_BACK_LEFT | AK_SPEAKER_HEIGHT_BACK_RIGHT ) ///< Dolby 7.0.4 setup channel mask
  92. #define AK_SPEAKER_SETUP_DOLBY_7_1_4 (AK_SPEAKER_SETUP_DOLBY_7_0_4 | AK_SPEAKER_LOW_FREQUENCY ) ///< Dolby 7.1.4 setup channel mask
  93. #define AK_SPEAKER_SETUP_ALL_SPEAKERS (AK_SPEAKER_SETUP_7POINT1 | AK_SPEAKER_BACK_CENTER | AK_SPEAKER_SETUP_HEIGHT_ALL | AK_SPEAKER_TOP) ///< All speakers.
  94. // Channel indices.
  95. // ------------------------------------------------
  96. // Channel indices for standard setups on the plane.
  97. #define AK_IDX_SETUP_FRONT_LEFT (0) ///< Index of front-left channel in all configurations.
  98. #define AK_IDX_SETUP_FRONT_RIGHT (1) ///< Index of front-right channel in all configurations.
  99. #define AK_IDX_SETUP_CENTER (2) ///< Index of front-center channel in all configurations.
  100. #define AK_IDX_SETUP_NOCENTER_BACK_LEFT (2) ///< Index of back-left channel in configurations with no front-center channel.
  101. #define AK_IDX_SETUP_NOCENTER_BACK_RIGHT (3) ///< Index of back-right channel in configurations with no front-center channel.
  102. #define AK_IDX_SETUP_NOCENTER_SIDE_LEFT (4) ///< Index of side-left channel in configurations with no front-center channel.
  103. #define AK_IDX_SETUP_NOCENTER_SIDE_RIGHT (5) ///< Index of side-right channel in configurations with no front-center channel.
  104. #define AK_IDX_SETUP_WITHCENTER_BACK_LEFT (3) ///< Index of back-left channel in configurations with a front-center channel.
  105. #define AK_IDX_SETUP_WITHCENTER_BACK_RIGHT (4) ///< Index of back-right channel in configurations with a front-center channel.
  106. #define AK_IDX_SETUP_WITHCENTER_SIDE_LEFT (5) ///< Index of side-left channel in configurations with a front-center channel.
  107. #define AK_IDX_SETUP_WITHCENTER_SIDE_RIGHT (6) ///< Index of side-right channel in configurations with a front-center channel.
  108. #define AK_IDX_SETUP_WITHCENTER_HEIGHT_FRONT_LEFT (7) ///< Index of height-front-left channel in configurations with a front-center channel.
  109. #define AK_IDX_SETUP_WITHCENTER_HEIGHT_FRONT_RIGHT (8) ///< Index of height-front-right channel in configurations with a front-center channel.
  110. #define AK_IDX_SETUP_WITHCENTER_HEIGHT_BACK_LEFT (9) ///< Index of height-back-left channel in configurations with a front-center channel.
  111. #define AK_IDX_SETUP_WITHCENTER_HEIGHT_BACK_RIGHT (10) ///< Index of height-back-right channel in configurations with a front-center channel.
  112. // Channel indices for specific setups.
  113. #define AK_IDX_SETUP_0_LFE (0) ///< Index of low-frequency channel in 0.1 setup (use with AkAudioBuffer::GetChannel())
  114. #define AK_IDX_SETUP_1_CENTER (0) ///< Index of center channel in 1.x setups (use with AkAudioBuffer::GetChannel())
  115. #define AK_IDX_SETUP_1_LFE (1) ///< Index of low-frequency channel in 1.1 setup (use with AkAudioBuffer::GetChannel())
  116. #define AK_IDX_SETUP_2_LEFT (0) ///< Index of left channel in 2.x setups (use with AkAudioBuffer::GetChannel())
  117. #define AK_IDX_SETUP_2_RIGHT (1) ///< Index of right channel in 2.x setups (use with AkAudioBuffer::GetChannel())
  118. #define AK_IDX_SETUP_2_LFE (2) ///< Index of low-frequency channel in 2.1 setup (use with AkAudioBuffer::GetChannel())
  119. #define AK_IDX_SETUP_3_LEFT (0) ///< Index of left channel in 3.x setups (use with AkAudioBuffer::GetChannel())
  120. #define AK_IDX_SETUP_3_RIGHT (1) ///< Index of right channel in 3.x setups (use with AkAudioBuffer::GetChannel())
  121. #define AK_IDX_SETUP_3_CENTER (2) ///< Index of center channel in 3.x setups (use with AkAudioBuffer::GetChannel())
  122. #define AK_IDX_SETUP_3_LFE (3) ///< Index of low-frequency channel in 3.1 setup (use with AkAudioBuffer::GetChannel())
  123. #define AK_IDX_SETUP_4_FRONTLEFT (0) ///< Index of front left channel in 4.x setups (use with AkAudioBuffer::GetChannel())
  124. #define AK_IDX_SETUP_4_FRONTRIGHT (1) ///< Index of front right channel in 4.x setups (use with AkAudioBuffer::GetChannel())
  125. #define AK_IDX_SETUP_4_REARLEFT (2) ///< Index of rear left channel in 4.x setups (use with AkAudioBuffer::GetChannel())
  126. #define AK_IDX_SETUP_4_REARRIGHT (3) ///< Index of rear right channel in 4.x setups (use with AkAudioBuffer::GetChannel())
  127. #define AK_IDX_SETUP_4_LFE (4) ///< Index of low-frequency channel in 4.1 setup (use with AkAudioBuffer::GetChannel())
  128. #define AK_IDX_SETUP_5_FRONTLEFT (0) ///< Index of front left channel in 5.x setups (use with AkAudioBuffer::GetChannel())
  129. #define AK_IDX_SETUP_5_FRONTRIGHT (1) ///< Index of front right channel in 5.x setups (use with AkAudioBuffer::GetChannel())
  130. #define AK_IDX_SETUP_5_CENTER (2) ///< Index of center channel in 5.x setups (use with AkAudioBuffer::GetChannel())
  131. #define AK_IDX_SETUP_5_REARLEFT (3) ///< Index of rear left channel in 5.x setups (use with AkAudioBuffer::GetChannel())
  132. #define AK_IDX_SETUP_5_REARRIGHT (4) ///< Index of rear right channel in 5.x setups (use with AkAudioBuffer::GetChannel())
  133. #define AK_IDX_SETUP_5_LFE (5) ///< Index of low-frequency channel in 5.1 setup (use with AkAudioBuffer::GetChannel())
  134. #define AK_IDX_SETUP_6_FRONTLEFT (0) ///< Index of front left channel in 6.x setups (use with AkAudioBuffer::GetChannel())
  135. #define AK_IDX_SETUP_6_FRONTRIGHT (1) ///< Index of front right channel in 6x setups (use with AkAudioBuffer::GetChannel())
  136. #define AK_IDX_SETUP_6_REARLEFT (2) ///< Index of rear left channel in 6.x setups (use with AkAudioBuffer::GetChannel())
  137. #define AK_IDX_SETUP_6_REARRIGHT (3) ///< Index of rear right channel in 6.x setups (use with AkAudioBuffer::GetChannel())
  138. #define AK_IDX_SETUP_6_SIDELEFT (4) ///< Index of side left channel in 6.x setups (use with AkAudioBuffer::GetChannel())
  139. #define AK_IDX_SETUP_6_SIDERIGHT (5) ///< Index of side right channel in 6.x setups (use with AkAudioBuffer::GetChannel())
  140. #define AK_IDX_SETUP_6_LFE (6) ///< Index of low-frequency channel in 6.1 setup (use with AkAudioBuffer::GetChannel())
  141. #define AK_IDX_SETUP_7_FRONTLEFT (0) ///< Index of front left channel in 7.x setups (use with AkAudioBuffer::GetChannel())
  142. #define AK_IDX_SETUP_7_FRONTRIGHT (1) ///< Index of front right channel in 7.x setups (use with AkAudioBuffer::GetChannel())
  143. #define AK_IDX_SETUP_7_CENTER (2) ///< Index of center channel in 7.x setups (use with AkAudioBuffer::GetChannel())
  144. #define AK_IDX_SETUP_7_REARLEFT (3) ///< Index of rear left channel in 7.x setups (use with AkAudioBuffer::GetChannel())
  145. #define AK_IDX_SETUP_7_REARRIGHT (4) ///< Index of rear right channel in 7.x setups (use with AkAudioBuffer::GetChannel())
  146. #define AK_IDX_SETUP_7_SIDELEFT (5) ///< Index of side left channel in 7.x setups (use with AkAudioBuffer::GetChannel())
  147. #define AK_IDX_SETUP_7_SIDERIGHT (6) ///< Index of side right channel in 7.x setups (use with AkAudioBuffer::GetChannel())
  148. #define AK_IDX_SETUP_7_LFE (7) ///< Index of low-frequency channel in 7.1 setup (use with AkAudioBuffer::GetChannel())
  149. //
  150. // Extra speaker setups. This is a more exhaustive list of speaker setups, which might not all be supported
  151. // by the Wwise Sound Engine audio pipeline.
  152. //
  153. #define AK_SPEAKER_SETUP_0_1 ( AK_SPEAKER_LOW_FREQUENCY ) //0.1
  154. #define AK_SPEAKER_SETUP_1_0_CENTER ( AK_SPEAKER_FRONT_CENTER ) //1.0 (C)
  155. #define AK_SPEAKER_SETUP_1_1_CENTER ( AK_SPEAKER_FRONT_CENTER | AK_SPEAKER_LOW_FREQUENCY ) //1.1 (C)
  156. #define AK_SPEAKER_SETUP_2_0 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT ) //2.0
  157. #define AK_SPEAKER_SETUP_2_1 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT | AK_SPEAKER_LOW_FREQUENCY ) //2.1
  158. #define AK_SPEAKER_SETUP_3_0 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT | AK_SPEAKER_FRONT_CENTER ) //3.0
  159. #define AK_SPEAKER_SETUP_3_1 ( AK_SPEAKER_SETUP_3_0 | AK_SPEAKER_LOW_FREQUENCY ) //3.1
  160. #define AK_SPEAKER_SETUP_FRONT ( AK_SPEAKER_SETUP_3_0 )
  161. #define AK_SPEAKER_SETUP_4_0 ( AK_SPEAKER_SETUP_4 )
  162. #define AK_SPEAKER_SETUP_4_1 ( AK_SPEAKER_SETUP_4POINT1 )
  163. #define AK_SPEAKER_SETUP_5_0 ( AK_SPEAKER_SETUP_5 )
  164. #define AK_SPEAKER_SETUP_5_1 ( AK_SPEAKER_SETUP_5POINT1 )
  165. #define AK_SPEAKER_SETUP_6_0 ( AK_SPEAKER_SETUP_6 )
  166. #define AK_SPEAKER_SETUP_6_1 ( AK_SPEAKER_SETUP_6POINT1 )
  167. #define AK_SPEAKER_SETUP_7_0 ( AK_SPEAKER_SETUP_7 )
  168. #define AK_SPEAKER_SETUP_7_1 ( AK_SPEAKER_SETUP_7POINT1 )
  169. // Standard/largest setup definitions.
  170. #define AK_SPEAKER_SETUP_DEFAULT_PLANE (AK_SPEAKER_SETUP_7POINT1) ///< All speakers on the plane, supported on this platform.
  171. #define AK_SUPPORTED_STANDARD_CHANNEL_MASK (AK_SPEAKER_SETUP_ALL_SPEAKERS) ///< Platform supports all standard channels.
  172. #define AK_STANDARD_MAX_NUM_CHANNELS (8) ///< Legacy: Platform supports at least 7.1
  173. #define AK_MAX_AMBISONICS_ORDER (5)
  174. // Helpers.
  175. inline void AK_SPEAKER_SETUP_FIX_LEFT_TO_CENTER( AkUInt32 &io_uChannelMask )
  176. {
  177. if( !(io_uChannelMask & AK_SPEAKER_FRONT_CENTER)
  178. && !(io_uChannelMask & AK_SPEAKER_FRONT_RIGHT)
  179. && (io_uChannelMask & AK_SPEAKER_FRONT_LEFT) )
  180. {
  181. io_uChannelMask &= ~AK_SPEAKER_FRONT_LEFT; // remove left
  182. io_uChannelMask |= AK_SPEAKER_FRONT_CENTER; // add center
  183. }
  184. }
  185. inline void AK_SPEAKER_SETUP_FIX_REAR_TO_SIDE( AkUInt32 &io_uChannelMask )
  186. {
  187. if( io_uChannelMask & ( AK_SPEAKER_BACK_LEFT ) && !( io_uChannelMask & AK_SPEAKER_SIDE_LEFT ) )
  188. {
  189. io_uChannelMask &= ~( AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT ); // remove rears
  190. io_uChannelMask |= ( AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT ); // add sides
  191. }
  192. }
  193. inline void AK_SPEAKER_SETUP_CONVERT_TO_SUPPORTED( AkUInt32 &io_uChannelMask )
  194. {
  195. AK_SPEAKER_SETUP_FIX_LEFT_TO_CENTER( io_uChannelMask );
  196. AK_SPEAKER_SETUP_FIX_REAR_TO_SIDE( io_uChannelMask );
  197. }
  198. /// Ambisonics configurations (corresponding to AkChannelConfig::eConfigType == AK_ChannelConfigType_Ambisonic).
  199. /// Convention: X points towards the front, and XYZ follow a right-hand rule, so Y is the side vector (pointing to the left).
  200. /// Channel presence and ordering are predefined according to the number of channels. The ordering convention is ACN,
  201. /// with the mapping of components to number of channels detailed below (source: https://en.wikipedia.org/wiki/Ambisonic_data_exchange_formats).
  202. /// Normalization natively used in Wwise is SN3D.
  203. ///
  204. /// <table cellspacing="0" cellpadding="1" border="1" width="800px">
  205. /// <tr><td rowspan="2" align="center"><b>Number of channels</b></td> <td colspan="2" align="center"><b>Order</b></td><td rowspan="2" align="center"><b>Description</b></td><td rowspan="2" align="center"><b>Layout of components</b></td></tr>
  206. /// <tr><td align="center">Horizontal</td><td align="center">Vertical</td></tr>
  207. /// <tr><td align="right">1 &nbsp;&nbsp;&nbsp;</td> <td align="right">0 &nbsp;&nbsp;&nbsp;</td><td align="right">0 &nbsp;&nbsp;&nbsp;</td> <td>&nbsp;&nbsp;mono</td><td>&nbsp;</td></tr>
  208. /// <tr><td align="right">4 &nbsp;&nbsp;&nbsp;</td> <td align="right">1 &nbsp;&nbsp;&nbsp;</td><td align="right">1 &nbsp;&nbsp;&nbsp;</td> <td>&nbsp;&nbsp;first-order full sphere</td><td>&nbsp;&nbsp;WYZX</td></tr>
  209. /// <tr><td align="right">9 &nbsp;&nbsp;&nbsp;</td> <td align="right">2 &nbsp;&nbsp;&nbsp;</td><td align="right">2 &nbsp;&nbsp;&nbsp;</td> <td>&nbsp;&nbsp;second-order full sphere</td><td>&nbsp;&nbsp;WYZXVTRSU</td></tr>
  210. /// <tr><td align="right">16 &nbsp;&nbsp;&nbsp;</td> <td align="right">3 &nbsp;&nbsp;&nbsp;</td><td align="right">3 &nbsp;&nbsp;&nbsp;</td> <td>&nbsp;&nbsp;third-order full sphere</td><td>&nbsp;&nbsp;WYZXVTRSUQOMKLNP</td></tr>
  211. /// </table>
  212. namespace AK
  213. {
  214. /// Returns the number of channels of a given channel configuration.
  215. static inline AkUInt8 ChannelMaskToNumChannels( AkChannelMask in_uChannelMask )
  216. {
  217. return (AkUInt8)AKPLATFORM::AkPopCount(in_uChannelMask);
  218. }
  219. /// Returns a 'best guess' channel configuration from a given number of channels.
  220. /// Will return 0 if no guess can be made.
  221. static inline AkChannelMask ChannelMaskFromNumChannels( unsigned int in_uNumChannels )
  222. {
  223. AkChannelMask uChannelMask = 0;
  224. switch ( in_uNumChannels )
  225. {
  226. case 1:
  227. uChannelMask = AK_SPEAKER_SETUP_1_0_CENTER;
  228. break;
  229. case 2:
  230. uChannelMask = AK_SPEAKER_SETUP_2_0;
  231. break;
  232. case 3:
  233. uChannelMask = AK_SPEAKER_SETUP_2_1;
  234. break;
  235. case 4:
  236. uChannelMask = AK_SPEAKER_SETUP_4_0;
  237. break;
  238. case 5:
  239. uChannelMask = AK_SPEAKER_SETUP_5_0;
  240. break;
  241. case 6:
  242. uChannelMask = AK_SPEAKER_SETUP_5_1;
  243. break;
  244. case 7:
  245. uChannelMask = AK_SPEAKER_SETUP_7;
  246. break;
  247. case 8:
  248. uChannelMask = AK_SPEAKER_SETUP_7POINT1;
  249. break;
  250. }
  251. return uChannelMask;
  252. }
  253. /// Converts a channel bit to a channel index (in Wwise pipeline ordering - LFE at the end), given a channel mask in_uChannelMask.
  254. /// \return Channel index.
  255. static inline AkUInt8 ChannelBitToIndex(AkChannelMask in_uChannelBit, AkChannelMask in_uChannelMask)
  256. {
  257. #ifdef AKASSERT
  258. AKASSERT(ChannelMaskToNumChannels(in_uChannelBit) == 1);
  259. #endif
  260. if (in_uChannelBit == AK_SPEAKER_LOW_FREQUENCY)
  261. return ChannelMaskToNumChannels(in_uChannelMask) - 1;
  262. return ChannelMaskToNumChannels(in_uChannelMask & ~AK_SPEAKER_LOW_FREQUENCY & (in_uChannelBit - 1)); // Count all channels prior this one except the LFE
  263. }
  264. /// Returns true when the LFE channel is present in a given channel configuration.
  265. /// \return True if the LFE channel is present.
  266. AkForceInline bool HasLFE(AkChannelMask in_uChannelMask)
  267. {
  268. return (in_uChannelMask & AK_SPEAKER_LOW_FREQUENCY) > 0;
  269. }
  270. /// Returns true when the center channel is present in a given channel configuration.
  271. /// Note that mono configurations have one channel which is arbitrary set to AK_SPEAKER_FRONT_CENTER,
  272. /// so HasCenter() returns true for mono signals.
  273. /// \return True if the center channel is present.
  274. AkForceInline bool HasCenter(AkChannelMask in_uChannelMask)
  275. {
  276. // All supported non-mono configurations have an AK_SPEAKER_FRONT_LEFT.
  277. return (in_uChannelMask & AK_SPEAKER_FRONT_CENTER) > 0;
  278. }
  279. /// Returns the number of angle values required to represent the given channel configuration.
  280. /// Use this function with supported 2D standard channel configurations only.
  281. /// \sa AK::SoundEngine::SetSpeakerAngles().
  282. AkForceInline AkUInt32 GetNumberOfAnglesForConfig(AkChannelMask in_uChannelMask)
  283. {
  284. #ifdef AKASSERT
  285. AKASSERT((in_uChannelMask & ~AK_SPEAKER_SETUP_DEFAULT_PLANE) == 0);
  286. #endif
  287. // LFE is irrelevant.
  288. in_uChannelMask &= ~AK_SPEAKER_LOW_FREQUENCY;
  289. // Center speaker is always in the center and thus does not require an angle.
  290. in_uChannelMask &= ~AK_SPEAKER_FRONT_CENTER;
  291. // We should have complete pairs at this point, unless there is a speaker at 180 degrees,
  292. // in which case we need one more angle to specify it.
  293. #ifdef AKASSERT
  294. AKASSERT((in_uChannelMask & AK_SPEAKER_BACK_CENTER) || ((ChannelMaskToNumChannels(in_uChannelMask) % 2) == 0));
  295. #endif
  296. return ChannelMaskToNumChannels(in_uChannelMask) >> 1;
  297. }
  298. /// Channel ordering type.
  299. enum AkChannelOrdering
  300. {
  301. ChannelOrdering_Standard, // L-R-C-LFE-RL-RR-RC-SL-SR-HL-HR-HC-HRL-HRR-HRC-T
  302. ChannelOrdering_RunTime // L-R-C-RL-RR-RC-SL-SR-HL-HR-HC-HRL-HRR-HRC-T-LFE
  303. };
  304. /// Returns true if standard configuration represented by channel mask has surround
  305. /// channels, either defined as side or back channels.
  306. AkForceInline bool HasSurroundChannels( AkChannelMask in_uChannelMask )
  307. {
  308. return ( in_uChannelMask & AK_SPEAKER_BACK_LEFT || in_uChannelMask & AK_SPEAKER_SIDE_LEFT );
  309. }
  310. /// Returns true if standard configuration represented by channel mask has strictly one
  311. /// pair of surround channels, either defined as side or back channels. 7.1 has two pairs
  312. /// of surround channels and would thus return false.
  313. AkForceInline bool HasStrictlyOnePairOfSurroundChannels( AkChannelMask in_uChannelMask )
  314. {
  315. return ( ( ( in_uChannelMask & AK_SPEAKER_BACK_LEFT ) != 0 ) ^ ( ( in_uChannelMask & AK_SPEAKER_SIDE_LEFT ) != 0 ) );
  316. }
  317. /// Returns true if standard configuration represented by channel mask has two
  318. /// pair of surround channels, that is, side and back channels. 7.1 has two pairs
  319. /// of surround channels and would thus return true, whereas 5.1 would return false.
  320. AkForceInline bool HasSideAndRearChannels( AkChannelMask in_uChannelMask )
  321. {
  322. return ( in_uChannelMask & AK_SPEAKER_BACK_LEFT && in_uChannelMask & AK_SPEAKER_SIDE_LEFT );
  323. }
  324. /// Returns true if standard configuration represented by channel mask has at least one "height" channel (above the plane).
  325. AkForceInline bool HasHeightChannels(AkChannelMask in_uChannelMask)
  326. {
  327. return (in_uChannelMask & ~AK_SPEAKER_SETUP_DEFAULT_PLANE) > 0;
  328. }
  329. /// Takes a channel mask and swap back channels with side channels if there is just
  330. /// one pair of surround channels.
  331. AkForceInline AkChannelMask BackToSideChannels( AkChannelMask in_uChannelMask )
  332. {
  333. if ( HasStrictlyOnePairOfSurroundChannels( in_uChannelMask ) )
  334. {
  335. in_uChannelMask &= ~( AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT ); // remove rears
  336. in_uChannelMask |= ( AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT ); // add sides
  337. }
  338. return in_uChannelMask;
  339. }
  340. /// Convert channel indices as they are ordered in standard (WAV) or Wwise sound engine (WEM) wave files
  341. /// (which follow channel mask bit values, except that the LFE is at the end in the case of WEMs)
  342. /// into display indices. Desired display order is L-R-C-SL-SR-RL-RR-HL-HR-HC-HRL-HRR-HRC-T-LFE. Note that 4-5.x configurations
  343. /// may define back or side channels. Either way they are "Surround" channels and are assigned to "SL, SR" names.
  344. static inline unsigned int StdChannelIndexToDisplayIndex( AkChannelOrdering in_eOrdering, unsigned int in_uChannelMask, unsigned int in_uChannelIdx )
  345. {
  346. if ( in_eOrdering == ChannelOrdering_Standard )
  347. {
  348. unsigned int uNumChannelsFront = ChannelMaskToNumChannels( in_uChannelMask & AK_SPEAKER_SETUP_FRONT );
  349. if ( ( in_uChannelMask & AK_SPEAKER_LOW_FREQUENCY )
  350. && ( in_uChannelIdx == uNumChannelsFront ) )
  351. {
  352. // Lfe. Return penultimate channel.
  353. in_uChannelIdx = ChannelMaskToNumChannels( in_uChannelMask ) - 1;
  354. }
  355. else if ( in_uChannelIdx >= uNumChannelsFront ) // strictly greater than uNumChannelsFront (lfe index) if lfe is present, greater or equal otherwise.
  356. {
  357. // Back channel. Return index or index-1 if there is an LFE (uLfeOffset==1).
  358. unsigned int uLfeOffset = ( in_uChannelMask & AK_SPEAKER_LOW_FREQUENCY ) ? 1 : 0;
  359. // 6-7.x: Need to swap back and sides.
  360. if ( HasSideAndRearChannels( in_uChannelMask ) )
  361. {
  362. unsigned int uRearIdx = uNumChannelsFront + uLfeOffset;
  363. unsigned int uSideIdx = uRearIdx + 2;
  364. unsigned int uAfterSideIdx = uSideIdx + 2;
  365. if ( in_uChannelIdx < uAfterSideIdx )
  366. {
  367. if ( in_uChannelIdx >= uSideIdx )
  368. in_uChannelIdx -= 2; // input is side, swap it with back.
  369. else
  370. in_uChannelIdx += 2; // input is back, swap it with side.
  371. }
  372. }
  373. in_uChannelIdx -= uLfeOffset; // compensate for LFE if it was skipped above.
  374. }
  375. }
  376. else
  377. {
  378. // 6-7.x: Need to swap back and sides.
  379. if ( HasSideAndRearChannels( in_uChannelMask ) )
  380. {
  381. unsigned int uRearIdx = ChannelMaskToNumChannels( in_uChannelMask & AK_SPEAKER_SETUP_FRONT );
  382. unsigned int uMaxIdx = uRearIdx + 4; // Side and rear channels.
  383. if ( in_uChannelIdx >= uRearIdx
  384. && in_uChannelIdx < uMaxIdx )
  385. {
  386. // Surround channel (not LFE).
  387. unsigned int uSideIdx = uRearIdx + 2;
  388. if ( in_uChannelIdx >= uSideIdx )
  389. in_uChannelIdx -= 2; // input is side, swap it with back.
  390. else
  391. in_uChannelIdx += 2; // input is back, swap it with side.
  392. }
  393. }
  394. }
  395. return in_uChannelIdx;
  396. }
  397. } // namespace AK
  398. /// Channel configuration type.
  399. enum AkChannelConfigType
  400. {
  401. AK_ChannelConfigType_Anonymous = 0x0, ///< Channel mask == 0 and channels are anonymous.
  402. AK_ChannelConfigType_Standard = 0x1, ///< Channels must be identified with standard defines in AkSpeakerConfigs.
  403. AK_ChannelConfigType_Ambisonic = 0x2, ///< Ambisonics. Channel mask == 0 and channels follow standard ambisonic order.
  404. AK_ChannelConfigType_Objects = 0x3, ///< Object-based configurations.
  405. AK_ChannelConfigType_UseDeviceMain = 0xE, ///< Special setting for bus objects to use the audio device main configuration.
  406. AK_ChannelConfigType_UseDevicePassthrough = 0xF ///< Special setting for bus objects to use the audio device passthrough configuration.
  407. };
  408. /// Defines a channel configuration.
  409. /// Examples:
  410. /// \code
  411. /// AkChannelConfig cfg;
  412. ///
  413. /// // Create a stereo configuration.
  414. /// cfg.SetStandard(AK_SPEAKER_SETUP_STEREO);
  415. ///
  416. /// // Create a 7.1.4 configuration (7.1 plus 4 height channels).
  417. /// cfg.SetStandard(AK_SPEAKER_SETUP_AURO_11POINT1_740);
  418. /// // or
  419. /// cfg.SetStandard(AK_SPEAKER_SETUP_DOLBY_7_1_4);
  420. ///
  421. /// // Create a 3rd order ambisonic configuration.
  422. /// cfg.SetAmbisonic(16); // pass in the number of spherical harmonics, (N+1)^2, where N is the ambisonics order.
  423. ///
  424. /// // Invalidate (usually means "As Parent")
  425. /// cfg.Clear();
  426. /// \endcode
  427. struct AkChannelConfig
  428. {
  429. // Channel config:
  430. // - uChannelMask is a bit field, whose channel identifiers depend on AkChannelConfigType (up to 20). Channel bits are defined in AkSpeakerConfig.h.
  431. // - eConfigType is a code that completes the identification of channels by uChannelMask.
  432. // - uNumChannels is the number of channels, identified (deduced from channel mask) or anonymous (set directly).
  433. AkUInt32 uNumChannels : 8; ///< Number of channels.
  434. AkUInt32 eConfigType : 4; ///< Channel config type (AkChannelConfigType).
  435. AkUInt32 uChannelMask : 20;///< Channel mask (configuration).
  436. /// Construct standard channel config from channel mask
  437. static AkForceInline AkChannelConfig Standard(AkUInt32 in_uChannelMask)
  438. {
  439. return AkChannelConfig(AK::ChannelMaskToNumChannels(in_uChannelMask), in_uChannelMask);
  440. }
  441. // Construct anonymous channel config from number of channels
  442. static AkForceInline AkChannelConfig Anonymous(AkUInt32 in_uNumChannels)
  443. {
  444. return AkChannelConfig(in_uNumChannels, 0);
  445. }
  446. /// Construct ambisonic channel config from number of channels (NOT order)
  447. static AkForceInline AkChannelConfig Ambisonic(AkUInt32 in_uNumChannels)
  448. {
  449. AkChannelConfig cfg;
  450. cfg.SetAmbisonic(in_uNumChannels);
  451. return cfg;
  452. }
  453. // Construct object-based channel config
  454. static AkForceInline AkChannelConfig Object()
  455. {
  456. AkChannelConfig cfg;
  457. cfg.SetObject();
  458. return cfg;
  459. }
  460. /// Constructor. Clears / sets the channel config in "invalid" state (IsValid() returns false).
  461. AkForceInline AkChannelConfig()
  462. : uNumChannels(0)
  463. , eConfigType(0)
  464. , uChannelMask(0)
  465. {
  466. }
  467. /// Constructor. Sets number of channels, and config type according to whether channel mask is defined or not. If defined, it must be consistent with the number of channels.
  468. AkForceInline AkChannelConfig(AkUInt32 in_uNumChannels, AkUInt32 in_uChannelMask)
  469. {
  470. // Input arguments should be consistent.
  471. SetStandardOrAnonymous(in_uNumChannels, in_uChannelMask);
  472. }
  473. /// Operator != with a 32-bit word.
  474. AkForceInline bool operator!=(AkUInt32 in_uBitField)
  475. {
  476. return (*((AkUInt32*)this) != in_uBitField);
  477. }
  478. /// Clear the channel config. Becomes "invalid" (IsValid() returns false).
  479. AkForceInline void Clear()
  480. {
  481. uNumChannels = 0;
  482. eConfigType = 0;
  483. uChannelMask = 0;
  484. }
  485. /// Set channel config as a standard configuration specified with given channel mask.
  486. AkForceInline void SetStandard(AkUInt32 in_uChannelMask)
  487. {
  488. uNumChannels = AK::ChannelMaskToNumChannels(in_uChannelMask);
  489. eConfigType = AK_ChannelConfigType_Standard;
  490. uChannelMask = in_uChannelMask;
  491. }
  492. /// Set channel config as either a standard or an anonymous configuration, specified with both a given channel mask (0 if anonymous) and a number of channels (which must match the channel mask if standard).
  493. AkForceInline void SetStandardOrAnonymous(AkUInt32 in_uNumChannels, AkUInt32 in_uChannelMask)
  494. {
  495. #ifdef AKASSERT
  496. AKASSERT(in_uChannelMask == 0 || in_uNumChannels == AK::ChannelMaskToNumChannels(in_uChannelMask));
  497. #endif
  498. uNumChannels = in_uNumChannels;
  499. eConfigType = (in_uChannelMask) ? AK_ChannelConfigType_Standard : AK_ChannelConfigType_Anonymous;
  500. uChannelMask = in_uChannelMask;
  501. }
  502. /// Set channel config as an anonymous configuration specified with given number of channels.
  503. AkForceInline void SetAnonymous(AkUInt32 in_uNumChannels)
  504. {
  505. uNumChannels = in_uNumChannels;
  506. eConfigType = AK_ChannelConfigType_Anonymous;
  507. uChannelMask = 0;
  508. }
  509. /// Set channel config as an ambisonic configuration specified with given number of channels.
  510. AkForceInline void SetAmbisonic(AkUInt32 in_uNumChannels)
  511. {
  512. uNumChannels = in_uNumChannels;
  513. eConfigType = AK_ChannelConfigType_Ambisonic;
  514. uChannelMask = 0;
  515. }
  516. /// Set channel config as an object-based configuration (implies dynamic number of objects).
  517. AkForceInline void SetObject()
  518. {
  519. uNumChannels = 0;
  520. eConfigType = AK_ChannelConfigType_Objects;
  521. uChannelMask = 0;
  522. }
  523. /// Set channel config as the main mix channel configuration
  524. AkForceInline void SetSameAsMainMix()
  525. {
  526. uNumChannels = 0;
  527. eConfigType = AK_ChannelConfigType_UseDeviceMain;
  528. uChannelMask = 0;
  529. }
  530. /// Set channel config as the passthrough mix channel configuration
  531. AkForceInline void SetSameAsPassthrough()
  532. {
  533. uNumChannels = 0;
  534. eConfigType = AK_ChannelConfigType_UseDevicePassthrough;
  535. uChannelMask = 0;
  536. }
  537. /// Returns true if valid, false otherwise (as when it is constructed, or invalidated using Clear()).
  538. AkForceInline bool IsValid() const
  539. {
  540. return eConfigType <= AK_ChannelConfigType_Objects && (uNumChannels != 0 || eConfigType == AK_ChannelConfigType_Objects);
  541. }
  542. /// Serialize channel config into a 32-bit word.
  543. AkForceInline AkUInt32 Serialize() const
  544. {
  545. return uNumChannels | (eConfigType << 8) | (uChannelMask << 12);
  546. }
  547. /// Deserialize channel config from a 32-bit word.
  548. AkForceInline void Deserialize(AkUInt32 in_uChannelConfig)
  549. {
  550. uNumChannels = in_uChannelConfig & 0x000000ff;
  551. eConfigType = (in_uChannelConfig >> 8) & 0x0000000f;
  552. uChannelMask = (in_uChannelConfig >> 12) & 0x000fffff;
  553. }
  554. /// Returns a new config based on 'this' with no LFE.
  555. AkForceInline AkChannelConfig RemoveLFE() const
  556. {
  557. AkChannelConfig newConfig = *this;
  558. AkUInt32 uNewChannelMask = newConfig.uChannelMask & ~AK_SPEAKER_LOW_FREQUENCY;
  559. AkUInt32 uNumLFEChannel = (newConfig.uChannelMask - uNewChannelMask) >> 3; // 0 or 1
  560. #ifdef AKASSERT
  561. AKASSERT(uNumLFEChannel == 0 || uNumLFEChannel == 1);
  562. #endif
  563. newConfig.uNumChannels -= uNumLFEChannel;
  564. newConfig.uChannelMask = uNewChannelMask;
  565. return newConfig;
  566. }
  567. /// Returns a new config based on 'this' with no Front Center channel.
  568. AkForceInline AkChannelConfig RemoveCenter() const
  569. {
  570. AkChannelConfig newConfig = *this;
  571. AkUInt32 uNewChannelMask = newConfig.uChannelMask & ~AK_SPEAKER_FRONT_CENTER;
  572. AkUInt32 uNumCenterChannel = (newConfig.uChannelMask - uNewChannelMask) >> 2; // 0 or 1.
  573. #ifdef AKASSERT
  574. AKASSERT(uNumCenterChannel == 0 || uNumCenterChannel == 1);
  575. #endif
  576. newConfig.uNumChannels -= uNumCenterChannel;
  577. newConfig.uChannelMask = uNewChannelMask;
  578. return newConfig;
  579. }
  580. /// Operator ==
  581. AkForceInline bool operator==(const AkChannelConfig & in_other) const
  582. {
  583. return uNumChannels == in_other.uNumChannels
  584. && eConfigType == in_other.eConfigType
  585. && uChannelMask == in_other.uChannelMask;
  586. }
  587. /// Operator !=
  588. AkForceInline bool operator!=(const AkChannelConfig & in_other) const
  589. {
  590. return uNumChannels != in_other.uNumChannels
  591. || eConfigType != in_other.eConfigType
  592. || uChannelMask != in_other.uChannelMask;
  593. }
  594. /// Query if LFE channel is present.
  595. /// \return True when LFE channel is present
  596. AkForceInline bool HasLFE() const
  597. {
  598. return AK::HasLFE(uChannelMask);
  599. }
  600. /// Query if center channel is present.
  601. /// Note that mono configurations have one channel which is arbitrary set to AK_SPEAKER_FRONT_CENTER,
  602. /// so HasCenter() returns true for mono signals.
  603. /// \return True when center channel is present and configuration has more than 2 channels.
  604. AkForceInline bool HasCenter() const
  605. {
  606. return AK::HasCenter(uChannelMask);
  607. }
  608. };
  609. #endif //_AK_SPEAKERCONFIG_H_