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.
This commit is contained in:
+1
-1
@@ -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)
|
||||
{
|
||||
|
||||
+2
-1
@@ -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);
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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]};
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
+4
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user