It’s not clear from the doc strings (we could be improve that), but channels are effectively sorted by their enum value. This means, when calling getTypeOfChannel() in a loop from 0 to N, the result will increase monotonically. The doc strings for the channel layouts provide the types of channels that are included, but not necessarily the orders.
In the example you gave, the actual order should be:
left (1)
right (2)
centre (3)
lfe (4)
leftSurroundSide (10)
rightSurroundSide (11)
topFrontLeft (13)
topFrontRight (15)
topRearLeft (16)
topRearRight (18)
leftSurroundRear (20)
rightSurroundRear (21)
wideLeft (22)
wideRight (23)
topSideLeft (28)
topSideRight (29)
Listing the channels in this order in the docs would arguably make them more difficult to parse because the ‘top’ speakers are mixed in with the ‘ear-level’ speakers.
@reuk Ok, got it. Yeah it is a bit confusing. Thanks for the clarification.
Is there a reason for using a Biginteger for all that with this kind of intransparent bit juggling instead of a simple std::vector < AudioChannelSet::ChannelType > for managing the different layouts? My guess is it would make things much more easy to understand, manage and debuggable…