バージョン
menu

Wwise SDK 2025.1.4
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/AkNumeralTypes.h>
31 #include AK/SoundEngine/Common/AkTypedefs.h>
32 #include AK/SoundEngine/Common/AkEnums.h>
33 #ifdef __cplusplus
34 #include AK/Tools/Common/AkBitFuncs.h>
35 #endif
36 
37 /// Standard speakers (channel mask):
38 #define AK_SPEAKER_FRONT_LEFT 0x1 ///
39 #define AK_SPEAKER_FRONT_RIGHT 0x2 ///
40 #define AK_SPEAKER_FRONT_CENTER 0x4 ///
41 #define AK_SPEAKER_LOW_FREQUENCY 0x8 ///
42 #define AK_SPEAKER_BACK_LEFT 0x10 ///
43 #define AK_SPEAKER_BACK_RIGHT 0x20 ///
44 #define AK_SPEAKER_BACK_CENTER 0x100 ///
45 #define AK_SPEAKER_SIDE_LEFT 0x200 ///
46 #define AK_SPEAKER_SIDE_RIGHT 0x400 ///
47 
48 /// "Height" speakers.
49 #define AK_SPEAKER_TOP 0x800 ///
50 #define AK_SPEAKER_HEIGHT_FRONT_LEFT 0x1000 ///
51 #define AK_SPEAKER_HEIGHT_FRONT_CENTER 0x2000 ///
52 #define AK_SPEAKER_HEIGHT_FRONT_RIGHT 0x4000 ///
53 #define AK_SPEAKER_HEIGHT_BACK_LEFT 0x8000 ///
54 #define AK_SPEAKER_HEIGHT_BACK_CENTER 0x10000 ///
55 #define AK_SPEAKER_HEIGHT_BACK_RIGHT 0x20000 ///
56 #define AK_SPEAKER_HEIGHT_SIDE_LEFT 0x40000 ///
57 #define AK_SPEAKER_HEIGHT_SIDE_RIGHT 0x80000 ///
58 
59 //
60 // Supported speaker setups. Those are the ones that can be used in the Wwise Sound Engine audio pipeline.
61 //
62 
63 #define AK_SPEAKER_SETUP_MONO AK_SPEAKER_FRONT_CENTER ///
64 #define AK_SPEAKER_SETUP_0POINT1 AK_SPEAKER_LOW_FREQUENCY ///
65 #define AK_SPEAKER_SETUP_1POINT1 (AK_SPEAKER_FRONT_CENTER | AK_SPEAKER_LOW_FREQUENCY) ///
66 #define AK_SPEAKER_SETUP_STEREO (AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT) ///
67 #define AK_SPEAKER_SETUP_2POINT1 (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_LOW_FREQUENCY) ///
68 #define AK_SPEAKER_SETUP_3STEREO (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_FRONT_CENTER) ///
69 #define AK_SPEAKER_SETUP_3POINT1 (AK_SPEAKER_SETUP_3STEREO | AK_SPEAKER_LOW_FREQUENCY) ///
70 #define AK_SPEAKER_SETUP_4 (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT) ///
71 #define AK_SPEAKER_SETUP_4POINT1 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_LOW_FREQUENCY) ///
72 #define AK_SPEAKER_SETUP_5 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_FRONT_CENTER) ///
73 #define AK_SPEAKER_SETUP_5POINT1 (AK_SPEAKER_SETUP_5 | AK_SPEAKER_LOW_FREQUENCY) ///
74 #define AK_SPEAKER_SETUP_6 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT) ///
75 #define AK_SPEAKER_SETUP_6POINT1 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_LOW_FREQUENCY) ///
76 #define AK_SPEAKER_SETUP_7 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_FRONT_CENTER) ///
77 #define AK_SPEAKER_SETUP_7POINT1 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_LOW_FREQUENCY) ///
78 #define AK_SPEAKER_SETUP_SURROUND (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_BACK_CENTER) ///
79 
80 #define AK_SPEAKER_SETUP_HEIGHT_2 (AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT) ///
81 #define AK_SPEAKER_SETUP_HEIGHT_4 (AK_SPEAKER_SETUP_HEIGHT_2 | AK_SPEAKER_HEIGHT_BACK_LEFT | AK_SPEAKER_HEIGHT_BACK_RIGHT) ///
82 #define AK_SPEAKER_SETUP_HEIGHT_5 (AK_SPEAKER_SETUP_HEIGHT_4 | AK_SPEAKER_HEIGHT_FRONT_CENTER) ///
83 #define AK_SPEAKER_SETUP_HEIGHT_ALL (AK_SPEAKER_SETUP_HEIGHT_5 | AK_SPEAKER_HEIGHT_BACK_CENTER) ///
84 #define AK_SPEAKER_SETUP_HEIGHT_4_TOP (AK_SPEAKER_SETUP_HEIGHT_4 | AK_SPEAKER_TOP) ///
85 #define AK_SPEAKER_SETUP_HEIGHT_5_TOP (AK_SPEAKER_SETUP_HEIGHT_5 | AK_SPEAKER_TOP) ///
86 
87 // Auro speaker setups
88 #define AK_SPEAKER_SETUP_AURO_222 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT) ///
89 #define AK_SPEAKER_SETUP_AURO_8 (AK_SPEAKER_SETUP_AURO_222 | AK_SPEAKER_HEIGHT_BACK_LEFT | AK_SPEAKER_HEIGHT_BACK_RIGHT) ///
90 #define AK_SPEAKER_SETUP_AURO_9 (AK_SPEAKER_SETUP_AURO_8 | AK_SPEAKER_FRONT_CENTER) ///
91 #define AK_SPEAKER_SETUP_AURO_9POINT1 (AK_SPEAKER_SETUP_AURO_9 | AK_SPEAKER_LOW_FREQUENCY) ///
92 #define AK_SPEAKER_SETUP_AURO_10 (AK_SPEAKER_SETUP_AURO_9 | AK_SPEAKER_TOP) ///
93 #define AK_SPEAKER_SETUP_AURO_10POINT1 (AK_SPEAKER_SETUP_AURO_10 | AK_SPEAKER_LOW_FREQUENCY) ///
94 #define AK_SPEAKER_SETUP_AURO_11 (AK_SPEAKER_SETUP_AURO_10 | AK_SPEAKER_HEIGHT_FRONT_CENTER) ///
95 #define AK_SPEAKER_SETUP_AURO_11POINT1 (AK_SPEAKER_SETUP_AURO_11 | AK_SPEAKER_LOW_FREQUENCY) ///
96 #define AK_SPEAKER_SETUP_AURO_11_740 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_SETUP_HEIGHT_4) ///
97 #define AK_SPEAKER_SETUP_AURO_11POINT1_740 (AK_SPEAKER_SETUP_AURO_11_740 | AK_SPEAKER_LOW_FREQUENCY) ///
98 #define AK_SPEAKER_SETUP_AURO_13_751 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_SETUP_HEIGHT_5 | AK_SPEAKER_TOP) ///
99 #define AK_SPEAKER_SETUP_AURO_13POINT1_751 (AK_SPEAKER_SETUP_AURO_13_751 | AK_SPEAKER_LOW_FREQUENCY) ///
100 
101 // Dolby speaker setups: in Dolby nomenclature, [#plane].[lfe].[#height]
102 #define AK_SPEAKER_SETUP_DOLBY_5_0_2 (AK_SPEAKER_SETUP_5 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT ) ///
103 #define AK_SPEAKER_SETUP_DOLBY_5_1_2 (AK_SPEAKER_SETUP_DOLBY_5_0_2 | AK_SPEAKER_LOW_FREQUENCY ) ///
104 #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 ) ///
105 #define AK_SPEAKER_SETUP_DOLBY_5_1_4 (AK_SPEAKER_SETUP_DOLBY_5_0_4 | AK_SPEAKER_LOW_FREQUENCY ) ///
106 #define AK_SPEAKER_SETUP_DOLBY_6_0_2 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT ) ///
107 #define AK_SPEAKER_SETUP_DOLBY_6_1_2 (AK_SPEAKER_SETUP_DOLBY_6_0_2 | AK_SPEAKER_LOW_FREQUENCY ) ///
108 #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 ) ///
109 #define AK_SPEAKER_SETUP_DOLBY_6_1_4 (AK_SPEAKER_SETUP_DOLBY_6_0_4 | AK_SPEAKER_LOW_FREQUENCY ) ///
110 #define AK_SPEAKER_SETUP_DOLBY_7_0_2 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT ) ///
111 #define AK_SPEAKER_SETUP_DOLBY_7_1_2 (AK_SPEAKER_SETUP_DOLBY_7_0_2 | AK_SPEAKER_LOW_FREQUENCY ) ///
112 #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 ) ///
113 #define AK_SPEAKER_SETUP_DOLBY_7_1_4 (AK_SPEAKER_SETUP_DOLBY_7_0_4 | AK_SPEAKER_LOW_FREQUENCY ) ///
114 
115 #define AK_SPEAKER_SETUP_ALL_SPEAKERS (AK_SPEAKER_SETUP_7POINT1 | AK_SPEAKER_BACK_CENTER | AK_SPEAKER_SETUP_HEIGHT_ALL | AK_SPEAKER_TOP) ///
116 
117 // Channel indices.
118 // ------------------------------------------------
119 
120 // Channel indices for standard setups on the plane.
121 #define AK_IDX_SETUP_FRONT_LEFT (0) ///
122 #define AK_IDX_SETUP_FRONT_RIGHT (1) ///
123 #define AK_IDX_SETUP_CENTER (2) ///
124 
125 #define AK_IDX_SETUP_NOCENTER_BACK_LEFT (2) ///
126 #define AK_IDX_SETUP_NOCENTER_BACK_RIGHT (3) ///
127 #define AK_IDX_SETUP_NOCENTER_SIDE_LEFT (4) ///
128 #define AK_IDX_SETUP_NOCENTER_SIDE_RIGHT (5) ///
129 
130 #define AK_IDX_SETUP_WITHCENTER_BACK_LEFT (3) ///
131 #define AK_IDX_SETUP_WITHCENTER_BACK_RIGHT (4) ///
132 #define AK_IDX_SETUP_WITHCENTER_SIDE_LEFT (5) ///
133 #define AK_IDX_SETUP_WITHCENTER_SIDE_RIGHT (6) ///
134 
135 #define AK_IDX_SETUP_WITHCENTER_HEIGHT_FRONT_LEFT (7) ///
136 #define AK_IDX_SETUP_WITHCENTER_HEIGHT_FRONT_RIGHT (8) ///
137 #define AK_IDX_SETUP_WITHCENTER_HEIGHT_BACK_LEFT (9) ///
138 #define AK_IDX_SETUP_WITHCENTER_HEIGHT_BACK_RIGHT (10) ///
139 
140 // Channel indices for specific setups.
141 #define AK_IDX_SETUP_0_LFE (0) ///
142 
143 #define AK_IDX_SETUP_1_CENTER (0) ///
144 #define AK_IDX_SETUP_1_LFE (1) ///
145 
146 #define AK_IDX_SETUP_2_LEFT (0) ///
147 #define AK_IDX_SETUP_2_RIGHT (1) ///
148 #define AK_IDX_SETUP_2_LFE (2) ///
149 
150 #define AK_IDX_SETUP_3_LEFT (0) ///
151 #define AK_IDX_SETUP_3_RIGHT (1) ///
152 #define AK_IDX_SETUP_3_CENTER (2) ///
153 #define AK_IDX_SETUP_3_LFE (3) ///
154 
155 #define AK_IDX_SETUP_4_FRONTLEFT (0) ///
156 #define AK_IDX_SETUP_4_FRONTRIGHT (1) ///
157 #define AK_IDX_SETUP_4_REARLEFT (2) ///
158 #define AK_IDX_SETUP_4_REARRIGHT (3) ///
159 #define AK_IDX_SETUP_4_LFE (4) ///
160 
161 #define AK_IDX_SETUP_5_FRONTLEFT (0) ///
162 #define AK_IDX_SETUP_5_FRONTRIGHT (1) ///
163 #define AK_IDX_SETUP_5_CENTER (2) ///
164 #define AK_IDX_SETUP_5_REARLEFT (3) ///
165 #define AK_IDX_SETUP_5_REARRIGHT (4) ///
166 #define AK_IDX_SETUP_5_LFE (5) ///
167 
168 #define AK_IDX_SETUP_6_FRONTLEFT (0) ///
169 #define AK_IDX_SETUP_6_FRONTRIGHT (1) ///
170 #define AK_IDX_SETUP_6_REARLEFT (2) ///
171 #define AK_IDX_SETUP_6_REARRIGHT (3) ///
172 #define AK_IDX_SETUP_6_SIDELEFT (4) ///
173 #define AK_IDX_SETUP_6_SIDERIGHT (5) ///
174 #define AK_IDX_SETUP_6_LFE (6) ///
175 
176 #define AK_IDX_SETUP_7_FRONTLEFT (0) ///
177 #define AK_IDX_SETUP_7_FRONTRIGHT (1) ///
178 #define AK_IDX_SETUP_7_CENTER (2) ///
179 #define AK_IDX_SETUP_7_REARLEFT (3) ///
180 #define AK_IDX_SETUP_7_REARRIGHT (4) ///
181 #define AK_IDX_SETUP_7_SIDELEFT (5) ///
182 #define AK_IDX_SETUP_7_SIDERIGHT (6) ///
183 #define AK_IDX_SETUP_7_LFE (7) ///
184 
185 //
186 // Extra speaker setups. This is a more exhaustive list of speaker setups, which might not all be supported
187 // by the Wwise Sound Engine audio pipeline.
188 //
189 
190 #define AK_SPEAKER_SETUP_0_1 ( AK_SPEAKER_LOW_FREQUENCY ) //0.1
191 
192 #define AK_SPEAKER_SETUP_1_0_CENTER ( AK_SPEAKER_FRONT_CENTER ) //1.0 (C)
193 #define AK_SPEAKER_SETUP_1_1_CENTER ( AK_SPEAKER_FRONT_CENTER | AK_SPEAKER_LOW_FREQUENCY ) //1.1 (C)
194 
195 #define AK_SPEAKER_SETUP_2_0 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT ) //2.0
196 #define AK_SPEAKER_SETUP_2_1 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT | AK_SPEAKER_LOW_FREQUENCY ) //2.1
197 
198 #define AK_SPEAKER_SETUP_3_0 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT | AK_SPEAKER_FRONT_CENTER ) //3.0
199 #define AK_SPEAKER_SETUP_3_1 ( AK_SPEAKER_SETUP_3_0 | AK_SPEAKER_LOW_FREQUENCY ) //3.1
200 
201 #define AK_SPEAKER_SETUP_FRONT ( AK_SPEAKER_SETUP_3_0 )
202 
203 #define AK_SPEAKER_SETUP_4_0 ( AK_SPEAKER_SETUP_4 )
204 #define AK_SPEAKER_SETUP_4_1 ( AK_SPEAKER_SETUP_4POINT1 )
205 #define AK_SPEAKER_SETUP_5_0 ( AK_SPEAKER_SETUP_5 )
206 #define AK_SPEAKER_SETUP_5_1 ( AK_SPEAKER_SETUP_5POINT1 )
207 
208 #define AK_SPEAKER_SETUP_6_0 ( AK_SPEAKER_SETUP_6 )
209 #define AK_SPEAKER_SETUP_6_1 ( AK_SPEAKER_SETUP_6POINT1 )
210 #define AK_SPEAKER_SETUP_7_0 ( AK_SPEAKER_SETUP_7 )
211 #define AK_SPEAKER_SETUP_7_1 ( AK_SPEAKER_SETUP_7POINT1 )
212 
213 // Standard/largest setup definitions.
214 #define AK_SPEAKER_SETUP_DEFAULT_PLANE (AK_SPEAKER_SETUP_7POINT1) ///
215 #define AK_SUPPORTED_STANDARD_CHANNEL_MASK (AK_SPEAKER_SETUP_ALL_SPEAKERS) ///
216 #define AK_STANDARD_MAX_NUM_CHANNELS (8) ///
217 
218 #define AK_MAX_AMBISONICS_ORDER (5)
219 
220 #define AK_DEFAULT_HEIGHT_ANGLE (30.0f)
221 
222 #ifdef __cplusplus
223 // Helpers.
224 inline void AK_SPEAKER_SETUP_FIX_LEFT_TO_CENTER(AkUInt32& io_uChannelMask)
225 {
226  if (!(io_uChannelMask & AK_SPEAKER_FRONT_CENTER)
227  && !(io_uChannelMask & AK_SPEAKER_FRONT_RIGHT)
228  && (io_uChannelMask & AK_SPEAKER_FRONT_LEFT))
229  {
230  io_uChannelMask &= ~AK_SPEAKER_FRONT_LEFT; // remove left
231  io_uChannelMask |= AK_SPEAKER_FRONT_CENTER; // add center
232  }
233 }
234 
235 inline void AK_SPEAKER_SETUP_FIX_REAR_TO_SIDE(AkUInt32& io_uChannelMask)
236 {
237  if (io_uChannelMask & (AK_SPEAKER_BACK_LEFT) && !(io_uChannelMask & AK_SPEAKER_SIDE_LEFT))
238  {
239  io_uChannelMask &= ~(AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT); // remove rears
240  io_uChannelMask |= (AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT); // add sides
241  }
242 }
243 
244 inline void AK_SPEAKER_SETUP_CONVERT_TO_SUPPORTED(AkUInt32& io_uChannelMask)
245 {
246  AK_SPEAKER_SETUP_FIX_LEFT_TO_CENTER(io_uChannelMask);
247  AK_SPEAKER_SETUP_FIX_REAR_TO_SIDE(io_uChannelMask);
248 }
249 
250 /// Ambisonics configurations (corresponding to AkChannelConfig::eConfigType == AK_ChannelConfigType_Ambisonic).
251 /// Convention: X points towards the front, and XYZ follow a right-hand rule, so Y is the side vector (pointing to the left).
252 /// Channel presence and ordering are predefined according to the number of channels. The ordering convention is ACN,
253 /// with the mapping of components to number of channels detailed below (source: https://en.wikipedia.org/wiki/Ambisonic_data_exchange_formats).
254 /// Normalization natively used in Wwise is SN3D.
255 ///
256 ///
257 ///
258 ///
259 ///
260 ///
261 ///
262 ///
263 ///
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
264 namespace AK
265 {
266 
267 /// Returns the number of channels of a given channel configuration.
268 static inline AkUInt8 ChannelMaskToNumChannels( AkChannelMask in_uChannelMask )
269 {
270  return (AkUInt8)AKPLATFORM::AkPopCount(in_uChannelMask);
271 }
272 
273 /// Returns a 'best guess' channel configuration from a given number of channels.
274 /// Will return 0 if no guess can be made.
275 static inline AkChannelMask ChannelMaskFromNumChannels( unsigned int in_uNumChannels )
276 {
277  AkChannelMask uChannelMask = 0;
278 
279  switch ( in_uNumChannels )
280  {
281  case 1:
282  uChannelMask = AK_SPEAKER_SETUP_1_0_CENTER;
283  break;
284  case 2:
285  uChannelMask = AK_SPEAKER_SETUP_2_0;
286  break;
287  case 3:
288  uChannelMask = AK_SPEAKER_SETUP_2_1;
289  break;
290  case 4:
291  uChannelMask = AK_SPEAKER_SETUP_4_0;
292  break;
293  case 5:
294  uChannelMask = AK_SPEAKER_SETUP_5_0;
295  break;
296  case 6:
297  uChannelMask = AK_SPEAKER_SETUP_5_1;
298  break;
299  case 7:
300  uChannelMask = AK_SPEAKER_SETUP_7;
301  break;
302  case 8:
303  uChannelMask = AK_SPEAKER_SETUP_7POINT1;
304  break;
305  }
306 
307  return uChannelMask;
308 }
309 
310 /// Converts a channel bit to a channel index (in Wwise pipeline ordering - LFE at the end), given a channel mask in_uChannelMask.
311 /// \return Channel index.
312 static inline AkUInt8 ChannelBitToIndex(AkChannelMask in_uChannelBit, AkChannelMask in_uChannelMask)
313 {
314 #ifdef AKASSERT
315  AKASSERT(ChannelMaskToNumChannels(in_uChannelBit) == 1);
316 #endif
317  if (in_uChannelBit == AK_SPEAKER_LOW_FREQUENCY)
318  return ChannelMaskToNumChannels(in_uChannelMask) - 1;
319  return ChannelMaskToNumChannels(in_uChannelMask & ~AK_SPEAKER_LOW_FREQUENCY & (in_uChannelBit - 1)); // Count all channels prior this one except the LFE
320 }
321 
322 /// Returns true when the LFE channel is present in a given channel configuration.
323 /// \return True if the LFE channel is present.
324 AkForceInline bool HasLFE(AkChannelMask in_uChannelMask)
325 {
326  return (in_uChannelMask & AK_SPEAKER_LOW_FREQUENCY) > 0;
327 }
328 
329 /// Returns true when the center channel is present in a given channel configuration.
330 /// Note that mono configurations have one channel which is arbitrary set to AK_SPEAKER_FRONT_CENTER,
331 /// so HasCenter() returns true for mono signals.
332 /// \return True if the center channel is present.
333 AkForceInline bool HasCenter(AkChannelMask in_uChannelMask)
334 {
335  // All supported non-mono configurations have an AK_SPEAKER_FRONT_LEFT.
336  return (in_uChannelMask & AK_SPEAKER_FRONT_CENTER) > 0;
337 }
338 
339 /// Returns the number of angle values required to represent the given channel configuration.
340 /// Use this function with supported 2D standard channel configurations only.
341 /// \sa AK::SoundEngine::SetSpeakerAngles().
343 {
344 #ifdef AKASSERT
345  AKASSERT((in_uChannelMask & ~AK_SPEAKER_SETUP_DEFAULT_PLANE) == 0);
346 #endif
347 
348  // LFE is irrelevant.
349  in_uChannelMask &= ~AK_SPEAKER_LOW_FREQUENCY;
350  // Center speaker is always in the center and thus does not require an angle.
351  in_uChannelMask &= ~AK_SPEAKER_FRONT_CENTER;
352  // We should have complete pairs at this point, unless there is a speaker at 180 degrees,
353  // in which case we need one more angle to specify it.
354 #ifdef AKASSERT
355  AKASSERT((in_uChannelMask & AK_SPEAKER_BACK_CENTER) || ((ChannelMaskToNumChannels(in_uChannelMask) % 2) == 0));
356 #endif
357  return ChannelMaskToNumChannels(in_uChannelMask) >> 1;
358 }
359 
360 /// Channel ordering type.
362 {
363  ChannelOrdering_Standard = 0, // L-R-C-LFE-RL-RR-RC-SL-SR-HL-HR-HC-HRL-HRR-HRC-T, or ACN ordering + SN3D norm
364  ChannelOrdering_Film, // L-C-R-SL-SR-RL-RR-LFE-HL-HR-HRL-HRR
366  ChannelOrdering_RunTime, // L-R-C-RL-RR-RC-SL-SR-HL-HR-HC-HRL-HRR-HRC-T-LFE
367 
368  ChannelOrdering_Last // End of enum, invalid value.
369 };
370 
371 /// Returns true if standard configuration represented by channel mask has surround
372 /// channels, either defined as side or back channels.
374 {
375  return ( in_uChannelMask & AK_SPEAKER_BACK_LEFT || in_uChannelMask & AK_SPEAKER_SIDE_LEFT );
376 }
377 
378 /// Returns true if standard configuration represented by channel mask has strictly one
379 /// pair of surround channels, either defined as side or back channels. 7.1 has two pairs
380 /// of surround channels and would thus return false.
382 {
383  return ( ( ( in_uChannelMask & AK_SPEAKER_BACK_LEFT ) != 0 ) ^ ( ( in_uChannelMask & AK_SPEAKER_SIDE_LEFT ) != 0 ) );
384 }
385 
386 /// Returns true if standard configuration represented by channel mask has two
387 /// pair of surround channels, that is, side and back channels. 7.1 has two pairs
388 /// of surround channels and would thus return true, whereas 5.1 would return false.
390 {
391  return ( in_uChannelMask & AK_SPEAKER_BACK_LEFT && in_uChannelMask & AK_SPEAKER_SIDE_LEFT );
392 }
393 
394 /// Returns true if standard configuration represented by channel mask has at least one "height" channel (above the plane).
396 {
397  return (in_uChannelMask & ~AK_SPEAKER_SETUP_DEFAULT_PLANE) > 0;
398 }
399 
400 /// Takes a channel mask and swap back channels with side channels if there is just
401 /// one pair of surround channels.
403 {
404  if ( HasStrictlyOnePairOfSurroundChannels( in_uChannelMask ) )
405  {
406  in_uChannelMask &= ~( AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT ); // remove rears
407  in_uChannelMask |= ( AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT ); // add sides
408  }
409  return in_uChannelMask;
410 }
411 
412 } // namespace AK
413 
414 #endif // __cplusplus
415 
416 /// Defines a channel configuration.
417 /// Examples:
418 /// \code
419 /// AkChannelConfig cfg;
420 ///
421 /// // Create a stereo configuration.
422 /// cfg.SetStandard(AK_SPEAKER_SETUP_STEREO);
423 ///
424 /// // Create a 7.1.4 configuration (7.1 plus 4 height channels).
425 /// cfg.SetStandard(AK_SPEAKER_SETUP_AURO_11POINT1_740);
426 /// // or
427 /// cfg.SetStandard(AK_SPEAKER_SETUP_DOLBY_7_1_4);
428 ///
429 /// // Create a 3rd order ambisonic configuration.
430 /// cfg.SetAmbisonic(16); // pass in the number of spherical harmonics, (N+1)^2, where N is the ambisonics order.
431 ///
432 /// // Invalidate (usually means "As Parent")
433 /// cfg.Clear();
434 /// \endcode
436 {
437  union {
438  // Channel config:
439  // - uChannelMask is a bit field, whose channel identifiers depend on AkChannelConfigType (up to 20). Channel bits are defined in AkSpeakerConfig.h.
440  // - eConfigType is a code that completes the identification of channels by uChannelMask.
441  // - uNumChannels is the number of channels, identified (deduced from channel mask) or anonymous (set directly).
442  struct
443  {
447  };
449  };
450 #ifdef __cplusplus
451 
452  /// Construct standard channel config from channel mask
454  {
455  return AkChannelConfig(AK::ChannelMaskToNumChannels(in_uChannelMask), in_uChannelMask);
456  }
457 
458  // Construct anonymous channel config from number of channels
460  {
461  return AkChannelConfig(in_uNumChannels, 0);
462  }
463 
464  /// Construct ambisonic channel config from number of channels (NOT order)
466  {
467  AkChannelConfig cfg;
468  cfg.SetAmbisonic(in_uNumChannels);
469  return cfg;
470  }
471 
472  // Construct object-based channel config
474  {
475  AkChannelConfig cfg;
476  cfg.SetObject();
477  return cfg;
478  }
479 
480  /// Constructor. Clears / sets the channel config in "invalid" state (IsValid() returns false).
482  {
483  uFullCfg = 0;
484  }
485 
487  {
488  uFullCfg = rCopy.uFullCfg;
489  }
490 
491  /// 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.
492  AkForceInline AkChannelConfig(AkUInt32 in_uNumChannels, AkUInt32 in_uChannelMask)
493  {
494  // Input arguments should be consistent.
495  SetStandardOrAnonymous(in_uNumChannels, in_uChannelMask);
496  }
497 
498  /// Operator != with a 32-bit word.
499  AkForceInline bool operator!=(AkUInt32 in_uBitField)
500  {
501  return (*((AkUInt32*)this) != in_uBitField);
502  }
503 
504  /// Clear the channel config. Becomes "invalid" (IsValid() returns false).
506  {
507  uFullCfg = 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 uFullCfg;
579  }
580 
581  /// Deserialize channel config from a 32-bit word.
582  AkForceInline void Deserialize(AkUInt32 in_uChannelConfig)
583  {
584  uFullCfg = in_uChannelConfig;
585  }
586 
587  /// Returns a new config based on 'this' with no LFE.
589  {
590  AkChannelConfig newConfig = *this;
591  AkUInt32 uNewChannelMask = newConfig.uChannelMask & ~AK_SPEAKER_LOW_FREQUENCY;
592  AkUInt32 uNumLFEChannel = (newConfig.uChannelMask - uNewChannelMask) >> 3; // 0 or 1
593 #ifdef AKASSERT
594  AKASSERT(uNumLFEChannel == 0 || uNumLFEChannel == 1);
595 #endif
596  newConfig.uNumChannels -= uNumLFEChannel;
597  newConfig.uChannelMask = uNewChannelMask;
598  return newConfig;
599  }
600 
601  /// Returns a new config based on 'this' with no Front Center channel.
603  {
604  AkChannelConfig newConfig = *this;
605  AkUInt32 uNewChannelMask = newConfig.uChannelMask & ~AK_SPEAKER_FRONT_CENTER;
606  AkUInt32 uNumCenterChannel = (newConfig.uChannelMask - uNewChannelMask) >> 2; // 0 or 1.
607 #ifdef AKASSERT
608  AKASSERT(uNumCenterChannel == 0 || uNumCenterChannel == 1);
609 #endif
610  newConfig.uNumChannels -= uNumCenterChannel;
611  newConfig.uChannelMask = uNewChannelMask;
612  return newConfig;
613  }
614 
615  /// Operator ==
616  AkForceInline bool operator==(const AkChannelConfig & in_other) const
617  {
618  return uFullCfg == in_other.uFullCfg;
619  }
620 
621  /// Operator !=
622  AkForceInline bool operator!=(const AkChannelConfig & in_other) const
623  {
624  return uFullCfg != in_other.uFullCfg;
625  }
626 
627  /// Query if LFE channel is present.
628  /// \return True when LFE channel is present
629  AkForceInline bool HasLFE() const
630  {
631  return AK::HasLFE(uChannelMask);
632  }
633 
634  /// Query if center channel is present.
635  /// Note that mono configurations have one channel which is arbitrary set to AK_SPEAKER_FRONT_CENTER,
636  /// so HasCenter() returns true for mono signals.
637  /// \return True when center channel is present and configuration has more than 2 channels.
639  {
640  return AK::HasCenter(uChannelMask);
641  }
642 #endif
643 };
644 
645 #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
@ AK_ChannelConfigType_Standard
Channels must be identified with standard defines in AkSpeakerConfigs.
Definition: AkEnums.h:406
AkForceInline AkChannelConfig(const AkChannelConfig &rCopy)
AkForceInline bool HasCenter() const
@ AK_ChannelConfigType_UseDevicePassthrough
Special setting for bus objects to use the audio device passthrough configuration.
Definition: AkEnums.h:412
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
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
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:73
#define AK_SPEAKER_FRONT_RIGHT
Front right speaker bit mask
AkForceInline AkUInt32 Serialize() const
Serialize channel config into a 32-bit word.
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_Objects
Object-based configurations.
Definition: AkEnums.h:408
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:69
#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
@ AK_ChannelConfigType_UseDeviceMain
Special setting for bus objects to use the audio device main configuration.
Definition: AkEnums.h:411
#define AK_SPEAKER_SETUP_5_1
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
AkForceInline bool HasSurroundChannels(AkChannelMask in_uChannelMask)
#define AK_SPEAKER_SETUP_2_0
AkForceInline bool operator==(const AkChannelConfig &in_other) const
Operator ==
@ AK_ChannelConfigType_Ambisonic
Ambisonics. Channel mask == 0 and channels follow standard ambisonic order.
Definition: AkEnums.h:407
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
@ AK_ChannelConfigType_Anonymous
Channel mask == 0 and channels are anonymous.
Definition: AkEnums.h:405
AkUInt32 eConfigType
Channel config type (AkChannelConfigType).
AkForceInline bool HasSideAndRearChannels(AkChannelMask in_uChannelMask)
AkForceInline bool HasLFE() const
AkUInt32 AkChannelMask
Channel mask (similar to extensibleWavFormat). Bit values are defined in AkSpeakerConfig....
Definition: AkTypedefs.h:60
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からはじめよう