28 #ifndef _AK_SPEAKERCONFIG_H_
29 #define _AK_SPEAKERCONFIG_H_
31 #include <AK/SoundEngine/Common/AkTypes.h>
34 #define AK_SPEAKER_FRONT_LEFT 0x1
35 #define AK_SPEAKER_FRONT_RIGHT 0x2
36 #define AK_SPEAKER_FRONT_CENTER 0x4
37 #define AK_SPEAKER_LOW_FREQUENCY 0x8
38 #define AK_SPEAKER_BACK_LEFT 0x10
39 #define AK_SPEAKER_BACK_RIGHT 0x20
40 #define AK_SPEAKER_BACK_CENTER 0x100
41 #define AK_SPEAKER_SIDE_LEFT 0x200
42 #define AK_SPEAKER_SIDE_RIGHT 0x400
45 #define AK_SPEAKER_TOP 0x800
46 #define AK_SPEAKER_HEIGHT_FRONT_LEFT 0x1000
47 #define AK_SPEAKER_HEIGHT_FRONT_CENTER 0x2000
48 #define AK_SPEAKER_HEIGHT_FRONT_RIGHT 0x4000
49 #define AK_SPEAKER_HEIGHT_BACK_LEFT 0x8000
50 #define AK_SPEAKER_HEIGHT_BACK_CENTER 0x10000
51 #define AK_SPEAKER_HEIGHT_BACK_RIGHT 0x20000
57 #define AK_SPEAKER_SETUP_MONO AK_SPEAKER_FRONT_CENTER
58 #define AK_SPEAKER_SETUP_0POINT1 AK_SPEAKER_LOW_FREQUENCY
59 #define AK_SPEAKER_SETUP_1POINT1 (AK_SPEAKER_FRONT_CENTER | AK_SPEAKER_LOW_FREQUENCY)
60 #define AK_SPEAKER_SETUP_STEREO (AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT)
61 #define AK_SPEAKER_SETUP_2POINT1 (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_LOW_FREQUENCY)
62 #define AK_SPEAKER_SETUP_3STEREO (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_FRONT_CENTER)
63 #define AK_SPEAKER_SETUP_3POINT1 (AK_SPEAKER_SETUP_3STEREO | AK_SPEAKER_LOW_FREQUENCY)
64 #define AK_SPEAKER_SETUP_4 (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT)
65 #define AK_SPEAKER_SETUP_4POINT1 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_LOW_FREQUENCY)
66 #define AK_SPEAKER_SETUP_5 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_FRONT_CENTER)
67 #define AK_SPEAKER_SETUP_5POINT1 (AK_SPEAKER_SETUP_5 | AK_SPEAKER_LOW_FREQUENCY)
68 #define AK_SPEAKER_SETUP_6 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT)
69 #define AK_SPEAKER_SETUP_6POINT1 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_LOW_FREQUENCY)
70 #define AK_SPEAKER_SETUP_7 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_FRONT_CENTER)
71 #define AK_SPEAKER_SETUP_7POINT1 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_LOW_FREQUENCY)
72 #define AK_SPEAKER_SETUP_SURROUND (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_BACK_CENTER)
75 #define AK_SPEAKER_SETUP_DPL2 (AK_SPEAKER_SETUP_4)
77 #define AK_SPEAKER_SETUP_HEIGHT_4 (AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT | AK_SPEAKER_HEIGHT_BACK_LEFT | AK_SPEAKER_HEIGHT_BACK_RIGHT)
78 #define AK_SPEAKER_SETUP_HEIGHT_5 (AK_SPEAKER_SETUP_HEIGHT_4 | AK_SPEAKER_HEIGHT_FRONT_CENTER)
79 #define AK_SPEAKER_SETUP_HEIGHT_ALL (AK_SPEAKER_SETUP_HEIGHT_5 | AK_SPEAKER_HEIGHT_BACK_CENTER)
82 #define AK_SPEAKER_SETUP_AURO_222 (AK_SPEAKER_SETUP_4 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT)
83 #define AK_SPEAKER_SETUP_AURO_8 (AK_SPEAKER_SETUP_AURO_222 | AK_SPEAKER_HEIGHT_BACK_LEFT | AK_SPEAKER_HEIGHT_BACK_RIGHT)
84 #define AK_SPEAKER_SETUP_AURO_9 (AK_SPEAKER_SETUP_AURO_8 | AK_SPEAKER_FRONT_CENTER)
85 #define AK_SPEAKER_SETUP_AURO_9POINT1 (AK_SPEAKER_SETUP_AURO_9 | AK_SPEAKER_LOW_FREQUENCY)
86 #define AK_SPEAKER_SETUP_AURO_10 (AK_SPEAKER_SETUP_AURO_9 | AK_SPEAKER_TOP)
87 #define AK_SPEAKER_SETUP_AURO_10POINT1 (AK_SPEAKER_SETUP_AURO_10 | AK_SPEAKER_LOW_FREQUENCY)
88 #define AK_SPEAKER_SETUP_AURO_11 (AK_SPEAKER_SETUP_AURO_10 | AK_SPEAKER_HEIGHT_FRONT_CENTER)
89 #define AK_SPEAKER_SETUP_AURO_11POINT1 (AK_SPEAKER_SETUP_AURO_11 | AK_SPEAKER_LOW_FREQUENCY)
90 #define AK_SPEAKER_SETUP_AURO_11_740 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_SETUP_HEIGHT_4)
91 #define AK_SPEAKER_SETUP_AURO_11POINT1_740 (AK_SPEAKER_SETUP_AURO_11_740 | AK_SPEAKER_LOW_FREQUENCY)
92 #define AK_SPEAKER_SETUP_AURO_13_751 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_SETUP_HEIGHT_5 | AK_SPEAKER_TOP)
93 #define AK_SPEAKER_SETUP_AURO_13POINT1_751 (AK_SPEAKER_SETUP_AURO_13_751 | AK_SPEAKER_LOW_FREQUENCY)
96 #define AK_SPEAKER_SETUP_DOLBY_5_0_2 (AK_SPEAKER_SETUP_5 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT )
97 #define AK_SPEAKER_SETUP_DOLBY_5_1_2 (AK_SPEAKER_SETUP_DOLBY_5_0_2 | AK_SPEAKER_LOW_FREQUENCY )
98 #define AK_SPEAKER_SETUP_DOLBY_6_0_2 (AK_SPEAKER_SETUP_6 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT )
99 #define AK_SPEAKER_SETUP_DOLBY_6_1_2 (AK_SPEAKER_SETUP_DOLBY_6_0_2 | AK_SPEAKER_LOW_FREQUENCY )
100 #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 )
101 #define AK_SPEAKER_SETUP_DOLBY_6_1_4 (AK_SPEAKER_SETUP_DOLBY_6_0_4 | AK_SPEAKER_LOW_FREQUENCY )
102 #define AK_SPEAKER_SETUP_DOLBY_7_0_2 (AK_SPEAKER_SETUP_7 | AK_SPEAKER_HEIGHT_FRONT_LEFT | AK_SPEAKER_HEIGHT_FRONT_RIGHT )
103 #define AK_SPEAKER_SETUP_DOLBY_7_1_2 (AK_SPEAKER_SETUP_DOLBY_7_0_2 | AK_SPEAKER_LOW_FREQUENCY )
104 #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 )
105 #define AK_SPEAKER_SETUP_DOLBY_7_1_4 (AK_SPEAKER_SETUP_DOLBY_7_0_4 | AK_SPEAKER_LOW_FREQUENCY )
107 #define AK_SPEAKER_SETUP_ALL_SPEAKERS (AK_SPEAKER_SETUP_7POINT1 | AK_SPEAKER_BACK_CENTER | AK_SPEAKER_SETUP_HEIGHT_ALL | AK_SPEAKER_TOP)
113 #define AK_IDX_SETUP_FRONT_LEFT (0)
114 #define AK_IDX_SETUP_FRONT_RIGHT (1)
115 #define AK_IDX_SETUP_CENTER (2)
117 #define AK_IDX_SETUP_NOCENTER_BACK_LEFT (2)
118 #define AK_IDX_SETUP_NOCENTER_BACK_RIGHT (3)
119 #define AK_IDX_SETUP_NOCENTER_SIDE_LEFT (4)
120 #define AK_IDX_SETUP_NOCENTER_SIDE_RIGHT (5)
122 #define AK_IDX_SETUP_WITHCENTER_BACK_LEFT (3)
123 #define AK_IDX_SETUP_WITHCENTER_BACK_RIGHT (4)
124 #define AK_IDX_SETUP_WITHCENTER_SIDE_LEFT (5)
125 #define AK_IDX_SETUP_WITHCENTER_SIDE_RIGHT (6)
128 #define AK_IDX_SETUP_0_LFE (0)
130 #define AK_IDX_SETUP_1_CENTER (0)
131 #define AK_IDX_SETUP_1_LFE (1)
133 #define AK_IDX_SETUP_2_LEFT (0)
134 #define AK_IDX_SETUP_2_RIGHT (1)
135 #define AK_IDX_SETUP_2_LFE (2)
137 #define AK_IDX_SETUP_3_LEFT (0)
138 #define AK_IDX_SETUP_3_RIGHT (1)
139 #define AK_IDX_SETUP_3_CENTER (2)
140 #define AK_IDX_SETUP_3_LFE (3)
142 #define AK_IDX_SETUP_4_FRONTLEFT (0)
143 #define AK_IDX_SETUP_4_FRONTRIGHT (1)
144 #define AK_IDX_SETUP_4_REARLEFT (2)
145 #define AK_IDX_SETUP_4_REARRIGHT (3)
146 #define AK_IDX_SETUP_4_LFE (4)
148 #define AK_IDX_SETUP_5_FRONTLEFT (0)
149 #define AK_IDX_SETUP_5_FRONTRIGHT (1)
150 #define AK_IDX_SETUP_5_CENTER (2)
151 #define AK_IDX_SETUP_5_REARLEFT (3)
152 #define AK_IDX_SETUP_5_REARRIGHT (4)
153 #define AK_IDX_SETUP_5_LFE (5)
156 #define AK_IDX_SETUP_6_FRONTLEFT (0)
157 #define AK_IDX_SETUP_6_FRONTRIGHT (1)
158 #define AK_IDX_SETUP_6_REARLEFT (2)
159 #define AK_IDX_SETUP_6_REARRIGHT (3)
160 #define AK_IDX_SETUP_6_SIDELEFT (4)
161 #define AK_IDX_SETUP_6_SIDERIGHT (5)
162 #define AK_IDX_SETUP_6_LFE (6)
164 #define AK_IDX_SETUP_7_FRONTLEFT (0)
165 #define AK_IDX_SETUP_7_FRONTRIGHT (1)
166 #define AK_IDX_SETUP_7_CENTER (2)
167 #define AK_IDX_SETUP_7_REARLEFT (3)
168 #define AK_IDX_SETUP_7_REARRIGHT (4)
169 #define AK_IDX_SETUP_7_SIDELEFT (5)
170 #define AK_IDX_SETUP_7_SIDERIGHT (6)
171 #define AK_IDX_SETUP_7_LFE (7)
179 #define AK_SPEAKER_SETUP_0_1 ( AK_SPEAKER_LOW_FREQUENCY ) //0.1
181 #define AK_SPEAKER_SETUP_1_0_CENTER ( AK_SPEAKER_FRONT_CENTER ) //1.0 (C)
182 #define AK_SPEAKER_SETUP_1_1_CENTER ( AK_SPEAKER_FRONT_CENTER | AK_SPEAKER_LOW_FREQUENCY ) //1.1 (C)
184 #define AK_SPEAKER_SETUP_2_0 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT ) //2.0
185 #define AK_SPEAKER_SETUP_2_1 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT | AK_SPEAKER_LOW_FREQUENCY ) //2.1
187 #define AK_SPEAKER_SETUP_3_0 ( AK_SPEAKER_FRONT_LEFT | AK_SPEAKER_FRONT_RIGHT | AK_SPEAKER_FRONT_CENTER ) //3.0
188 #define AK_SPEAKER_SETUP_3_1 ( AK_SPEAKER_SETUP_3_0 | AK_SPEAKER_LOW_FREQUENCY ) //3.1
190 #define AK_SPEAKER_SETUP_FRONT ( AK_SPEAKER_SETUP_3_0 )
192 #define AK_SPEAKER_SETUP_4_0 ( AK_SPEAKER_SETUP_4 )
193 #define AK_SPEAKER_SETUP_4_1 ( AK_SPEAKER_SETUP_4POINT1 )
194 #define AK_SPEAKER_SETUP_5_0 ( AK_SPEAKER_SETUP_5 )
195 #define AK_SPEAKER_SETUP_5_1 ( AK_SPEAKER_SETUP_5POINT1 )
197 #define AK_SPEAKER_SETUP_6_0 ( AK_SPEAKER_SETUP_6 )
198 #define AK_SPEAKER_SETUP_6_1 ( AK_SPEAKER_SETUP_6POINT1 )
199 #define AK_SPEAKER_SETUP_7_0 ( AK_SPEAKER_SETUP_7 )
200 #define AK_SPEAKER_SETUP_7_1 ( AK_SPEAKER_SETUP_7POINT1 )
203 #if defined(AK_71AUDIO)
204 #define AK_SPEAKER_SETUP_DEFAULT_PLANE (AK_SPEAKER_SETUP_7POINT1)
205 #define AK_SUPPORTED_STANDARD_CHANNEL_MASK (AK_SPEAKER_SETUP_ALL_SPEAKERS)
206 #define AK_STANDARD_MAX_NUM_CHANNELS (8)
207 #elif defined(AK_LFECENTER) && defined(AK_REARCHANNELS)
208 #define AK_SPEAKER_SETUP_DEFAULT_PLANE (AK_SPEAKER_SETUP_5POINT1)
209 #define AK_SUPPORTED_STANDARD_CHANNEL_MASK (AK_SPEAKER_SETUP_DEFAULT_PLANE)
210 #define AK_VOICE_MAX_NUM_CHANNELS (6)
211 #define AK_STANDARD_MAX_NUM_CHANNELS (AK_VOICE_MAX_NUM_CHANNELS)
212 #elif defined(AK_REARCHANNELS)
213 #define AK_SPEAKER_SETUP_DEFAULT_PLANE (AK_SPEAKER_SETUP_4 | AK_SPEAKER_FRONT_CENTER)
214 #define AK_VOICE_MAX_NUM_CHANNELS (4)
215 #define AK_SUPPORTED_STANDARD_CHANNEL_MASK (AK_SPEAKER_SETUP_DEFAULT_PLANE)
217 #define AK_SPEAKER_SETUP_DEFAULT_PLANE (AK_SPEAKER_SETUP_STEREO | AK_SPEAKER_FRONT_CENTER)
218 #define AK_SUPPORTED_STANDARD_CHANNEL_MASK (AK_SPEAKER_SETUP_STEREO)
219 #define AK_VOICE_MAX_NUM_CHANNELS (2)
220 #define AK_STANDARD_MAX_NUM_CHANNELS (AK_VOICE_MAX_NUM_CHANNELS)
224 #define AK_NUM_SAMPLED_SPHERE_POINTS (32)
227 inline void AK_SPEAKER_SETUP_FIX_LEFT_TO_CENTER( AkUInt32 &io_uChannelMask )
229 if( !(io_uChannelMask & AK_SPEAKER_FRONT_CENTER)
230 && !(io_uChannelMask & AK_SPEAKER_FRONT_RIGHT)
231 && (io_uChannelMask & AK_SPEAKER_FRONT_LEFT) )
233 io_uChannelMask &= ~AK_SPEAKER_FRONT_LEFT;
234 io_uChannelMask |= AK_SPEAKER_FRONT_CENTER;
238 inline void AK_SPEAKER_SETUP_FIX_REAR_TO_SIDE( AkUInt32 &io_uChannelMask )
240 if( io_uChannelMask & ( AK_SPEAKER_BACK_LEFT ) && !( io_uChannelMask & AK_SPEAKER_SIDE_LEFT ) )
242 io_uChannelMask &= ~( AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT );
243 io_uChannelMask |= ( AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT );
247 inline void AK_SPEAKER_SETUP_CONVERT_TO_SUPPORTED( AkUInt32 &io_uChannelMask )
249 AK_SPEAKER_SETUP_FIX_LEFT_TO_CENTER( io_uChannelMask );
250 AK_SPEAKER_SETUP_FIX_REAR_TO_SIDE( io_uChannelMask );
275 while( in_uChannelMask ){ ++num; in_uChannelMask &= in_uChannelMask-1; }
283 AkChannelMask uChannelMask = 0;
285 switch ( in_uNumChannels )
288 uChannelMask = AK_SPEAKER_SETUP_1_0_CENTER;
291 uChannelMask = AK_SPEAKER_SETUP_2_0;
294 uChannelMask = AK_SPEAKER_SETUP_2_1;
297 uChannelMask = AK_SPEAKER_SETUP_4_0;
300 uChannelMask = AK_SPEAKER_SETUP_5_0;
303 uChannelMask = AK_SPEAKER_SETUP_5_1;
306 uChannelMask = AK_SPEAKER_SETUP_7;
309 uChannelMask = AK_SPEAKER_SETUP_7POINT1;
318 static inline AkUInt8
ChannelBitToIndex(AkChannelMask in_uChannelBit, AkChannelMask in_uChannelMask)
323 if (in_uChannelBit == AK_SPEAKER_LOW_FREQUENCY)
330 AkForceInline
bool HasLFE(AkChannelMask in_uChannelMask)
332 return (in_uChannelMask & AK_SPEAKER_LOW_FREQUENCY) > 0;
339 AkForceInline
bool HasCenter(AkChannelMask in_uChannelMask)
342 return (in_uChannelMask & AK_SPEAKER_FRONT_CENTER) > 0;
351 AKASSERT((in_uChannelMask & ~AK_SPEAKER_SETUP_DEFAULT_PLANE) == 0);
355 in_uChannelMask &= ~AK_SPEAKER_LOW_FREQUENCY;
357 in_uChannelMask &= ~AK_SPEAKER_FRONT_CENTER;
377 return ( in_uChannelMask & AK_SPEAKER_BACK_LEFT || in_uChannelMask & AK_SPEAKER_SIDE_LEFT );
385 return ( ( ( in_uChannelMask & AK_SPEAKER_BACK_LEFT ) != 0 ) ^ ( ( in_uChannelMask & AK_SPEAKER_SIDE_LEFT ) != 0 ) );
393 return ( in_uChannelMask & AK_SPEAKER_BACK_LEFT && in_uChannelMask & AK_SPEAKER_SIDE_LEFT );
399 return (in_uChannelMask & ~AK_SPEAKER_SETUP_DEFAULT_PLANE) > 0;
408 in_uChannelMask &= ~( AK_SPEAKER_BACK_LEFT | AK_SPEAKER_BACK_RIGHT );
409 in_uChannelMask |= ( AK_SPEAKER_SIDE_LEFT | AK_SPEAKER_SIDE_RIGHT );
411 return in_uChannelMask;
423 if ( ( in_uChannelMask & AK_SPEAKER_LOW_FREQUENCY )
424 && ( in_uChannelIdx == uNumChannelsFront ) )
429 else if ( in_uChannelIdx >= uNumChannelsFront )
432 unsigned int uLfeOffset = ( in_uChannelMask & AK_SPEAKER_LOW_FREQUENCY ) ? 1 : 0;
437 unsigned int uRearIdx = uNumChannelsFront + uLfeOffset;
438 unsigned int uSideIdx = uRearIdx + 2;
439 unsigned int uAfterSideIdx = uSideIdx + 2;
440 if ( in_uChannelIdx < uAfterSideIdx )
442 if ( in_uChannelIdx >= uSideIdx )
448 in_uChannelIdx -= uLfeOffset;
457 unsigned int uMaxIdx = uRearIdx + 4;
459 if ( in_uChannelIdx >= uRearIdx
460 && in_uChannelIdx < uMaxIdx )
463 unsigned int uSideIdx = uRearIdx + 2;
464 if ( in_uChannelIdx >= uSideIdx )
472 return in_uChannelIdx;
478 enum AkChannelConfigType
480 AK_ChannelConfigType_Anonymous = 0x0,
481 AK_ChannelConfigType_Standard = 0x1,
482 AK_ChannelConfigType_Ambisonic = 0x2
532 return (*((AkUInt32*)
this) != in_uBitField);
558 eConfigType = (in_uChannelMask) ? AK_ChannelConfigType_Standard : AK_ChannelConfigType_Anonymous;
594 eConfigType = (in_uChannelConfig >> 8) & 0x0000000f;
603 AkUInt32 uNewChannelMask = newConfig.
uChannelMask & ~AK_SPEAKER_LOW_FREQUENCY;
604 AkUInt32 uNumLFEChannel = (newConfig.
uChannelMask - uNewChannelMask) >> 3;
606 AKASSERT(uNumLFEChannel == 0 || uNumLFEChannel == 1);
619 AkUInt32 uNewChannelMask = newConfig.
uChannelMask & ~AK_SPEAKER_FRONT_CENTER;
620 AkUInt32 uNumCenterChannel = (newConfig.
uChannelMask - uNewChannelMask) >> 2;
622 AKASSERT(uNumCenterChannel == 0 || uNumCenterChannel == 1);
657 case AK_SPEAKER_SETUP_MONO:
658 case AK_SPEAKER_SETUP_STEREO:
660 case AK_SPEAKER_SETUP_0POINT1:
661 case AK_SPEAKER_SETUP_1POINT1:
662 case AK_SPEAKER_SETUP_2POINT1:
663 case AK_SPEAKER_SETUP_3STEREO:
664 case AK_SPEAKER_SETUP_3POINT1:
665 #ifdef AK_REARCHANNELS
666 case AK_SPEAKER_SETUP_4:
667 case AK_SPEAKER_SETUP_4POINT1:
668 case AK_SPEAKER_SETUP_5:
669 case AK_SPEAKER_SETUP_5POINT1:
704 #endif //_AK_SPEAKERCONFIG_H_