-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (51 loc) · 1.7 KB
/
Copy pathmain.cpp
File metadata and controls
61 lines (51 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <JPLSpatial/ChannelMap.h>
#include <JPLSpatial/Math/MinimalVec3.h>
#include <JPLSpatial/Panning/VBAPanning2D.h>
#include <array>
#include <iomanip>
#include <iostream>
#include <string_view>
namespace
{
struct DirectionExample
{
std::string_view Name;
JPL::MinimalVec3 Direction;
};
constexpr std::array cDirectionExamples{
DirectionExample{ "front", JPL::MinimalVec3{ 0.0f, 0.0f, -1.0f } },
DirectionExample{ "right", JPL::MinimalVec3{ 1.0f, 0.0f, 0.0f } },
DirectionExample{ "back", JPL::MinimalVec3{ 0.0f, 0.0f, 1.0f } },
DirectionExample{ "left", JPL::MinimalVec3{ -1.0f, 0.0f, 0.0f } },
};
constexpr std::array cChannels{
JPL::EChannel::FrontLeft,
JPL::EChannel::FrontRight,
JPL::EChannel::BackLeft,
JPL::EChannel::BackRight
};
}
int main()
{
const auto outputLayout = JPL::ChannelMap::FromChannelMask(JPL::ChannelMask::Quad);
JPL::StandardPanner2D panner;
if (!panner.Initialize(outputLayout))
{
std::cerr << "Could not initialize the quad VBAP panner.\n";
return 1;
}
std::array<float, cChannels.size()> gains{};
std::cout << std::fixed << std::setprecision(4);
for (const auto& example : cDirectionExamples)
{
panner.GetSpeakerGains(example.Direction, gains);
std::cout << std::left << std::setw(7) << example.Name;
for (std::size_t channelIdx = 0; channelIdx < gains.size(); ++channelIdx)
{
std::cout << JPL::ToStringShort(cChannels[channelIdx]) << '=' << gains[channelIdx];
if (channelIdx + 1 != gains.size())
std::cout << " ";
}
std::cout << '\n';
}
}