mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +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
File diff suppressed because it is too large
Load diff
|
|
@ -32,7 +32,6 @@
|
|||
#include <future>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
|
@ -40,8 +39,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include "alspan.h"
|
||||
#include "alstring.h"
|
||||
#include "alnumeric.h"
|
||||
#include "fmt/core.h"
|
||||
#include "makemhr.h"
|
||||
#include "polyphase_resampler.h"
|
||||
#include "sofa-support.h"
|
||||
|
|
@ -62,12 +61,12 @@ using uint = unsigned int;
|
|||
*/
|
||||
auto PrepareLayout(const al::span<const float> xyzs, HrirDataT *hData) -> bool
|
||||
{
|
||||
fprintf(stdout, "Detecting compatible layout...\n");
|
||||
fmt::println("Detecting compatible layout...");
|
||||
|
||||
auto fds = GetCompatibleLayout(xyzs);
|
||||
if(fds.size() > MAX_FD_COUNT)
|
||||
{
|
||||
fprintf(stdout, "Incompatible layout (inumerable radii).\n");
|
||||
fmt::println("Incompatible layout (inumerable radii).");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +91,7 @@ auto PrepareLayout(const al::span<const float> xyzs, HrirDataT *hData) -> bool
|
|||
|
||||
++fi;
|
||||
}
|
||||
fprintf(stdout, "Using %u of %zu IRs.\n", ir_total, xyzs.size()/3);
|
||||
fmt::println("Using {} of {} IRs.", ir_total, xyzs.size()/3);
|
||||
const auto azs = al::span{azCounts}.first<MAX_FD_COUNT>();
|
||||
return PrepareHrirData(al::span{distances}.first(fi), evCounts, azs, hData);
|
||||
}
|
||||
|
|
@ -109,7 +108,7 @@ float GetSampleRate(MYSOFA_HRTF *sofaHrtf)
|
|||
{
|
||||
if(srate_dim)
|
||||
{
|
||||
fprintf(stderr, "Duplicate SampleRate.DIMENSION_LIST\n");
|
||||
fmt::println(stderr, "Duplicate SampleRate.DIMENSION_LIST");
|
||||
return 0.0f;
|
||||
}
|
||||
srate_dim = srate_attrs->value;
|
||||
|
|
@ -118,42 +117,42 @@ float GetSampleRate(MYSOFA_HRTF *sofaHrtf)
|
|||
{
|
||||
if(srate_units)
|
||||
{
|
||||
fprintf(stderr, "Duplicate SampleRate.Units\n");
|
||||
fmt::println(stderr, "Duplicate SampleRate.Units");
|
||||
return 0.0f;
|
||||
}
|
||||
srate_units = srate_attrs->value;
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Unexpected sample rate attribute: %s = %s\n", srate_attrs->name,
|
||||
fmt::println(stderr, "Unexpected sample rate attribute: {} = {}", srate_attrs->name,
|
||||
srate_attrs->value);
|
||||
srate_attrs = srate_attrs->next;
|
||||
}
|
||||
if(!srate_dim)
|
||||
{
|
||||
fprintf(stderr, "Missing sample rate dimensions\n");
|
||||
fmt::println(stderr, "Missing sample rate dimensions");
|
||||
return 0.0f;
|
||||
}
|
||||
if(srate_dim != "I"sv)
|
||||
{
|
||||
fprintf(stderr, "Unsupported sample rate dimensions: %s\n", srate_dim);
|
||||
fmt::println(stderr, "Unsupported sample rate dimensions: {}", srate_dim);
|
||||
return 0.0f;
|
||||
}
|
||||
if(!srate_units)
|
||||
{
|
||||
fprintf(stderr, "Missing sample rate unit type\n");
|
||||
fmt::println(stderr, "Missing sample rate unit type");
|
||||
return 0.0f;
|
||||
}
|
||||
if(srate_units != "hertz"sv)
|
||||
{
|
||||
fprintf(stderr, "Unsupported sample rate unit type: %s\n", srate_units);
|
||||
fmt::println(stderr, "Unsupported sample rate unit type: {}", srate_units);
|
||||
return 0.0f;
|
||||
}
|
||||
/* I dimensions guarantees 1 element, so just extract it. */
|
||||
const auto values = al::span{srate_array->values, sofaHrtf->I};
|
||||
if(values[0] < float{MIN_RATE} || values[0] > float{MAX_RATE})
|
||||
{
|
||||
fprintf(stderr, "Sample rate out of range: %f (expected %u to %u)", values[0], MIN_RATE,
|
||||
MAX_RATE);
|
||||
fmt::println(stderr, "Sample rate out of range: {:f} (expected {} to {})", values[0],
|
||||
MIN_RATE, MAX_RATE);
|
||||
return 0.0f;
|
||||
}
|
||||
return values[0];
|
||||
|
|
@ -175,19 +174,19 @@ auto PrepareDelay(MYSOFA_HRTF *sofaHrtf) -> std::optional<DelayType>
|
|||
{
|
||||
if(delay_dim)
|
||||
{
|
||||
fprintf(stderr, "Duplicate Delay.DIMENSION_LIST\n");
|
||||
fmt::println(stderr, "Duplicate Delay.DIMENSION_LIST");
|
||||
return std::nullopt;
|
||||
}
|
||||
delay_dim = delay_attrs->value;
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Unexpected delay attribute: %s = %s\n", delay_attrs->name,
|
||||
fmt::println(stderr, "Unexpected delay attribute: {} = {}", delay_attrs->name,
|
||||
delay_attrs->value ? delay_attrs->value : "<null>");
|
||||
delay_attrs = delay_attrs->next;
|
||||
}
|
||||
if(!delay_dim)
|
||||
{
|
||||
fprintf(stderr, "Missing delay dimensions\n");
|
||||
fmt::println(stderr, "Missing delay dimensions");
|
||||
return DelayType::None;
|
||||
}
|
||||
if(delay_dim == "I,R"sv)
|
||||
|
|
@ -195,7 +194,7 @@ auto PrepareDelay(MYSOFA_HRTF *sofaHrtf) -> std::optional<DelayType>
|
|||
if(delay_dim == "M,R"sv)
|
||||
return DelayType::M_R;
|
||||
|
||||
fprintf(stderr, "Unsupported delay dimensions: %s\n", delay_dim);
|
||||
fmt::println(stderr, "Unsupported delay dimensions: {}", delay_dim);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
|
@ -210,24 +209,24 @@ bool CheckIrData(MYSOFA_HRTF *sofaHrtf)
|
|||
{
|
||||
if(ir_dim)
|
||||
{
|
||||
fprintf(stderr, "Duplicate IR.DIMENSION_LIST\n");
|
||||
fmt::println(stderr, "Duplicate IR.DIMENSION_LIST");
|
||||
return false;
|
||||
}
|
||||
ir_dim = ir_attrs->value;
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Unexpected IR attribute: %s = %s\n", ir_attrs->name,
|
||||
fmt::println(stderr, "Unexpected IR attribute: {} = {}", ir_attrs->name,
|
||||
ir_attrs->value ? ir_attrs->value : "<null>");
|
||||
ir_attrs = ir_attrs->next;
|
||||
}
|
||||
if(!ir_dim)
|
||||
{
|
||||
fprintf(stderr, "Missing IR dimensions\n");
|
||||
fmt::println(stderr, "Missing IR dimensions");
|
||||
return false;
|
||||
}
|
||||
if(ir_dim != "M,R,N"sv)
|
||||
{
|
||||
fprintf(stderr, "Unsupported IR dimensions: %s\n", ir_dim);
|
||||
fmt::println(stderr, "Unsupported IR dimensions: {}", ir_dim);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -315,7 +314,7 @@ bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayType dela
|
|||
HrirAzT &azd = field->mEvs[ei].mAzs[ai];
|
||||
if(!azd.mIrs[0].empty())
|
||||
{
|
||||
fprintf(stderr, "\nMultiple measurements near [ a=%f, e=%f, r=%f ].\n",
|
||||
fmt::println(stderr, "\nMultiple measurements near [ a={:f}, e={:f}, r={:f} ].",
|
||||
aer[0], aer[1], aer[2]);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -367,10 +366,10 @@ bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayType dela
|
|||
auto load_future = std::async(std::launch::async, load_proc);
|
||||
do {
|
||||
load_status = load_future.wait_for(std::chrono::milliseconds{50});
|
||||
printf("\rLoading HRIRs... %u of %u", loaded_count.load(), sofaHrtf->M);
|
||||
fmt::print("\rLoading HRIRs... {} of {}", loaded_count.load(), sofaHrtf->M);
|
||||
fflush(stdout);
|
||||
} while(load_status != std::future_status::ready);
|
||||
fputc('\n', stdout);
|
||||
fmt::println("");
|
||||
return load_future.get();
|
||||
}
|
||||
|
||||
|
|
@ -382,10 +381,13 @@ bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayType dela
|
|||
struct MagCalculator {
|
||||
const uint mFftSize{};
|
||||
const uint mIrPoints{};
|
||||
std::vector<al::span<double>> mIrs{};
|
||||
std::vector<al::span<double>> mIrs;
|
||||
std::atomic<size_t> mCurrent{};
|
||||
std::atomic<size_t> mDone{};
|
||||
|
||||
MagCalculator(const uint fftsize, const uint irpoints) : mFftSize{fftsize}, mIrPoints{irpoints}
|
||||
{ }
|
||||
|
||||
void Worker()
|
||||
{
|
||||
auto htemp = std::vector<complex_d>(mFftSize);
|
||||
|
|
@ -422,28 +424,27 @@ bool LoadSofaFile(const std::string_view filename, const uint numThreads, const
|
|||
MySofaHrtfPtr sofaHrtf{mysofa_load(std::string{filename}.c_str(), &err)};
|
||||
if(!sofaHrtf)
|
||||
{
|
||||
fprintf(stdout, "Error: Could not load %.*s: %s\n", al::sizei(filename), filename.data(),
|
||||
SofaErrorStr(err));
|
||||
fmt::println("Error: Could not load {}: {} ({})", filename, SofaErrorStr(err), err);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* NOTE: Some valid SOFA files are failing this check. */
|
||||
err = mysofa_check(sofaHrtf.get());
|
||||
if(err != MYSOFA_OK)
|
||||
fprintf(stderr, "Warning: Supposedly malformed source file '%.*s' (%s).\n",
|
||||
al::sizei(filename), filename.data(), SofaErrorStr(err));
|
||||
fmt::println(stderr, "Warning: Supposedly malformed source file '{}': {} ({})", filename,
|
||||
SofaErrorStr(err), err);
|
||||
|
||||
mysofa_tocartesian(sofaHrtf.get());
|
||||
|
||||
/* Make sure emitter and receiver counts are sane. */
|
||||
if(sofaHrtf->E != 1)
|
||||
{
|
||||
fprintf(stderr, "%u emitters not supported\n", sofaHrtf->E);
|
||||
fmt::println(stderr, "{} emitters not supported", sofaHrtf->E);
|
||||
return false;
|
||||
}
|
||||
if(sofaHrtf->R > 2 || sofaHrtf->R < 1)
|
||||
{
|
||||
fprintf(stderr, "%u receivers not supported\n", sofaHrtf->R);
|
||||
fmt::println(stderr, "{} receivers not supported", sofaHrtf->R);
|
||||
return false;
|
||||
}
|
||||
/* Assume R=2 is a stereo measurement, and R=1 is mono left-ear-only. */
|
||||
|
|
@ -455,12 +456,14 @@ bool LoadSofaFile(const std::string_view filename, const uint numThreads, const
|
|||
/* Check and set the FFT and IR size. */
|
||||
if(sofaHrtf->N > fftSize)
|
||||
{
|
||||
fprintf(stderr, "Sample points exceeds the FFT size.\n");
|
||||
fmt::println(stderr, "Sample points exceeds the FFT size ({} > {}).", sofaHrtf->N,
|
||||
fftSize);
|
||||
return false;
|
||||
}
|
||||
if(sofaHrtf->N < truncSize)
|
||||
{
|
||||
fprintf(stderr, "Sample points is below the truncation size.\n");
|
||||
fmt::println(stderr, "Sample points is below the truncation size ({} < {}).", sofaHrtf->N,
|
||||
truncSize);
|
||||
return false;
|
||||
}
|
||||
hData->mIrPoints = sofaHrtf->N;
|
||||
|
|
@ -502,7 +505,7 @@ bool LoadSofaFile(const std::string_view filename, const uint numThreads, const
|
|||
}
|
||||
if(ei >= hData->mFds[fi].mEvs.size())
|
||||
{
|
||||
fprintf(stderr, "Missing source references [ %d, *, * ].\n", fi);
|
||||
fmt::println(stderr, "Missing source references [ {}, *, * ].", fi);
|
||||
return false;
|
||||
}
|
||||
hData->mFds[fi].mEvStart = ei;
|
||||
|
|
@ -513,7 +516,7 @@ bool LoadSofaFile(const std::string_view filename, const uint numThreads, const
|
|||
HrirAzT &azd = hData->mFds[fi].mEvs[ei].mAzs[ai];
|
||||
if(azd.mIrs[0].empty())
|
||||
{
|
||||
fprintf(stderr, "Missing source reference [ %d, %d, %d ].\n", fi, ei, ai);
|
||||
fmt::println(stderr, "Missing source reference [ {}, {}, {} ].", fi, ei, ai);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -572,10 +575,10 @@ bool LoadSofaFile(const std::string_view filename, const uint numThreads, const
|
|||
auto load_future = std::async(std::launch::async, onset_proc);
|
||||
do {
|
||||
load_status = load_future.wait_for(std::chrono::milliseconds{50});
|
||||
printf("\rCalculating HRIR onsets... %zu of %zu", hrir_done.load(), hrir_total);
|
||||
fmt::print("\rCalculating HRIR onsets... {} of {}", hrir_done.load(), hrir_total);
|
||||
fflush(stdout);
|
||||
} while(load_status != std::future_status::ready);
|
||||
fputc('\n', stdout);
|
||||
fmt::println("");
|
||||
if(!load_future.get())
|
||||
return false;
|
||||
|
||||
|
|
@ -595,16 +598,16 @@ bool LoadSofaFile(const std::string_view filename, const uint numThreads, const
|
|||
std::vector<std::thread> thrds;
|
||||
thrds.reserve(numThreads);
|
||||
for(size_t i{0};i < numThreads;++i)
|
||||
thrds.emplace_back(std::mem_fn(&MagCalculator::Worker), &calculator);
|
||||
thrds.emplace_back(&MagCalculator::Worker, &calculator);
|
||||
size_t count;
|
||||
do {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{50});
|
||||
count = calculator.mDone.load();
|
||||
|
||||
printf("\rCalculating HRIR magnitudes... %zu of %zu", count, calculator.mIrs.size());
|
||||
fmt::print("\rCalculating HRIR magnitudes... {} of {}", count, calculator.mIrs.size());
|
||||
fflush(stdout);
|
||||
} while(count != calculator.mIrs.size());
|
||||
fputc('\n', stdout);
|
||||
fmt::println("");
|
||||
|
||||
for(auto &thrd : thrds)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
|
|
@ -82,7 +81,6 @@
|
|||
#include <numeric>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "alcomplex.h"
|
||||
|
|
@ -90,6 +88,8 @@
|
|||
#include "alnumeric.h"
|
||||
#include "alspan.h"
|
||||
#include "alstring.h"
|
||||
#include "filesystem.h"
|
||||
#include "fmt/core.h"
|
||||
#include "loaddef.h"
|
||||
#include "loadsofa.h"
|
||||
|
||||
|
|
@ -283,8 +283,7 @@ auto WriteAscii(const std::string_view out, std::ostream &ostream, const std::st
|
|||
{
|
||||
if(!ostream.write(out.data(), std::streamsize(out.size())) || ostream.bad())
|
||||
{
|
||||
fprintf(stderr, "\nError: Bad write to file '%.*s'.\n", al::sizei(filename),
|
||||
filename.data());
|
||||
fmt::println(stderr, "\nError: Bad write to file '{}'.", filename);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
|
@ -301,8 +300,7 @@ auto WriteBin4(const uint bytes, const uint32_t in, std::ostream &ostream,
|
|||
|
||||
if(!ostream.write(out.data(), std::streamsize(bytes)) || ostream.bad())
|
||||
{
|
||||
fprintf(stderr, "\nError: Bad write to file '%.*s'.\n", al::sizei(filename),
|
||||
filename.data());
|
||||
fmt::println(stderr, "\nError: Bad write to file '{}'.", filename);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
|
@ -315,11 +313,10 @@ auto StoreMhr(const HrirDataT *hData, const std::string_view filename) -> bool
|
|||
const uint n{hData->mIrPoints};
|
||||
uint dither_seed{22222};
|
||||
|
||||
std::ofstream ostream{std::filesystem::u8path(filename)};
|
||||
auto ostream = fs::ofstream{fs::u8path(filename), std::ios::binary};
|
||||
if(!ostream.is_open())
|
||||
{
|
||||
fprintf(stderr, "\nError: Could not open MHR file '%.*s'.\n", al::sizei(filename),
|
||||
filename.data());
|
||||
fmt::println(stderr, "\nError: Could not open MHR file '{}'.", filename);
|
||||
return false;
|
||||
}
|
||||
if(!WriteAscii(GetMHRMarker(), ostream, filename))
|
||||
|
|
@ -913,7 +910,7 @@ void ReconstructHrirs(const HrirDataT *hData, const uint numThreads)
|
|||
std::vector<std::thread> thrds;
|
||||
thrds.reserve(numThreads);
|
||||
for(size_t i{0};i < numThreads;++i)
|
||||
thrds.emplace_back(std::mem_fn(&HrirReconstructor::Worker), &reconstructor);
|
||||
thrds.emplace_back(&HrirReconstructor::Worker, &reconstructor);
|
||||
|
||||
/* Keep track of the number of IRs done, periodically reporting it. */
|
||||
size_t count;
|
||||
|
|
@ -923,10 +920,10 @@ void ReconstructHrirs(const HrirDataT *hData, const uint numThreads)
|
|||
count = reconstructor.mDone.load();
|
||||
size_t pcdone{count * 100 / reconstructor.mIrs.size()};
|
||||
|
||||
printf("\r%3zu%% done (%zu of %zu)", pcdone, count, reconstructor.mIrs.size());
|
||||
fmt::print("\r{:3}% done ({} of {})", pcdone, count, reconstructor.mIrs.size());
|
||||
fflush(stdout);
|
||||
} while(count < reconstructor.mIrs.size());
|
||||
fputc('\n', stdout);
|
||||
fmt::println("");
|
||||
|
||||
for(auto &thrd : thrds)
|
||||
{
|
||||
|
|
@ -1076,7 +1073,7 @@ void CalculateHrtds(const HeadModelT model, const double radius, HrirDataT *hDat
|
|||
}
|
||||
if(maxHrtd > MaxHrtd)
|
||||
{
|
||||
fprintf(stdout, " Scaling for max delay of %f samples to %f\n...\n", maxHrtd, MaxHrtd);
|
||||
fmt::println(" Scaling for max delay of {:f} samples to {:f}\n...", maxHrtd, MaxHrtd);
|
||||
const double scale{MaxHrtd / maxHrtd};
|
||||
for(auto &field : hData->mFds)
|
||||
{
|
||||
|
|
@ -1158,22 +1155,20 @@ bool ProcessDefinition(std::string_view inName, const uint outRate, const Channe
|
|||
{
|
||||
HrirDataT hData;
|
||||
|
||||
fprintf(stdout, "Using %u thread%s.\n", numThreads, (numThreads==1)?"":"s");
|
||||
fmt::println("Using {} thread{}.", numThreads, (numThreads==1)?"":"s");
|
||||
if(inName.empty() || inName == "-"sv)
|
||||
{
|
||||
inName = "stdin"sv;
|
||||
fprintf(stdout, "Reading HRIR definition from %.*s...\n", al::sizei(inName),
|
||||
inName.data());
|
||||
fmt::println("Reading HRIR definition from {}...", inName);
|
||||
if(!LoadDefInput(std::cin, {}, inName, fftSize, truncSize, outRate, chanMode, &hData))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto input = std::make_unique<std::ifstream>(std::filesystem::u8path(inName));
|
||||
auto input = std::make_unique<fs::ifstream>(fs::u8path(inName));
|
||||
if(!input->is_open())
|
||||
{
|
||||
fprintf(stderr, "Error: Could not open input file '%.*s'\n", al::sizei(inName),
|
||||
inName.data());
|
||||
fmt::println(stderr, "Error: Could not open input file '{}'", inName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1181,8 +1176,7 @@ bool ProcessDefinition(std::string_view inName, const uint outRate, const Channe
|
|||
input->read(startbytes.data(), startbytes.size());
|
||||
if(input->gcount() != startbytes.size() || !input->good())
|
||||
{
|
||||
fprintf(stderr, "Error: Could not read input file '%.*s'\n", al::sizei(inName),
|
||||
inName.data());
|
||||
fmt::println(stderr, "Error: Could not read input file '{}'", inName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1190,15 +1184,13 @@ bool ProcessDefinition(std::string_view inName, const uint outRate, const Channe
|
|||
&& startbytes[3] == 'F')
|
||||
{
|
||||
input = nullptr;
|
||||
fprintf(stdout, "Reading HRTF data from %.*s...\n", al::sizei(inName),
|
||||
inName.data());
|
||||
fmt::println("Reading HRTF data from {}...", inName);
|
||||
if(!LoadSofaFile(inName, numThreads, fftSize, truncSize, outRate, chanMode, &hData))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stdout, "Reading HRIR definition from %.*s...\n", al::sizei(inName),
|
||||
inName.data());
|
||||
fmt::println("Reading HRIR definition from {}...", inName);
|
||||
if(!LoadDefInput(*input, startbytes, inName, fftSize, truncSize, outRate, chanMode,
|
||||
&hData))
|
||||
return false;
|
||||
|
|
@ -1213,69 +1205,69 @@ bool ProcessDefinition(std::string_view inName, const uint outRate, const Channe
|
|||
|
||||
if(hData.mFds.size() > 1)
|
||||
{
|
||||
fprintf(stdout, "Balancing field magnitudes...\n");
|
||||
fmt::println("Balancing field magnitudes...");
|
||||
BalanceFieldMagnitudes(&hData, c, m);
|
||||
}
|
||||
fprintf(stdout, "Calculating diffuse-field average...\n");
|
||||
fmt::println("Calculating diffuse-field average...");
|
||||
CalculateDiffuseFieldAverage(&hData, c, m, surface, limit, dfa);
|
||||
fprintf(stdout, "Performing diffuse-field equalization...\n");
|
||||
fmt::println("Performing diffuse-field equalization...");
|
||||
DiffuseFieldEqualize(c, m, dfa, &hData);
|
||||
}
|
||||
if(hData.mFds.size() > 1)
|
||||
{
|
||||
fprintf(stdout, "Sorting %zu fields...\n", hData.mFds.size());
|
||||
fmt::println("Sorting {} fields...", hData.mFds.size());
|
||||
std::sort(hData.mFds.begin(), hData.mFds.end(),
|
||||
[](const HrirFdT &lhs, const HrirFdT &rhs) noexcept
|
||||
{ return lhs.mDistance < rhs.mDistance; });
|
||||
if(farfield)
|
||||
{
|
||||
fprintf(stdout, "Clearing %zu near field%s...\n", hData.mFds.size()-1,
|
||||
fmt::println("Clearing {} near field{}...", hData.mFds.size()-1,
|
||||
(hData.mFds.size()-1 != 1) ? "s" : "");
|
||||
hData.mFds.erase(hData.mFds.cbegin(), hData.mFds.cend()-1);
|
||||
}
|
||||
}
|
||||
fprintf(stdout, "Synthesizing missing elevations...\n");
|
||||
fmt::println("Synthesizing missing elevations...");
|
||||
if(model == HM_Dataset)
|
||||
SynthesizeOnsets(&hData);
|
||||
SynthesizeHrirs(&hData);
|
||||
fprintf(stdout, "Performing minimum phase reconstruction...\n");
|
||||
fmt::println("Performing minimum phase reconstruction...");
|
||||
ReconstructHrirs(&hData, numThreads);
|
||||
fprintf(stdout, "Truncating minimum-phase HRIRs...\n");
|
||||
fmt::println("Truncating minimum-phase HRIRs...");
|
||||
hData.mIrPoints = truncSize;
|
||||
fprintf(stdout, "Normalizing final HRIRs...\n");
|
||||
fmt::println("Normalizing final HRIRs...");
|
||||
NormalizeHrirs(&hData);
|
||||
fprintf(stdout, "Calculating impulse delays...\n");
|
||||
fmt::println("Calculating impulse delays...");
|
||||
CalculateHrtds(model, (radius > DefaultCustomRadius) ? radius : hData.mRadius, &hData);
|
||||
|
||||
const auto rateStr = std::to_string(hData.mIrRate);
|
||||
const auto expName = StrSubst(outName, "%r"sv, rateStr);
|
||||
fprintf(stdout, "Creating MHR data set %s...\n", expName.c_str());
|
||||
fmt::println("Creating MHR data set {}...", expName);
|
||||
return StoreMhr(&hData, expName);
|
||||
}
|
||||
|
||||
void PrintHelp(const std::string_view argv0, FILE *ofile)
|
||||
{
|
||||
fprintf(ofile, "Usage: %.*s [<option>...]\n\n", al::sizei(argv0), argv0.data());
|
||||
fprintf(ofile, "Options:\n");
|
||||
fprintf(ofile, " -r <rate> Change the data set sample rate to the specified value and\n");
|
||||
fprintf(ofile, " resample the HRIRs accordingly.\n");
|
||||
fprintf(ofile, " -m Change the data set to mono, mirroring the left ear for the\n");
|
||||
fprintf(ofile, " right ear.\n");
|
||||
fprintf(ofile, " -a Change the data set to single field, using the farthest field.\n");
|
||||
fprintf(ofile, " -j <threads> Number of threads used to process HRIRs (default: 2).\n");
|
||||
fprintf(ofile, " -f <points> Override the FFT window size (default: %u).\n", DefaultFftSize);
|
||||
fprintf(ofile, " -e {on|off} Toggle diffuse-field equalization (default: %s).\n", (DefaultEqualize ? "on" : "off"));
|
||||
fprintf(ofile, " -s {on|off} Toggle surface-weighted diffuse-field average (default: %s).\n", (DefaultSurface ? "on" : "off"));
|
||||
fprintf(ofile, " -l {<dB>|none} Specify a limit to the magnitude range of the diffuse-field\n");
|
||||
fprintf(ofile, " average (default: %.2f).\n", DefaultLimit);
|
||||
fprintf(ofile, " -w <points> Specify the size of the truncation window that's applied\n");
|
||||
fprintf(ofile, " after minimum-phase reconstruction (default: %u).\n", DefaultTruncSize);
|
||||
fprintf(ofile, " -d {dataset| Specify the model used for calculating the head-delay timing\n");
|
||||
fprintf(ofile, " sphere} values (default: %s).\n", ((HM_Default == HM_Dataset) ? "dataset" : "sphere"));
|
||||
fprintf(ofile, " -c <radius> Use a customized head radius measured to-ear in meters.\n");
|
||||
fprintf(ofile, " -i <filename> Specify an HRIR definition file to use (defaults to stdin).\n");
|
||||
fprintf(ofile, " -o <filename> Specify an output file. Use of '%%r' will be substituted with\n");
|
||||
fprintf(ofile, " the data set sample rate.\n");
|
||||
fmt::println(ofile, "Usage: {} [<option>...]\n", argv0);
|
||||
fmt::println(ofile, "Options:");
|
||||
fmt::println(ofile, " -r <rate> Change the data set sample rate to the specified value and");
|
||||
fmt::println(ofile, " resample the HRIRs accordingly.");
|
||||
fmt::println(ofile, " -m Change the data set to mono, mirroring the left ear for the");
|
||||
fmt::println(ofile, " right ear.");
|
||||
fmt::println(ofile, " -a Change the data set to single field, using the farthest field.");
|
||||
fmt::println(ofile, " -j <threads> Number of threads used to process HRIRs (default: 2).");
|
||||
fmt::println(ofile, " -f <points> Override the FFT window size (default: {}).", DefaultFftSize);
|
||||
fmt::println(ofile, " -e {{on|off}} Toggle diffuse-field equalization (default: {}).", (DefaultEqualize ? "on" : "off"));
|
||||
fmt::println(ofile, " -s {{on|off}} Toggle surface-weighted diffuse-field average (default: {}).", (DefaultSurface ? "on" : "off"));
|
||||
fmt::println(ofile, " -l {{<dB>|none}} Specify a limit to the magnitude range of the diffuse-field");
|
||||
fmt::println(ofile, " average (default: {:.2f}).", DefaultLimit);
|
||||
fmt::println(ofile, " -w <points> Specify the size of the truncation window that's applied");
|
||||
fmt::println(ofile, " after minimum-phase reconstruction (default: {}).", DefaultTruncSize);
|
||||
fmt::println(ofile, " -d {{dataset| Specify the model used for calculating the head-delay timing");
|
||||
fmt::println(ofile, " sphere}} values (default: {}).", ((HM_Default == HM_Dataset) ? "dataset" : "sphere"));
|
||||
fmt::println(ofile, " -c <radius> Use a customized head radius measured to-ear in meters.");
|
||||
fmt::println(ofile, " -i <filename> Specify an HRIR definition file to use (defaults to stdin).");
|
||||
fmt::println(ofile, " -o <filename> Specify an output file. Use of '%r' will be substituted with");
|
||||
fmt::println(ofile, " the data set sample rate.");
|
||||
}
|
||||
|
||||
// Standard command line dispatch.
|
||||
|
|
@ -1283,7 +1275,7 @@ int main(al::span<std::string_view> args)
|
|||
{
|
||||
if(args.size() < 2)
|
||||
{
|
||||
fprintf(stdout, "HRTF Processing and Composition Utility\n\n");
|
||||
fmt::println("HRTF Processing and Composition Utility\n");
|
||||
PrintHelp(args[0], stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
@ -1325,7 +1317,7 @@ int main(al::span<std::string_view> args)
|
|||
|
||||
if(args[0][0] != '-' || args[0].size() == 1)
|
||||
{
|
||||
fprintf(stderr, "Invalid argument: %.*s\n", al::sizei(args[0]), args[0].data());
|
||||
fmt::println(stderr, "Invalid argument: {}", args[0]);
|
||||
return -1;
|
||||
}
|
||||
++argplace;
|
||||
|
|
@ -1335,13 +1327,13 @@ int main(al::span<std::string_view> args)
|
|||
const auto listidx = optlist.find(nextopt);
|
||||
if(listidx >= optlist.size())
|
||||
{
|
||||
fprintf(stderr, "Unknown argument: -%c\n", nextopt);
|
||||
fmt::println(stderr, "Unknown argument: -{:c}", nextopt);
|
||||
return -1;
|
||||
}
|
||||
const bool needsarg{listidx+1 < optlist.size() && optlist[listidx+1] == ':'};
|
||||
if(needsarg && (argplace+1 < args[0].size() || args.size() < 2))
|
||||
{
|
||||
fprintf(stderr, "Missing parameter for argument: -%c\n", nextopt);
|
||||
fmt::println(stderr, "Missing parameter for argument: -{:c}", nextopt);
|
||||
return -1;
|
||||
}
|
||||
if(++argplace == args[0].size())
|
||||
|
|
@ -1364,8 +1356,9 @@ int main(al::span<std::string_view> args)
|
|||
outRate = static_cast<uint>(std::stoul(std::string{optarg}, &endpos, 10));
|
||||
if(endpos != optarg.size() || outRate < MIN_RATE || outRate > MAX_RATE)
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected between %u to %u.\n",
|
||||
al::sizei(optarg), optarg.data(), opt, MIN_RATE, MAX_RATE);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected between {} to {}.",
|
||||
optarg, opt, MIN_RATE, MAX_RATE);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1382,8 +1375,9 @@ int main(al::span<std::string_view> args)
|
|||
numThreads = static_cast<uint>(std::stoul(std::string{optarg}, &endpos, 10));
|
||||
if(endpos != optarg.size() || numThreads > 64)
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected between %u to %u.\n",
|
||||
al::sizei(optarg), optarg.data(), opt, 0, 64);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected between {} to {}.",
|
||||
optarg, opt, 0, 64);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if(numThreads == 0)
|
||||
|
|
@ -1395,8 +1389,9 @@ int main(al::span<std::string_view> args)
|
|||
if(endpos != optarg.size() || (fftSize&(fftSize-1)) || fftSize < MinFftSize
|
||||
|| fftSize > MaxFftSize)
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected a power-of-two between %u to %u.\n",
|
||||
al::sizei(optarg), optarg.data(), opt, MinFftSize, MaxFftSize);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected a power-of-two between {} to {}.",
|
||||
optarg, opt, MinFftSize, MaxFftSize);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1408,8 +1403,9 @@ int main(al::span<std::string_view> args)
|
|||
equalize = false;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected on or off.\n",
|
||||
al::sizei(optarg), optarg.data(), opt);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected on or off.",
|
||||
optarg, opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1421,8 +1417,9 @@ int main(al::span<std::string_view> args)
|
|||
surface = false;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected on or off.\n",
|
||||
al::sizei(optarg), optarg.data(), opt);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected on or off.",
|
||||
optarg, opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1435,8 +1432,9 @@ int main(al::span<std::string_view> args)
|
|||
limit = std::stod(std::string{optarg}, &endpos);
|
||||
if(endpos != optarg.size() || limit < MinLimit || limit > MaxLimit)
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected between %.0f to %.0f.\n",
|
||||
al::sizei(optarg), optarg.data(), opt, MinLimit, MaxLimit);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected between {:.0f} to {:.0f}.",
|
||||
optarg, opt, MinLimit, MaxLimit);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1446,8 +1444,9 @@ int main(al::span<std::string_view> args)
|
|||
truncSize = static_cast<uint>(std::stoul(std::string{optarg}, &endpos, 10));
|
||||
if(endpos != optarg.size() || truncSize < MinTruncSize || truncSize > MaxTruncSize)
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected between %u to %u.\n",
|
||||
al::sizei(optarg), optarg.data(), opt, MinTruncSize, MaxTruncSize);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected between {} to {}.",
|
||||
optarg, opt, MinTruncSize, MaxTruncSize);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1459,8 +1458,9 @@ int main(al::span<std::string_view> args)
|
|||
model = HM_Sphere;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected dataset or sphere.\n",
|
||||
al::sizei(optarg), optarg.data(), opt);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected dataset or sphere.",
|
||||
optarg, opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1469,8 +1469,9 @@ int main(al::span<std::string_view> args)
|
|||
radius = std::stod(std::string{optarg}, &endpos);
|
||||
if(endpos != optarg.size() || radius < MinCustomRadius || radius > MaxCustomRadius)
|
||||
{
|
||||
fprintf(stderr, "\nError: Got unexpected value \"%.*s\" for option -%c, expected between %.2f to %.2f.\n",
|
||||
al::sizei(optarg), optarg.data(), opt, MinCustomRadius, MaxCustomRadius);
|
||||
fmt::println(stderr,
|
||||
"\nError: Got unexpected value \"{}\" for option -{:c}, expected between {:.2f} to {:.2f}.",
|
||||
optarg, opt, MinCustomRadius, MaxCustomRadius);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1496,7 +1497,7 @@ int main(al::span<std::string_view> args)
|
|||
const int ret{ProcessDefinition(inName, outRate, chanMode, farfield, numThreads, fftSize,
|
||||
equalize, surface, limit, truncSize, model, radius, outName)};
|
||||
if(!ret) return -1;
|
||||
fprintf(stdout, "Operation completed.\n");
|
||||
fmt::println("Operation completed.");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,43 +12,35 @@
|
|||
|
||||
|
||||
// The maximum path length used when processing filenames.
|
||||
enum { MAX_PATH_LEN = 256u };
|
||||
inline constexpr auto MAX_PATH_LEN = 256u;
|
||||
|
||||
// The limit to the number of 'distances' listed in the data set definition.
|
||||
// Must be less than 256
|
||||
enum { MAX_FD_COUNT = 16u };
|
||||
inline constexpr auto MAX_FD_COUNT = 16u;
|
||||
|
||||
// The limits to the number of 'elevations' listed in the data set definition.
|
||||
// Must be less than 256.
|
||||
enum {
|
||||
MIN_EV_COUNT = 5u,
|
||||
MAX_EV_COUNT = 181u
|
||||
};
|
||||
inline constexpr auto MIN_EV_COUNT = 5u;
|
||||
inline constexpr auto MAX_EV_COUNT = 181u;
|
||||
|
||||
// The limits for each of the 'azimuths' listed in the data set definition.
|
||||
// Must be less than 256.
|
||||
enum {
|
||||
MIN_AZ_COUNT = 1u,
|
||||
MAX_AZ_COUNT = 255u
|
||||
};
|
||||
inline constexpr auto MIN_AZ_COUNT = 1u;
|
||||
inline constexpr auto MAX_AZ_COUNT = 255u;
|
||||
|
||||
// The limits for the 'distance' from source to listener for each field in
|
||||
// the definition file.
|
||||
inline constexpr double MIN_DISTANCE{0.05};
|
||||
inline constexpr double MAX_DISTANCE{2.50};
|
||||
inline constexpr auto MIN_DISTANCE = 0.05;
|
||||
inline constexpr auto MAX_DISTANCE = 2.50;
|
||||
|
||||
// The limits for the sample 'rate' metric in the data set definition and for
|
||||
// resampling.
|
||||
enum {
|
||||
MIN_RATE = 32000u,
|
||||
MAX_RATE = 96000u
|
||||
};
|
||||
inline constexpr auto MIN_RATE = 32000u;
|
||||
inline constexpr auto MAX_RATE = 96000u;
|
||||
|
||||
// The limits for the HRIR 'points' metric in the data set definition.
|
||||
enum {
|
||||
MIN_POINTS = 16u,
|
||||
MAX_POINTS = 8192u
|
||||
};
|
||||
inline constexpr auto MIN_POINTS = 16u;
|
||||
inline constexpr auto MAX_POINTS = 8192u;
|
||||
|
||||
|
||||
using uint = unsigned int;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue