버전
menu

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

이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요