161 [[nodiscard]]
constexpr bool Has(
EChannel channel)
const noexcept {
return (mChannelMask &
static_cast<uint32_t
>(channel)) == channel; }
162 [[nodiscard]]
constexpr bool HasLFE() const noexcept {
return (mChannelMask &
static_cast<uint32_t
>(EChannel::LFE)) == EChannel::LFE; }
163 [[nodiscard]]
constexpr bool HasTopChannels() const noexcept {
return mChannelMask >= EChannel::TOP_Channels; }
164 [[nodiscard]]
constexpr bool IsValid() const noexcept {
return mChannelMask != ChannelMask::Invalid; }
170 return InvalidChannelIndex;
173 int value =
static_cast<int>(mChannelMask);
176 if (channel ==
static_cast<EChannel>(value & -value))
179 value &= (value - 1);
182 return InvalidChannelIndex;
187 EChannel foundChannel = EChannel::Invalid;
189 ForEachChannel([index, &foundChannel](
EChannel channel,
uint32 channelIndex)
191 if (channelIndex == index)
192 foundChannel = channel;
208 case 2:
return ChannelMap(ChannelMask::Stereo);
211 case 5:
return ChannelMap(ChannelMask::Surround_4_1);
212 case 6:
return ChannelMap(ChannelMask::Surround_5_1);
213 case 7:
return ChannelMap(ChannelMask::Surround_6_1);
214 case 8:
return ChannelMap(ChannelMask::Surround_7_1);
216 JPL_ASSERT(
"ChannelMap can be created from channel count up to 8 channels.");
221 template<
class Predicate>
225 int value =
static_cast<int>(mChannelMask);
228 static_assert(std::invocable<Predicate, EChannel, uint32> ||
229 std::invocable<Predicate, EChannel>,
"Invalid predicate signature.");
231 const auto channel =
static_cast<EChannel>(value & -value);
232 if constexpr (std::invocable<Predicate, EChannel, uint32>)
233 predicate(channel, channelIndex);
238 value &= (value - 1);
243 [[nodiscard]]
constexpr bool operator==(
const ChannelMap& other)
const noexcept {
return mChannelMask == other.mChannelMask; }
244 [[nodiscard]]
constexpr bool operator!=(
const ChannelMap& other)
const noexcept {
return mChannelMask != other.mChannelMask; }
248 uint32 mChannelMask = ChannelMask::Invalid;
259 : Name(ChannelMask::
ToString(channelMask))
260 , Layout(
ChannelMap::FromChannelMask(channelMask))
266 JPL_INLINE
bool operator==(const
NamedChannelMask& other) const noexcept {
return other.Layout == Layout; }
274 struct [[nodiscard]] hash<
JPL::ChannelMap>
278 return channelMap.mChannelMask;
#define JPL_BIT(x)
Definition Core.h:359
#define JPL_ASSERT(inExpression,...)
Main assert macro, usage: JPL_ASSERT(condition, message) or JPL_ASSERT(condition)
Definition ErrorReporting.h:80
Definition ChannelMap.h:154
constexpr uint32 GetNumChannels() const noexcept
Definition ChannelMap.h:166
constexpr bool IsValid() const noexcept
Definition ChannelMap.h:164
constexpr bool operator==(const ChannelMap &other) const noexcept
Definition ChannelMap.h:243
static constexpr ChannelMap FromNumChannels(uint32 numChannels)
Definition ChannelMap.h:203
static constexpr ChannelMap FromChannelMask(uint32 channelMask)
Definition ChannelMap.h:202
constexpr bool operator!=(const ChannelMap &other) const noexcept
Definition ChannelMap.h:244
constexpr ChannelMap()=default
constexpr uint32 GetChannelMask() const
Definition ChannelMap.h:198
constexpr bool HasTopChannels() const noexcept
Definition ChannelMap.h:163
constexpr EChannel GetChannelAtIndex(uint32 index) const
Definition ChannelMap.h:185
constexpr uint32 GetChannelIndex(EChannel channel) const
Definition ChannelMap.h:167
constexpr bool HasLFE() const noexcept
Definition ChannelMap.h:162
constexpr bool Has(EChannel channel) const noexcept
Definition ChannelMap.h:161
constexpr void ForEachChannel(Predicate predicate) const
Definition ChannelMap.h:222
constexpr uint32 Surround_7_1
Definition ChannelMap.h:121
constexpr uint32 LCR
Definition ChannelMap.h:98
constexpr uint32 Surround_5_1
Definition ChannelMap.h:114
constexpr uint32 Pentagonal
Definition ChannelMap.h:104
constexpr uint32 Surround_9_0_6
Definition ChannelMap.h:143
constexpr uint32 Surround_7_0_2
Definition ChannelMap.h:131
constexpr uint32 Surround_7_0
Definition ChannelMap.h:120
constexpr uint32 Surround_7_1_4
Definition ChannelMap.h:134
constexpr uint32 Surround_6_1
Definition ChannelMap.h:116
constexpr uint32 Stereo
Definition ChannelMap.h:97
constexpr uint32 Surround_9_0_4
Definition ChannelMap.h:141
constexpr uint32 Surround_5_1_4
Definition ChannelMap.h:127
constexpr uint32 LRS
Definition ChannelMap.h:99
constexpr uint32 Octagonal
Definition ChannelMap.h:109
constexpr uint32 Surround_4_1
Definition ChannelMap.h:112
constexpr uint32 Surround_7_0_4
Definition ChannelMap.h:133
constexpr uint32 Invalid
Definition ChannelMap.h:93
constexpr uint32 Surround_6_0
Definition ChannelMap.h:115
constexpr uint32 LCRS
Definition ChannelMap.h:100
constexpr uint32 Surround_5_0
Definition ChannelMap.h:113
constexpr uint32 Surround_7_0_6
Definition ChannelMap.h:136
JPL_INLINE std::string_view ToString(uint32 channelMask)
Definition ChannelMap.h:285
constexpr uint32 Surround_9_1_6
Definition ChannelMap.h:144
constexpr uint32 Surround_9_1_4
Definition ChannelMap.h:142
constexpr uint32 Surround_5_0_4
Definition ChannelMap.h:126
constexpr uint32 Quad
Definition ChannelMap.h:101
constexpr uint32 Surround_7_1_6
Definition ChannelMap.h:137
constexpr uint32 Surround_7_1_2
Definition ChannelMap.h:132
constexpr uint32 Surround_5_0_2
Definition ChannelMap.h:124
constexpr uint32 Mono
Definition ChannelMap.h:96
constexpr uint32 Surround_5_1_2
Definition ChannelMap.h:125
Definition AcousticMaterial.h:36
std::uint32_t uint32
Definition Core.h:311
constexpr std::string_view ToString(EChannel channel)
Definition ChannelMap.h:325
constexpr std::string_view ToStringShort(EChannel channel)
Definition ChannelMap.h:356
EChannel
Definition ChannelMap.h:39
@ TOP_Channels
Definition ChannelMap.h:75
@ TopBackLeft
Definition ChannelMap.h:67
@ TopFrontRight
Definition ChannelMap.h:61
@ BackCenter
Definition ChannelMap.h:53
@ TopSideRight
Definition ChannelMap.h:65
@ Invalid
Definition ChannelMap.h:78
@ TopFrontCenter
Definition ChannelMap.h:60
@ TopSideLeft
Definition ChannelMap.h:64
@ FrontLeftCenter
Definition ChannelMap.h:48
@ TopBackCenter
Definition ChannelMap.h:68
@ SideRight
Definition ChannelMap.h:46
@ SideLeft
Definition ChannelMap.h:45
@ FrontCenter
Definition ChannelMap.h:42
@ WideRight
Definition ChannelMap.h:56
@ BackRight
Definition ChannelMap.h:52
@ NUM_GroundChannels
Definition ChannelMap.h:73
@ NUM_TopChannels
Definition ChannelMap.h:76
@ TopBackRight
Definition ChannelMap.h:69
@ BackLeft
Definition ChannelMap.h:51
@ FrontRightCenter
Definition ChannelMap.h:49
@ TopCenter
Definition ChannelMap.h:58
@ LFE
Definition ChannelMap.h:43
@ FrontLeft
Definition ChannelMap.h:40
@ WideLeft
Definition ChannelMap.h:55
@ TopFrontLeft
Definition ChannelMap.h:59
@ FrontRight
Definition ChannelMap.h:41
Definition ChannelMap.h:272
Utility to hold some channel mask with a name.
Definition ChannelMap.h:254
NamedChannelMask(uint32 channelMask)
Definition ChannelMap.h:258
std::string_view Name
Definition ChannelMap.h:255
ChannelMap Layout
Definition ChannelMap.h:256
NamedChannelMask() noexcept=default
constexpr std::size_t operator()(const JPL::ChannelMap &channelMap) const
Definition ChannelMap.h:276