50 template<CVec3 Vec3Type>
51 [[nodiscard]]
inline Vec3Type
ComputeVBAP(
const Vec3Type& sourceDirection,
const Vec3Type& triPointA,
const Vec3Type& triPointB,
const Vec3Type& triPointC)
64 return Vec3Type{ 0.0f, 0.0f, 0.0f };
84 return Vec2{ 0.0f, 0.0f };
90 namespace SpeakerTriangulation
92 using Vec3i = std::array<uint8, 3>;
94 template<auto GetSpeakerVectorFunction,
class Vec3ContainerType>
103 outVectors.reserve(numChannels);
109 outVectors.push_back(GetSpeakerVectorFunction(channel));
115 template<auto GetSpeakerVectorFunction,
class Vec3ContainerType,
class IndexContainerType>
124 outMapIndices.clear();
125 outVectors.reserve(numChannels);
126 outMapIndices.reserve(numChannels);
132 outVectors.push_back(GetSpeakerVectorFunction(channel));
133 outMapIndices.push_back(index);
140 template<CVec3 Vec3Type,
class Vec3iContainerType>
143 const auto& vertices = speakerVectors;
146 if (vertices.size() == 3)
148 outIndices.push_back({ 0, 1, 2 });
162 HullBuilderType builder(vertices);
164 const char* errorMessage =
nullptr;
166 if (builder.Initialize(INT_MAX, 0.0f, errorMessage) != HullBuilderType::EResult::Success)
169 if (!
JPL_ENSURE(builder.GetNumVerticesUsed() == vertices.size()))
172 builder.GetTriangles(outIndices);
177 template<auto GetSpeakerVectorFunction, CVec3 Vec3Type,
class Vec3ContainerType,
class Vec3iContainerType>
203 dummySpeakers.
AddDummy(Vec3Type(0.0f, -1.0f, 0.0f));
205 const int numTopChannels = [channelMap]()
207 int numTopChannels = 0;
212 return numTopChannels;
216 if (numTopChannels == 6 || numTopChannels == 4)
227 outVertices = std::move(vertices);
249 const float a2 = other.Angle < 0.0f ? other.Angle + JPL_TWO_PI : other.Angle;
250 if (a1 < a2)
return std::strong_ordering::less;
251 if (a1 > a2)
return std::strong_ordering::greater;
252 return std::strong_ordering::equal;
257 template<
template<
typename...>
class ArrayType,
class ...Args>
260 ArrayType<ChannelAngle, Args...>& sortedChannelAngles,
261 std::function<
float(
EChannel)> getChannelAngle,
264 sortedChannelAngles.clear();
286 const float channelAngle = getChannelAngle(channel);
288 sortedChannelAngles.emplace_back(channelAngle < 0.0f ? channelAngle + JPL_TWO_PI : channelAngle, channelIndex);
291 std::ranges::sort(sortedChannelAngles);
#define JPL_ASSERT(inExpression,...)
Main assert macro, usage: JPL_ASSERT(condition, message) or JPL_ASSERT(condition)
Definition ErrorReporting.h:80
#define JPL_ENSURE(inExpression,...)
Define ENSURE.
Definition ErrorReporting.h:94
Definition ChannelMap.h:154
constexpr uint32 GetNumChannels() const noexcept
Definition ChannelMap.h:166
constexpr bool IsValid() const noexcept
Definition ChannelMap.h:164
constexpr bool HasTopChannels() const noexcept
Definition ChannelMap.h:163
constexpr bool HasLFE() const noexcept
Definition ChannelMap.h:162
constexpr void ForEachChannel(Predicate predicate) const
Definition ChannelMap.h:222
Definition ConvexHullBuilder.h:57
Utility class to encapsulate dummy speaker handling while building a LUT.
Definition DummySpeakers.h:36
JPL_INLINE constexpr void AddIfChannelNotPresent(EChannel channel)
Definition DummySpeakers.h:53
JPL_INLINE constexpr void AddDummy(const Vec3Type &speakerVector)
Definition DummySpeakers.h:47
JPL_INLINE constexpr auto Abs(const T &value) noexcept
Standard abs is not constexpr in C++20.
Definition Math.h:87
bool GetSpeakerVectors(ChannelMap channelMap, Vec3ContainerType &outVectors)
Definition VBAPEx.h:95
std::array< uint8, 3 > Vec3i
Definition VBAPEx.h:92
bool TriangulateSpeakerLayout(std::span< const Vec3Type > speakerVectors, Vec3iContainerType &outIndices)
Definition VBAPEx.h:141
Definition AcousticMaterial.h:36
std::uint32_t uint32
Definition Core.h:311
Vec3Type ComputeVBAP(const Vec3Type &sourceDirection, const Vec3Type &triPointA, const Vec3Type &triPointB, const Vec3Type &triPointC)
Definition VBAPEx.h:51
std::pmr::memory_resource * GetDefaultMemoryResource() noexcept
Definition Memory.h:42
EChannel
Definition ChannelMap.h:39
@ TOP_Channels
Definition ChannelMap.h:75
@ TopCenter
Definition ChannelMap.h:58
@ LFE
Definition ChannelMap.h:43
Minimal 2x2 matrix interface.
Definition MinimalMat.h:35
static JPL_INLINE constexpr Mat2 FromColumns(const Vec2 &l1, const Vec2 &l2) noexcept
Definition MinimalMat.h:42
JPL_INLINE constexpr Vec2 Transform(const Vec2 &p) const noexcept
Definition MinimalMat.h:45
Minimal 3x3 matrix interface.
Definition MinimalMat.h:83
JPL_INLINE constexpr Vec3 Transform(const Vec3 &v) const noexcept
Definition MinimalMat.h:92
static JPL_INLINE constexpr Mat3 FromColumns(const Vec3 &l1, const Vec3 &l2, const Vec3 &l3) noexcept
Definition MinimalMat.h:90
JPL_INLINE constexpr std::strong_ordering operator<=>(const ChannelAngle &other) const noexcept
Definition VBAPEx.h:246
float Angle
Definition VBAPEx.h:242
uint32 ChannelId
Definition VBAPEx.h:243
JPL_INLINE constexpr bool operator==(const ChannelAngle &other) const noexcept
Definition VBAPEx.h:254
static void GetSortedChannelAngles(ChannelMap channelMap, ArrayType< ChannelAngle, Args... > &sortedChannelAngles, std::function< float(EChannel)> getChannelAngle, bool skipLFE=true)
Get channel angles from ChannelMap, normalize to [0, Pi] and sort in assending order.
Definition VBAPEx.h:258
Definition MinimalVec2.h:29