mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-10 22:24:33 +00:00
update openal-soft to 1.24.3
keeping the alt 87514151c4 (diff-73a8dc1ce58605f6c5ea53548454c3bae516ec5132a29c9d7ff7edf9730c75be)
This commit is contained in:
parent
12db0500e8
commit
ba32094b7b
276 changed files with 49304 additions and 8712 deletions
|
|
@ -27,7 +27,6 @@
|
|||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
|
|
@ -38,7 +37,7 @@
|
|||
|
||||
#include "alnumbers.h"
|
||||
#include "alspan.h"
|
||||
#include "alstring.h"
|
||||
#include "fmt/core.h"
|
||||
#include "phase_shifter.h"
|
||||
#include "vector.h"
|
||||
|
||||
|
|
@ -49,6 +48,8 @@
|
|||
|
||||
namespace {
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
struct SndFileDeleter {
|
||||
void operator()(SNDFILE *sndfile) { sf_close(sndfile); }
|
||||
};
|
||||
|
|
@ -249,49 +250,63 @@ int main(al::span<std::string_view> args)
|
|||
{
|
||||
if(args.size() < 2 || args[1] == "-h" || args[1] == "--help")
|
||||
{
|
||||
printf("Usage: %.*s <infile...>\n\n", al::sizei(args[0]), args[0].data());
|
||||
fmt::println("Usage: {} <[options] infile...>\n\n"
|
||||
" Options:\n"
|
||||
" -bhj Encode 2-channel UHJ, aka \"BJH\" (default).\n"
|
||||
" -thj Encode 3-channel UHJ, aka \"TJH\".\n"
|
||||
" -phj Encode 4-channel UHJ, aka \"PJH\".\n"
|
||||
"\n"
|
||||
"3-channel UHJ supplements 2-channel UHJ with an extra channel that allows full\n"
|
||||
"reconstruction of first-order 2D ambisonics. 4-channel UHJ supplements 3-channel\n"
|
||||
"UHJ with an extra channel carrying height information, providing for full\n"
|
||||
"reconstruction of first-order 3D ambisonics.\n"
|
||||
"\n"
|
||||
"Note: The third and fourth channels should be ignored if they're not being\n"
|
||||
"decoded. Unlike the first two channels, they are not designed for undecoded\n"
|
||||
"playback, so the resulting files will not play correctly if this isn't handled.",
|
||||
args[0]);
|
||||
return 1;
|
||||
}
|
||||
args = args.subspan(1);
|
||||
|
||||
uint uhjchans{2};
|
||||
size_t num_files{0}, num_encoded{0};
|
||||
for(size_t fidx{1};fidx < args.size();++fidx)
|
||||
auto process_arg = [&uhjchans,&num_files,&num_encoded](std::string_view arg) -> void
|
||||
{
|
||||
if(args[fidx] == "-bhj")
|
||||
if(arg == "-bhj"sv)
|
||||
{
|
||||
uhjchans = 2;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if(args[fidx] == "-thj")
|
||||
if(arg == "-thj"sv)
|
||||
{
|
||||
uhjchans = 3;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if(args[fidx] == "-phj")
|
||||
if(arg == "-phj"sv)
|
||||
{
|
||||
uhjchans = 4;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
++num_files;
|
||||
|
||||
std::string outname{args[fidx]};
|
||||
size_t lastslash{outname.find_last_of('/')};
|
||||
auto outname = std::string{arg};
|
||||
const auto lastslash = outname.rfind('/');
|
||||
if(lastslash != std::string::npos)
|
||||
outname.erase(0, lastslash+1);
|
||||
size_t extpos{outname.find_last_of('.')};
|
||||
const auto extpos = outname.rfind('.');
|
||||
if(extpos != std::string::npos)
|
||||
outname.resize(extpos);
|
||||
outname += ".uhj.flac";
|
||||
|
||||
SF_INFO ininfo{};
|
||||
SndFilePtr infile{sf_open(std::string{args[fidx]}.c_str(), SFM_READ, &ininfo)};
|
||||
SndFilePtr infile{sf_open(std::string{arg}.c_str(), SFM_READ, &ininfo)};
|
||||
if(!infile)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %.*s\n", al::sizei(args[fidx]), args[fidx].data());
|
||||
continue;
|
||||
fmt::println(stderr, "Failed to open {}", arg);
|
||||
return;
|
||||
}
|
||||
printf("Converting %.*s to %s...\n", al::sizei(args[fidx]), args[fidx].data(),
|
||||
outname.c_str());
|
||||
fmt::println("Converting {} to {}...", arg, outname);
|
||||
|
||||
/* Work out the channel map, preferably using the actual channel map
|
||||
* from the file/format, but falling back to assuming WFX order.
|
||||
|
|
@ -365,27 +380,51 @@ int main(al::span<std::string_view> args)
|
|||
mapstr += std::to_string(idx);
|
||||
}
|
||||
}
|
||||
fprintf(stderr, " ... %zu channels not supported (map: %s)\n", chanmap.size(),
|
||||
mapstr.c_str());
|
||||
continue;
|
||||
fmt::println(stderr, " ... {} channels not supported (map: {})", chanmap.size(),
|
||||
mapstr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sf_command(infile.get(), SFC_WAVEX_GET_AMBISONIC, nullptr,
|
||||
0) == SF_AMBISONIC_B_FORMAT)
|
||||
{
|
||||
if(ininfo.channels == 4)
|
||||
{
|
||||
fmt::println(stderr, " ... detected FuMa 3D B-Format");
|
||||
chanmap[0] = SF_CHANNEL_MAP_AMBISONIC_B_W;
|
||||
chanmap[1] = SF_CHANNEL_MAP_AMBISONIC_B_X;
|
||||
chanmap[2] = SF_CHANNEL_MAP_AMBISONIC_B_Y;
|
||||
chanmap[3] = SF_CHANNEL_MAP_AMBISONIC_B_Z;
|
||||
}
|
||||
else if(ininfo.channels == 3)
|
||||
{
|
||||
fmt::println(stderr, " ... detected FuMa 2D B-Format");
|
||||
chanmap[0] = SF_CHANNEL_MAP_AMBISONIC_B_W;
|
||||
chanmap[1] = SF_CHANNEL_MAP_AMBISONIC_B_X;
|
||||
chanmap[2] = SF_CHANNEL_MAP_AMBISONIC_B_Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt::println(stderr, " ... unhandled {}-channel B-Format", ininfo.channels);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(ininfo.channels == 1)
|
||||
{
|
||||
fprintf(stderr, " ... assuming front-center\n");
|
||||
fmt::println(stderr, " ... assuming front-center");
|
||||
spkrs = MonoMap;
|
||||
chanmap[0] = SF_CHANNEL_MAP_CENTER;
|
||||
}
|
||||
else if(ininfo.channels == 2)
|
||||
{
|
||||
fprintf(stderr, " ... assuming WFX order stereo\n");
|
||||
fmt::println(stderr, " ... assuming WFX order stereo");
|
||||
spkrs = StereoMap;
|
||||
chanmap[0] = SF_CHANNEL_MAP_LEFT;
|
||||
chanmap[1] = SF_CHANNEL_MAP_RIGHT;
|
||||
}
|
||||
else if(ininfo.channels == 6)
|
||||
{
|
||||
fprintf(stderr, " ... assuming WFX order 5.1\n");
|
||||
fmt::println(stderr, " ... assuming WFX order 5.1");
|
||||
spkrs = X51Map;
|
||||
chanmap[0] = SF_CHANNEL_MAP_LEFT;
|
||||
chanmap[1] = SF_CHANNEL_MAP_RIGHT;
|
||||
|
|
@ -396,7 +435,7 @@ int main(al::span<std::string_view> args)
|
|||
}
|
||||
else if(ininfo.channels == 8)
|
||||
{
|
||||
fprintf(stderr, " ... assuming WFX order 7.1\n");
|
||||
fmt::println(stderr, " ... assuming WFX order 7.1");
|
||||
spkrs = X71Map;
|
||||
chanmap[0] = SF_CHANNEL_MAP_LEFT;
|
||||
chanmap[1] = SF_CHANNEL_MAP_RIGHT;
|
||||
|
|
@ -409,8 +448,8 @@ int main(al::span<std::string_view> args)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " ... unmapped %d-channel audio not supported\n", ininfo.channels);
|
||||
continue;
|
||||
fmt::println(stderr, " ... unmapped {}-channel audio not supported", ininfo.channels);
|
||||
return;
|
||||
}
|
||||
|
||||
SF_INFO outinfo{};
|
||||
|
|
@ -421,8 +460,8 @@ int main(al::span<std::string_view> args)
|
|||
SndFilePtr outfile{sf_open(outname.c_str(), SFM_WRITE, &outinfo)};
|
||||
if(!outfile)
|
||||
{
|
||||
fprintf(stderr, " ... failed to create %s\n", outname.c_str());
|
||||
continue;
|
||||
fmt::println(stderr, " ... failed to create {}", outname);
|
||||
return;
|
||||
}
|
||||
|
||||
auto encoder = std::make_unique<UhjEncoder>();
|
||||
|
|
@ -485,7 +524,7 @@ int main(al::span<std::string_view> args)
|
|||
[chanid](const SpeakerPos pos){return pos.mChannelID == chanid;});
|
||||
if(spkr == spkrs.cend())
|
||||
{
|
||||
fprintf(stderr, " ... failed to find channel ID %d\n", chanid);
|
||||
fmt::println(stderr, " ... failed to find channel ID {}", chanid);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -523,19 +562,21 @@ int main(al::span<std::string_view> args)
|
|||
sf_count_t wrote{sf_writef_float(outfile.get(), outmem.data(),
|
||||
static_cast<sf_count_t>(got))};
|
||||
if(wrote < 0)
|
||||
fprintf(stderr, " ... failed to write samples: %d\n", sf_error(outfile.get()));
|
||||
fmt::println(stderr, " ... failed to write samples: {}", sf_error(outfile.get()));
|
||||
else
|
||||
total_wrote += static_cast<size_t>(wrote);
|
||||
}
|
||||
printf(" ... wrote %zu samples (%" PRId64 ").\n", total_wrote, int64_t{ininfo.frames});
|
||||
fmt::println(" ... wrote {} samples ({}).", total_wrote, ininfo.frames);
|
||||
++num_encoded;
|
||||
}
|
||||
};
|
||||
std::for_each(args.begin(), args.end(), process_arg);
|
||||
|
||||
if(num_encoded == 0)
|
||||
fprintf(stderr, "Failed to encode any input files\n");
|
||||
fmt::println(stderr, "Failed to encode any input files");
|
||||
else if(num_encoded < num_files)
|
||||
fprintf(stderr, "Encoded %zu of %zu files\n", num_encoded, num_files);
|
||||
fmt::println(stderr, "Encoded {} of {} files", num_encoded, num_files);
|
||||
else
|
||||
printf("Encoded %s%zu file%s\n", (num_encoded > 1) ? "all " : "", num_encoded,
|
||||
fmt::println("Encoded {}{} file{}", (num_encoded > 1) ? "all " : "", num_encoded,
|
||||
(num_encoded == 1) ? "" : "s");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue