aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-12-26 05:23:08 -0800
committerChris Robinson <[email protected]>2020-12-26 05:23:08 -0800
commit8a86ec8ac5cb9ae1f766bd33893bf2e6729b1025 (patch)
tree3b6a0463c5d9fb48e0bb87f4317d16102ae06b8b
parent5f233a2c24de58fde98e08ad8acb6cfe1803d716 (diff)
Add a crossover frequency field for the device
Used when upsampling low-order ambisonic signals to higher order. Rather than a hardcoded 400hz, it ensures a consistent crossover point when an ambdec configuration is used. It can also allow for an alsoft config option.
-rw-r--r--al/source.cpp2
-rw-r--r--alc/alc.cpp3
-rw-r--r--alc/alcmain.h1
-rw-r--r--alc/effects/convolution.cpp2
-rw-r--r--alc/effects/reverb.cpp2
-rw-r--r--alc/hrtf.cpp4
-rw-r--r--alc/hrtf.h2
-rw-r--r--alc/panning.cpp5
8 files changed, 13 insertions, 8 deletions
diff --git a/al/source.cpp b/al/source.cpp
index fa7665c4..cf536f2b 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -475,7 +475,7 @@ void InitVoice(Voice *voice, ALsource *source, BufferlistItem *BufferList, ALCco
AmbiIndex::OrderFromChannel.data()};
const auto scales = BFormatDec::GetHFOrderScales(voice->mAmbiOrder, device->mAmbiOrder);
- const BandSplitter splitter{400.0f / static_cast<float>(device->Frequency)};
+ const BandSplitter splitter{device->mXOverFreq / static_cast<float>(device->Frequency)};
for(auto &chandata : voice->mChans)
{
diff --git a/alc/alc.cpp b/alc/alc.cpp
index d42d055b..b833cb80 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2219,7 +2219,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
AmbiIndex::OrderFrom2DChannel.data() :
AmbiIndex::OrderFromChannel.data()};
- const BandSplitter splitter{400.0f / static_cast<float>(device->Frequency)};
+ const BandSplitter splitter{device->mXOverFreq /
+ static_cast<float>(device->Frequency)};
const auto scales = BFormatDec::GetHFOrderScales(voice->mAmbiOrder,
device->mAmbiOrder);
diff --git a/alc/alcmain.h b/alc/alcmain.h
index 3362c011..92c69b74 100644
--- a/alc/alcmain.h
+++ b/alc/alcmain.h
@@ -205,6 +205,7 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
*/
DevAmbiLayout mAmbiLayout{DevAmbiLayout::Default};
DevAmbiScaling mAmbiScale{DevAmbiScaling::Default};
+ float mXOverFreq{400.0f};
ALCenum LimiterState{ALC_DONT_CARE_SOFT};
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index bf439721..c072653d 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -247,7 +247,7 @@ void ConvolutionState::setBuffer(const ALCdevice *device, const BufferStorage *b
(uint64_t{buffer->mSampleLen}*device->Frequency + (buffer->mSampleRate-1)) /
buffer->mSampleRate);
- const BandSplitter splitter{400.0f / static_cast<float>(device->Frequency)};
+ const BandSplitter splitter{device->mXOverFreq / static_cast<float>(device->Frequency)};
for(auto &e : *mChans)
e.mFilter = splitter;
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp
index 646ac624..2bf09bef 100644
--- a/alc/effects/reverb.cpp
+++ b/alc/effects/reverb.cpp
@@ -672,7 +672,7 @@ void ReverbState::deviceUpdate(const ALCdevice *device)
mMixOut = &ReverbState::MixOutPlain;
mOrderScales.fill(1.0f);
}
- mAmbiSplitter[0][0].init(400.0f / frequency);
+ mAmbiSplitter[0][0].init(device->mXOverFreq / frequency);
std::fill(mAmbiSplitter[0].begin()+1, mAmbiSplitter[0].end(), mAmbiSplitter[0][0]);
std::fill(mAmbiSplitter[1].begin(), mAmbiSplitter[1].end(), mAmbiSplitter[0][0]);
}
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp
index f8a5f214..28d85177 100644
--- a/alc/hrtf.cpp
+++ b/alc/hrtf.cpp
@@ -279,7 +279,7 @@ std::unique_ptr<DirectHrtfState> DirectHrtfState::Create(size_t num_chans)
void DirectHrtfState::build(const HrtfStore *Hrtf, const uint irSize,
const al::span<const AngularPoint> AmbiPoints, const float (*AmbiMatrix)[MaxAmbiChannels],
- const al::span<const float,MaxAmbiOrder+1> AmbiOrderHFGain)
+ const float XOverFreq, const al::span<const float,MaxAmbiOrder+1> AmbiOrderHFGain)
{
using double2 = std::array<double,2>;
struct ImpulseResponse {
@@ -287,7 +287,7 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const uint irSize,
uint ldelay, rdelay;
};
- const double xover_norm{400.0 / Hrtf->sampleRate};
+ const double xover_norm{double{XOverFreq} / Hrtf->sampleRate};
for(size_t i{0};i < mChannels.size();++i)
{
const size_t order{AmbiIndex::OrderFromChannel[i]};
diff --git a/alc/hrtf.h b/alc/hrtf.h
index 56839abd..a46b64e2 100644
--- a/alc/hrtf.h
+++ b/alc/hrtf.h
@@ -73,7 +73,7 @@ struct DirectHrtfState {
*/
void build(const HrtfStore *Hrtf, const uint irSize,
const al::span<const AngularPoint> AmbiPoints, const float (*AmbiMatrix)[MaxAmbiChannels],
- const al::span<const float,MaxAmbiOrder+1> AmbiOrderHFGain);
+ const float XOverFreq, const al::span<const float,MaxAmbiOrder+1> AmbiOrderHFGain);
static std::unique_ptr<DirectHrtfState> Create(size_t num_chans);
diff --git a/alc/panning.cpp b/alc/panning.cpp
index b9ddd2e8..2da5d490 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -595,6 +595,7 @@ void InitCustomPanning(ALCdevice *device, const bool hqdec, const bool stablize,
if(!hqdec && conf->FreqBands != 1)
ERR("Basic renderer uses the high-frequency matrix as single-band (xover_freq = %.0fhz)\n",
conf->XOverFreq);
+ device->mXOverFreq = conf->XOverFreq;
const ALuint order{(conf->ChanMask > Ambi2OrderMask) ? 3u :
(conf->ChanMask > Ambi1OrderMask) ? 2u : 1u};
@@ -813,7 +814,8 @@ void InitHrtfPanning(ALCdevice *device)
HrtfStore *Hrtf{device->mHrtf.get()};
auto hrtfstate = DirectHrtfState::Create(count);
- hrtfstate->build(Hrtf, device->mIrSize, AmbiPoints, AmbiMatrix, AmbiOrderHFGain);
+ hrtfstate->build(Hrtf, device->mIrSize, AmbiPoints, AmbiMatrix, device->mXOverFreq,
+ AmbiOrderHFGain);
device->mHrtfState = std::move(hrtfstate);
InitNearFieldCtrl(device, Hrtf->field[0].distance, ambi_order, true);
@@ -848,6 +850,7 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, HrtfRequestMode hrtf_appreq
device->mHrtf = nullptr;
device->mIrSize = 0;
device->HrtfName.clear();
+ device->mXOverFreq = 400.0f;
device->mRenderMode = RenderMode::Normal;
if(device->FmtChans != DevFmtStereo)