diff options
author | Chris Robinson <[email protected]> | 2023-01-11 01:49:24 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-01-11 01:49:24 -0800 |
commit | 155d27de3aaed9fcdcc8d72a934d81ce8542410b (patch) | |
tree | 0f8c1e85d8a5e92cc4d2c238bc51d7d771ee198d /utils | |
parent | 05d934ccd1a828773c3f33180bafad4220a33d4d (diff) |
Remove the FFT'd resampler from makemhr
Both SOFA and non-SOFA inputs use the polyphase resampler as needed when
loading the IRs.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/makemhr/makemhr.cpp | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/utils/makemhr/makemhr.cpp b/utils/makemhr/makemhr.cpp index b9d1b84a..e0911438 100644 --- a/utils/makemhr/makemhr.cpp +++ b/utils/makemhr/makemhr.cpp @@ -623,94 +623,6 @@ static void DiffuseFieldEqualize(const uint channels, const uint m, const double } } -// Resamples the HRIRs for use at the given sampling rate. -static void ResampleHrirs(const uint rate, HrirDataT *hData) -{ - struct Resampler { - const double scale; - const size_t m; - - /* Resampling from a lower rate to a higher rate. This likely only - * works properly when 1 <= scale <= 2. - */ - void upsample(double *resampled, const double *ir) const - { - std::fill_n(resampled, m, 0.0); - resampled[0] = ir[0]; - for(size_t in{1};in < m;++in) - { - const auto offset = static_cast<double>(in) / scale; - const auto out = static_cast<size_t>(offset); - - const double a{offset - static_cast<double>(out)}; - if(out == m-1) - resampled[out] += ir[in]*(1.0-a); - else - { - resampled[out ] += ir[in]*(1.0-a); - resampled[out+1] += ir[in]*a; - } - } - } - - /* Resampling from a higher rate to a lower rate. This likely only - * works properly when 0.5 <= scale <= 1.0. - */ - void downsample(double *resampled, const double *ir) const - { - resampled[0] = ir[0]; - for(size_t out{1};out < m;++out) - { - const auto offset = static_cast<double>(out) * scale; - const auto in = static_cast<size_t>(offset); - - const double a{offset - static_cast<double>(in)}; - if(in == m-1) - resampled[out] = ir[in]*(1.0-a); - else - resampled[out] = ir[in]*(1.0-a) + ir[in+1]*a; - } - } - }; - - while(rate > hData->mIrRate*2) - ResampleHrirs(hData->mIrRate*2, hData); - while(rate < (hData->mIrRate+1)/2) - ResampleHrirs((hData->mIrRate+1)/2, hData); - - const auto scale = static_cast<double>(rate) / hData->mIrRate; - const size_t m{hData->mFftSize/2u + 1u}; - auto resampled = std::vector<double>(m); - - const Resampler resampler{scale, m}; - auto do_resample = std::bind( - std::mem_fn((scale > 1.0) ? &Resampler::upsample : &Resampler::downsample), &resampler, - _1, _2); - - const uint channels{(hData->mChannelType == CT_STEREO) ? 2u : 1u}; - for(uint fi{0};fi < hData->mFdCount;++fi) - { - for(uint ei{hData->mFds[fi].mEvStart};ei < hData->mFds[fi].mEvCount;++ei) - { - for(uint ai{0};ai < hData->mFds[fi].mEvs[ei].mAzCount;++ai) - { - HrirAzT *azd = &hData->mFds[fi].mEvs[ei].mAzs[ai]; - for(uint ti{0};ti < channels;++ti) - { - do_resample(resampled.data(), azd->mIrs[ti]); - /* This should probably be rescaled according to the scale, - * however it'll all be normalized in the end so a constant - * scalar is fine to leave. - */ - std::transform(resampled.cbegin(), resampled.cend(), azd->mIrs[ti], - [](const double d) { return std::max(d, EPSILON); }); - } - } - } - } - hData->mIrRate = rate; -} - /* Given field and elevation indices and an azimuth, calculate the indices of * the two HRIRs that bound the coordinate along with a factor for * calculating the continuous HRIR using interpolation. @@ -1367,11 +1279,6 @@ static int ProcessDefinition(const char *inName, const uint outRate, const Chann hData.mFdCount = 1; } } - if(outRate != 0 && outRate != hData.mIrRate) - { - fprintf(stdout, "Resampling HRIRs...\n"); - ResampleHrirs(outRate, &hData); - } fprintf(stdout, "Synthesizing missing elevations...\n"); if(model == HM_DATASET) SynthesizeOnsets(&hData); |