mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-24 05:45:40 +00:00
update openal
This commit is contained in:
parent
62f3b93ff9
commit
6721a6b021
287 changed files with 33851 additions and 27325 deletions
|
|
@ -33,12 +33,15 @@
|
|||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "aloptional.h"
|
||||
#include "alspan.h"
|
||||
#include "alstring.h"
|
||||
#include "alnumeric.h"
|
||||
#include "makemhr.h"
|
||||
#include "polyphase_resampler.h"
|
||||
#include "sofa-support.h"
|
||||
|
|
@ -46,6 +49,9 @@
|
|||
#include "mysofa.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
using uint = unsigned int;
|
||||
|
||||
/* Attempts to produce a compatible layout. Most data sets tend to be
|
||||
|
|
@ -54,19 +60,19 @@ using uint = unsigned int;
|
|||
* possible. Those sets that contain purely random measurements or use
|
||||
* different major axes will fail.
|
||||
*/
|
||||
static bool PrepareLayout(const uint m, const float *xyzs, HrirDataT *hData)
|
||||
auto PrepareLayout(const al::span<const float> xyzs, HrirDataT *hData) -> bool
|
||||
{
|
||||
fprintf(stdout, "Detecting compatible layout...\n");
|
||||
|
||||
auto fds = GetCompatibleLayout(m, xyzs);
|
||||
auto fds = GetCompatibleLayout(xyzs);
|
||||
if(fds.size() > MAX_FD_COUNT)
|
||||
{
|
||||
fprintf(stdout, "Incompatible layout (inumerable radii).\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
double distances[MAX_FD_COUNT]{};
|
||||
uint evCounts[MAX_FD_COUNT]{};
|
||||
std::array<double,MAX_FD_COUNT> distances{};
|
||||
std::array<uint,MAX_FD_COUNT> evCounts{};
|
||||
auto azCounts = std::vector<std::array<uint,MAX_EV_COUNT>>(MAX_FD_COUNT);
|
||||
for(auto &azs : azCounts) azs.fill(0u);
|
||||
|
||||
|
|
@ -86,12 +92,11 @@ static bool PrepareLayout(const uint m, const float *xyzs, HrirDataT *hData)
|
|||
|
||||
++fi;
|
||||
}
|
||||
fprintf(stdout, "Using %u of %u IRs.\n", ir_total, m);
|
||||
const auto azs = al::as_span(azCounts).first<MAX_FD_COUNT>();
|
||||
return PrepareHrirData({distances, fi}, evCounts, azs, hData);
|
||||
fprintf(stdout, "Using %u of %zu IRs.\n", 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);
|
||||
}
|
||||
|
||||
|
||||
float GetSampleRate(MYSOFA_HRTF *sofaHrtf)
|
||||
{
|
||||
const char *srate_dim{nullptr};
|
||||
|
|
@ -100,7 +105,7 @@ float GetSampleRate(MYSOFA_HRTF *sofaHrtf)
|
|||
MYSOFA_ATTRIBUTE *srate_attrs{srate_array->attributes};
|
||||
while(srate_attrs)
|
||||
{
|
||||
if(std::string{"DIMENSION_LIST"} == srate_attrs->name)
|
||||
if("DIMENSION_LIST"sv == srate_attrs->name)
|
||||
{
|
||||
if(srate_dim)
|
||||
{
|
||||
|
|
@ -109,7 +114,7 @@ float GetSampleRate(MYSOFA_HRTF *sofaHrtf)
|
|||
}
|
||||
srate_dim = srate_attrs->value;
|
||||
}
|
||||
else if(std::string{"Units"} == srate_attrs->name)
|
||||
else if("Units"sv == srate_attrs->name)
|
||||
{
|
||||
if(srate_units)
|
||||
{
|
||||
|
|
@ -128,7 +133,7 @@ float GetSampleRate(MYSOFA_HRTF *sofaHrtf)
|
|||
fprintf(stderr, "Missing sample rate dimensions\n");
|
||||
return 0.0f;
|
||||
}
|
||||
if(srate_dim != std::string{"I"})
|
||||
if(srate_dim != "I"sv)
|
||||
{
|
||||
fprintf(stderr, "Unsupported sample rate dimensions: %s\n", srate_dim);
|
||||
return 0.0f;
|
||||
|
|
@ -138,40 +143,40 @@ float GetSampleRate(MYSOFA_HRTF *sofaHrtf)
|
|||
fprintf(stderr, "Missing sample rate unit type\n");
|
||||
return 0.0f;
|
||||
}
|
||||
if(srate_units != std::string{"hertz"})
|
||||
if(srate_units != "hertz"sv)
|
||||
{
|
||||
fprintf(stderr, "Unsupported sample rate unit type: %s\n", srate_units);
|
||||
return 0.0f;
|
||||
}
|
||||
/* I dimensions guarantees 1 element, so just extract it. */
|
||||
if(srate_array->values[0] < MIN_RATE || srate_array->values[0] > MAX_RATE)
|
||||
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)", srate_array->values[0],
|
||||
MIN_RATE, MAX_RATE);
|
||||
fprintf(stderr, "Sample rate out of range: %f (expected %u to %u)", values[0], MIN_RATE,
|
||||
MAX_RATE);
|
||||
return 0.0f;
|
||||
}
|
||||
return srate_array->values[0];
|
||||
return values[0];
|
||||
}
|
||||
|
||||
enum class DelayType : uint8_t {
|
||||
None,
|
||||
I_R, /* [1][Channels] */
|
||||
M_R, /* [HRIRs][Channels] */
|
||||
Invalid,
|
||||
};
|
||||
DelayType PrepareDelay(MYSOFA_HRTF *sofaHrtf)
|
||||
auto PrepareDelay(MYSOFA_HRTF *sofaHrtf) -> std::optional<DelayType>
|
||||
{
|
||||
const char *delay_dim{nullptr};
|
||||
MYSOFA_ARRAY *delay_array{&sofaHrtf->DataDelay};
|
||||
MYSOFA_ATTRIBUTE *delay_attrs{delay_array->attributes};
|
||||
while(delay_attrs)
|
||||
{
|
||||
if(std::string{"DIMENSION_LIST"} == delay_attrs->name)
|
||||
if("DIMENSION_LIST"sv == delay_attrs->name)
|
||||
{
|
||||
if(delay_dim)
|
||||
{
|
||||
fprintf(stderr, "Duplicate Delay.DIMENSION_LIST\n");
|
||||
return DelayType::Invalid;
|
||||
return std::nullopt;
|
||||
}
|
||||
delay_dim = delay_attrs->value;
|
||||
}
|
||||
|
|
@ -185,13 +190,13 @@ DelayType PrepareDelay(MYSOFA_HRTF *sofaHrtf)
|
|||
fprintf(stderr, "Missing delay dimensions\n");
|
||||
return DelayType::None;
|
||||
}
|
||||
if(delay_dim == std::string{"I,R"})
|
||||
if(delay_dim == "I,R"sv)
|
||||
return DelayType::I_R;
|
||||
else if(delay_dim == std::string{"M,R"})
|
||||
if(delay_dim == "M,R"sv)
|
||||
return DelayType::M_R;
|
||||
|
||||
fprintf(stderr, "Unsupported delay dimensions: %s\n", delay_dim);
|
||||
return DelayType::Invalid;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool CheckIrData(MYSOFA_HRTF *sofaHrtf)
|
||||
|
|
@ -201,7 +206,7 @@ bool CheckIrData(MYSOFA_HRTF *sofaHrtf)
|
|||
MYSOFA_ATTRIBUTE *ir_attrs{ir_array->attributes};
|
||||
while(ir_attrs)
|
||||
{
|
||||
if(std::string{"DIMENSION_LIST"} == ir_attrs->name)
|
||||
if("DIMENSION_LIST"sv == ir_attrs->name)
|
||||
{
|
||||
if(ir_dim)
|
||||
{
|
||||
|
|
@ -220,7 +225,7 @@ bool CheckIrData(MYSOFA_HRTF *sofaHrtf)
|
|||
fprintf(stderr, "Missing IR dimensions\n");
|
||||
return false;
|
||||
}
|
||||
if(ir_dim != std::string{"M,R,N"})
|
||||
if(ir_dim != "M,R,N"sv)
|
||||
{
|
||||
fprintf(stderr, "Unsupported IR dimensions: %s\n", ir_dim);
|
||||
return false;
|
||||
|
|
@ -230,13 +235,13 @@ bool CheckIrData(MYSOFA_HRTF *sofaHrtf)
|
|||
|
||||
|
||||
/* Calculate the onset time of a HRIR. */
|
||||
static constexpr int OnsetRateMultiple{10};
|
||||
static double CalcHrirOnset(PPhaseResampler &rs, const uint rate, const uint n,
|
||||
al::span<double> upsampled, const double *hrir)
|
||||
constexpr int OnsetRateMultiple{10};
|
||||
auto CalcHrirOnset(PPhaseResampler &rs, const uint rate, al::span<double> upsampled,
|
||||
const al::span<const double> hrir) -> double
|
||||
{
|
||||
rs.process(n, hrir, static_cast<uint>(upsampled.size()), upsampled.data());
|
||||
rs.process(hrir, upsampled);
|
||||
|
||||
auto abs_lt = [](const double &lhs, const double &rhs) -> bool
|
||||
auto abs_lt = [](const double lhs, const double rhs) -> bool
|
||||
{ return std::abs(lhs) < std::abs(rhs); };
|
||||
auto iter = std::max_element(upsampled.cbegin(), upsampled.cend(), abs_lt);
|
||||
return static_cast<double>(std::distance(upsampled.cbegin(), iter)) /
|
||||
|
|
@ -244,16 +249,16 @@ static double CalcHrirOnset(PPhaseResampler &rs, const uint rate, const uint n,
|
|||
}
|
||||
|
||||
/* Calculate the magnitude response of a HRIR. */
|
||||
static void CalcHrirMagnitude(const uint points, const uint n, al::span<complex_d> h, double *hrir)
|
||||
void CalcHrirMagnitude(const uint points, al::span<complex_d> h, const al::span<double> hrir)
|
||||
{
|
||||
auto iter = std::copy_n(hrir, points, h.begin());
|
||||
auto iter = std::copy_n(hrir.cbegin(), points, h.begin());
|
||||
std::fill(iter, h.end(), complex_d{0.0, 0.0});
|
||||
|
||||
FftForward(n, h.data());
|
||||
MagnitudeResponse(n, h.data(), hrir);
|
||||
forward_fft(h);
|
||||
MagnitudeResponse(h, hrir.first((h.size()/2) + 1));
|
||||
}
|
||||
|
||||
static bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayType delayType,
|
||||
bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayType delayType,
|
||||
const uint outRate)
|
||||
{
|
||||
std::atomic<uint> loaded_count{0u};
|
||||
|
|
@ -261,27 +266,27 @@ static bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayTy
|
|||
auto load_proc = [sofaHrtf,hData,delayType,outRate,&loaded_count]() -> bool
|
||||
{
|
||||
const uint channels{(hData->mChannelType == CT_STEREO) ? 2u : 1u};
|
||||
hData->mHrirsBase.resize(channels * hData->mIrCount * hData->mIrSize, 0.0);
|
||||
double *hrirs = hData->mHrirsBase.data();
|
||||
hData->mHrirsBase.resize(channels * size_t{hData->mIrCount} * hData->mIrSize, 0.0);
|
||||
const auto hrirs = al::span{hData->mHrirsBase};
|
||||
|
||||
std::unique_ptr<double[]> restmp;
|
||||
al::optional<PPhaseResampler> resampler;
|
||||
std::vector<double> restmp;
|
||||
std::optional<PPhaseResampler> resampler;
|
||||
if(outRate && outRate != hData->mIrRate)
|
||||
{
|
||||
resampler.emplace().init(hData->mIrRate, outRate);
|
||||
restmp = std::make_unique<double[]>(sofaHrtf->N);
|
||||
restmp.resize(sofaHrtf->N);
|
||||
}
|
||||
|
||||
const auto srcPosValues = al::span{sofaHrtf->SourcePosition.values, sofaHrtf->M*3_uz};
|
||||
const auto irValues = al::span{sofaHrtf->DataIR.values,
|
||||
size_t{sofaHrtf->M}*sofaHrtf->R*sofaHrtf->N};
|
||||
for(uint si{0u};si < sofaHrtf->M;++si)
|
||||
{
|
||||
loaded_count.fetch_add(1u);
|
||||
|
||||
float aer[3]{
|
||||
sofaHrtf->SourcePosition.values[3*si],
|
||||
sofaHrtf->SourcePosition.values[3*si + 1],
|
||||
sofaHrtf->SourcePosition.values[3*si + 2]
|
||||
};
|
||||
mysofa_c2s(aer);
|
||||
std::array aer{srcPosValues[3_uz*si], srcPosValues[3_uz*si + 1],
|
||||
srcPosValues[3_uz*si + 2]};
|
||||
mysofa_c2s(aer.data());
|
||||
|
||||
if(std::abs(aer[1]) >= 89.999f)
|
||||
aer[0] = 0.0f;
|
||||
|
|
@ -307,8 +312,8 @@ static bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayTy
|
|||
ai %= static_cast<uint>(field->mEvs[ei].mAzs.size());
|
||||
if(std::abs(af) >= 0.1) continue;
|
||||
|
||||
HrirAzT *azd = &field->mEvs[ei].mAzs[ai];
|
||||
if(azd->mIrs[0] != nullptr)
|
||||
HrirAzT &azd = field->mEvs[ei].mAzs[ai];
|
||||
if(!azd.mIrs[0].empty())
|
||||
{
|
||||
fprintf(stderr, "\nMultiple measurements near [ a=%f, e=%f, r=%f ].\n",
|
||||
aer[0], aer[1], aer[2]);
|
||||
|
|
@ -317,30 +322,33 @@ static bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayTy
|
|||
|
||||
for(uint ti{0u};ti < channels;++ti)
|
||||
{
|
||||
azd->mIrs[ti] = &hrirs[hData->mIrSize * (hData->mIrCount*ti + azd->mIndex)];
|
||||
azd.mIrs[ti] = hrirs.subspan(
|
||||
(size_t{hData->mIrCount}*ti + azd.mIndex) * hData->mIrSize, hData->mIrSize);
|
||||
const auto ir = irValues.subspan((size_t{si}*sofaHrtf->R + ti)*sofaHrtf->N,
|
||||
sofaHrtf->N);
|
||||
if(!resampler)
|
||||
std::copy_n(&sofaHrtf->DataIR.values[(si*sofaHrtf->R + ti)*sofaHrtf->N],
|
||||
sofaHrtf->N, azd->mIrs[ti]);
|
||||
std::copy_n(ir.cbegin(), ir.size(), azd.mIrs[ti].begin());
|
||||
else
|
||||
{
|
||||
std::copy_n(&sofaHrtf->DataIR.values[(si*sofaHrtf->R + ti)*sofaHrtf->N],
|
||||
sofaHrtf->N, restmp.get());
|
||||
resampler->process(sofaHrtf->N, restmp.get(), hData->mIrSize, azd->mIrs[ti]);
|
||||
std::copy_n(ir.cbegin(), ir.size(), restmp.begin());
|
||||
resampler->process(restmp, azd.mIrs[ti]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Include any per-channel or per-HRIR delays. */
|
||||
if(delayType == DelayType::I_R)
|
||||
{
|
||||
const float *delayValues{sofaHrtf->DataDelay.values};
|
||||
const auto delayValues = al::span{sofaHrtf->DataDelay.values,
|
||||
size_t{sofaHrtf->I}*sofaHrtf->R};
|
||||
for(uint ti{0u};ti < channels;++ti)
|
||||
azd->mDelays[ti] = delayValues[ti] / static_cast<float>(hData->mIrRate);
|
||||
azd.mDelays[ti] = delayValues[ti] / static_cast<float>(hData->mIrRate);
|
||||
}
|
||||
else if(delayType == DelayType::M_R)
|
||||
{
|
||||
const float *delayValues{sofaHrtf->DataDelay.values};
|
||||
const auto delayValues = al::span{sofaHrtf->DataDelay.values,
|
||||
size_t{sofaHrtf->M}*sofaHrtf->R};
|
||||
for(uint ti{0u};ti < channels;++ti)
|
||||
azd->mDelays[ti] = delayValues[si*sofaHrtf->R + ti] /
|
||||
azd.mDelays[ti] = delayValues[si*sofaHrtf->R + ti] /
|
||||
static_cast<float>(hData->mIrRate);
|
||||
}
|
||||
}
|
||||
|
|
@ -374,7 +382,7 @@ static bool LoadResponses(MYSOFA_HRTF *sofaHrtf, HrirDataT *hData, const DelayTy
|
|||
struct MagCalculator {
|
||||
const uint mFftSize{};
|
||||
const uint mIrPoints{};
|
||||
std::vector<double*> mIrs{};
|
||||
std::vector<al::span<double>> mIrs{};
|
||||
std::atomic<size_t> mCurrent{};
|
||||
std::atomic<size_t> mDone{};
|
||||
|
||||
|
|
@ -382,7 +390,7 @@ struct MagCalculator {
|
|||
{
|
||||
auto htemp = std::vector<complex_d>(mFftSize);
|
||||
|
||||
while(1)
|
||||
while(true)
|
||||
{
|
||||
/* Load the current index to process. */
|
||||
size_t idx{mCurrent.load()};
|
||||
|
|
@ -397,7 +405,7 @@ struct MagCalculator {
|
|||
*/
|
||||
} while(!mCurrent.compare_exchange_weak(idx, idx+1, std::memory_order_relaxed));
|
||||
|
||||
CalcHrirMagnitude(mIrPoints, mFftSize, htemp, mIrs[idx]);
|
||||
CalcHrirMagnitude(mIrPoints, htemp, mIrs[idx]);
|
||||
|
||||
/* Increment the number of IRs done. */
|
||||
mDone.fetch_add(1);
|
||||
|
|
@ -405,22 +413,25 @@ struct MagCalculator {
|
|||
}
|
||||
};
|
||||
|
||||
bool LoadSofaFile(const char *filename, const uint numThreads, const uint fftSize,
|
||||
} // namespace
|
||||
|
||||
bool LoadSofaFile(const std::string_view filename, const uint numThreads, const uint fftSize,
|
||||
const uint truncSize, const uint outRate, const ChannelModeT chanMode, HrirDataT *hData)
|
||||
{
|
||||
int err;
|
||||
MySofaHrtfPtr sofaHrtf{mysofa_load(filename, &err)};
|
||||
MySofaHrtfPtr sofaHrtf{mysofa_load(std::string{filename}.c_str(), &err)};
|
||||
if(!sofaHrtf)
|
||||
{
|
||||
fprintf(stdout, "Error: Could not load %s: %s\n", filename, SofaErrorStr(err));
|
||||
fprintf(stdout, "Error: Could not load %.*s: %s\n", al::sizei(filename), filename.data(),
|
||||
SofaErrorStr(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", filename,
|
||||
SofaErrorStr(err));
|
||||
fprintf(stderr, "Warning: Supposedly malformed source file '%.*s' (%s).\n",
|
||||
al::sizei(filename), filename.data(), SofaErrorStr(err));
|
||||
|
||||
mysofa_tocartesian(sofaHrtf.get());
|
||||
|
||||
|
|
@ -459,19 +470,19 @@ bool LoadSofaFile(const char *filename, const uint numThreads, const uint fftSiz
|
|||
/* Assume a default head radius of 9cm. */
|
||||
hData->mRadius = 0.09;
|
||||
|
||||
hData->mIrRate = static_cast<uint>(GetSampleRate(sofaHrtf.get()) + 0.5f);
|
||||
hData->mIrRate = static_cast<uint>(std::lround(GetSampleRate(sofaHrtf.get())));
|
||||
if(!hData->mIrRate)
|
||||
return false;
|
||||
|
||||
DelayType delayType = PrepareDelay(sofaHrtf.get());
|
||||
if(delayType == DelayType::Invalid)
|
||||
const auto delayType = PrepareDelay(sofaHrtf.get());
|
||||
if(!delayType)
|
||||
return false;
|
||||
|
||||
if(!CheckIrData(sofaHrtf.get()))
|
||||
return false;
|
||||
if(!PrepareLayout(sofaHrtf->M, sofaHrtf->SourcePosition.values, hData))
|
||||
if(!PrepareLayout(al::span{sofaHrtf->SourcePosition.values, sofaHrtf->M*3_uz}, hData))
|
||||
return false;
|
||||
if(!LoadResponses(sofaHrtf.get(), hData, delayType, outRate))
|
||||
if(!LoadResponses(sofaHrtf.get(), hData, *delayType, outRate))
|
||||
return false;
|
||||
sofaHrtf = nullptr;
|
||||
|
||||
|
|
@ -484,7 +495,7 @@ bool LoadSofaFile(const char *filename, const uint numThreads, const uint fftSiz
|
|||
for(;ai < hData->mFds[fi].mEvs[ei].mAzs.size();ai++)
|
||||
{
|
||||
HrirAzT &azd = hData->mFds[fi].mEvs[ei].mAzs[ai];
|
||||
if(azd.mIrs[0] != nullptr) break;
|
||||
if(!azd.mIrs[0].empty()) break;
|
||||
}
|
||||
if(ai < hData->mFds[fi].mEvs[ei].mAzs.size())
|
||||
break;
|
||||
|
|
@ -500,7 +511,7 @@ bool LoadSofaFile(const char *filename, const uint numThreads, const uint fftSiz
|
|||
for(uint ai{0u};ai < hData->mFds[fi].mEvs[ei].mAzs.size();ai++)
|
||||
{
|
||||
HrirAzT &azd = hData->mFds[fi].mEvs[ei].mAzs[ai];
|
||||
if(azd.mIrs[0] == nullptr)
|
||||
if(azd.mIrs[0].empty())
|
||||
{
|
||||
fprintf(stderr, "Missing source reference [ %d, %d, %d ].\n", fi, ei, ai);
|
||||
return false;
|
||||
|
|
@ -512,7 +523,7 @@ bool LoadSofaFile(const char *filename, const uint numThreads, const uint fftSiz
|
|||
|
||||
size_t hrir_total{0};
|
||||
const uint channels{(hData->mChannelType == CT_STEREO) ? 2u : 1u};
|
||||
double *hrirs = hData->mHrirsBase.data();
|
||||
const auto hrirs = al::span{hData->mHrirsBase};
|
||||
for(uint fi{0u};fi < hData->mFds.size();fi++)
|
||||
{
|
||||
for(uint ei{0u};ei < hData->mFds[fi].mEvStart;ei++)
|
||||
|
|
@ -520,8 +531,9 @@ bool LoadSofaFile(const char *filename, const uint numThreads, const uint fftSiz
|
|||
for(uint ai{0u};ai < hData->mFds[fi].mEvs[ei].mAzs.size();ai++)
|
||||
{
|
||||
HrirAzT &azd = hData->mFds[fi].mEvs[ei].mAzs[ai];
|
||||
for(uint ti{0u};ti < channels;ti++)
|
||||
azd.mIrs[ti] = &hrirs[hData->mIrSize * (hData->mIrCount*ti + azd.mIndex)];
|
||||
for(size_t ti{0u};ti < channels;ti++)
|
||||
azd.mIrs[ti] = hrirs.subspan((hData->mIrCount*ti + azd.mIndex)*hData->mIrSize,
|
||||
hData->mIrSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -533,7 +545,7 @@ bool LoadSofaFile(const char *filename, const uint numThreads, const uint fftSiz
|
|||
auto onset_proc = [hData,channels,&hrir_done]() -> bool
|
||||
{
|
||||
/* Temporary buffer used to calculate the IR's onset. */
|
||||
auto upsampled = std::vector<double>(OnsetRateMultiple * hData->mIrPoints);
|
||||
auto upsampled = std::vector<double>(size_t{OnsetRateMultiple} * hData->mIrPoints);
|
||||
/* This resampler is used to help detect the response onset. */
|
||||
PPhaseResampler rs;
|
||||
rs.init(hData->mIrRate, OnsetRateMultiple*hData->mIrRate);
|
||||
|
|
@ -547,8 +559,8 @@ bool LoadSofaFile(const char *filename, const uint numThreads, const uint fftSiz
|
|||
for(uint ti{0};ti < channels;ti++)
|
||||
{
|
||||
hrir_done.fetch_add(1u, std::memory_order_acq_rel);
|
||||
azd.mDelays[ti] += CalcHrirOnset(rs, hData->mIrRate, hData->mIrPoints,
|
||||
upsampled, azd.mIrs[ti]);
|
||||
azd.mDelays[ti] += CalcHrirOnset(rs, hData->mIrRate, upsampled,
|
||||
azd.mIrs[ti].first(hData->mIrPoints));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue