aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp4
-rw-r--r--alc/alu.cpp24
-rw-r--r--alc/bformatdec.cpp21
-rw-r--r--alc/effects/convolution.cpp22
-rw-r--r--alc/hrtf.cpp2
-rw-r--r--alc/panning.cpp37
6 files changed, 54 insertions, 56 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 8cd902ed..2b9eb2df 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2212,8 +2212,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
if(voice->mAmbiOrder && device->mAmbiOrder > voice->mAmbiOrder)
{
const uint8_t *OrderFromChan{(voice->mFmtChannels == FmtBFormat2D) ?
- AmbiIndex::OrderFrom2DChannel.data() :
- AmbiIndex::OrderFromChannel.data()};
+ AmbiIndex::OrderFrom2DChannel().data() :
+ AmbiIndex::OrderFromChannel().data()};
const BandSplitter splitter{device->mXOverFreq /
static_cast<float>(device->Frequency)};
diff --git a/alc/alu.cpp b/alc/alu.cpp
index fe4c54a1..0cbfefec 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -345,23 +345,23 @@ inline uint dither_rng(uint *seed) noexcept
}
-auto GetAmbiScales(AmbiScaling scaletype) noexcept -> const std::array<float,MaxAmbiChannels>&
+inline auto& GetAmbiScales(AmbiScaling scaletype) noexcept
{
- if(scaletype == AmbiScaling::FuMa) return AmbiScale::FromFuMa;
- if(scaletype == AmbiScaling::SN3D) return AmbiScale::FromSN3D;
- return AmbiScale::FromN3D;
+ if(scaletype == AmbiScaling::FuMa) return AmbiScale::FromFuMa();
+ if(scaletype == AmbiScaling::SN3D) return AmbiScale::FromSN3D();
+ return AmbiScale::FromN3D();
}
-auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const std::array<uint8_t,MaxAmbiChannels>&
+inline auto& GetAmbiLayout(AmbiLayout layouttype) noexcept
{
- if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa;
- return AmbiIndex::FromACN;
+ if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa();
+ return AmbiIndex::FromACN();
}
-auto GetAmbi2DLayout(AmbiLayout layouttype) noexcept -> const std::array<uint8_t,MaxAmbi2DChannels>&
+inline auto& GetAmbi2DLayout(AmbiLayout layouttype) noexcept
{
- if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa2D;
- return AmbiIndex::FromACN2D;
+ if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa2D();
+ return AmbiIndex::FromACN2D();
}
@@ -855,7 +855,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
std::bind(std::multiplies<float>{}, _1, 1.0f-coverage));
/* NOTE: W needs to be scaled according to channel scaling. */
- const auto &scales = GetAmbiScales(voice->mAmbiScaling);
+ auto&& scales = GetAmbiScales(voice->mAmbiScaling);
ComputePanGains(&Device->Dry, coeffs.data(), DryGain.Base*scales[0],
voice->mChans[0].mDryParams.Gains.Target);
for(uint i{0};i < NumSends;i++)
@@ -907,7 +907,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
for(size_t c{1};c < num_channels;c++)
{
const size_t acn{index_map[c]};
- const size_t order{AmbiIndex::OrderFromChannel[acn]};
+ const size_t order{AmbiIndex::OrderFromChannel()[acn]};
const size_t tocopy{ChansPerOrder[order]};
const size_t offset{OrderOffset[order]};
const float scale{scales[acn] * coverage};
diff --git a/alc/bformatdec.cpp b/alc/bformatdec.cpp
index 64c45b68..9b2d9049 100644
--- a/alc/bformatdec.cpp
+++ b/alc/bformatdec.cpp
@@ -31,19 +31,18 @@ constexpr std::array<float,MaxAmbiOrder+1> Ambi3DDecoderHFScale3O{{
5.89792205e-01f, 8.79693856e-01f, 1.00000000e+00f, 1.00000000e+00f
}};
-inline auto GetDecoderHFScales(uint order) noexcept -> const std::array<float,MaxAmbiOrder+1>&
+inline auto& GetDecoderHFScales(uint order) noexcept
{
if(order >= 3) return Ambi3DDecoderHFScale3O;
if(order == 2) return Ambi3DDecoderHFScale2O;
return Ambi3DDecoderHFScale;
}
-inline auto GetAmbiScales(AmbDecScale scaletype) noexcept
- -> const std::array<float,MaxAmbiChannels>&
+inline auto& GetAmbiScales(AmbDecScale scaletype) noexcept
{
- if(scaletype == AmbDecScale::FuMa) return AmbiScale::FromFuMa;
- if(scaletype == AmbDecScale::SN3D) return AmbiScale::FromSN3D;
- return AmbiScale::FromN3D;
+ if(scaletype == AmbDecScale::FuMa) return AmbiScale::FromFuMa();
+ if(scaletype == AmbDecScale::SN3D) return AmbiScale::FromSN3D();
+ return AmbiScale::FromN3D();
}
} // namespace
@@ -56,15 +55,15 @@ BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const siz
, mChannelDec{inchans}
{
const bool periphonic{(conf->ChanMask&AmbiPeriphonicMask) != 0};
- const std::array<float,MaxAmbiChannels> &coeff_scale = GetAmbiScales(conf->CoeffScale);
+ auto&& coeff_scale = GetAmbiScales(conf->CoeffScale);
if(!mDualBand)
{
for(size_t j{0},k{0};j < mChannelDec.size();++j)
{
- const size_t acn{periphonic ? j : AmbiIndex::FromACN2D[j]};
+ const size_t acn{periphonic ? j : AmbiIndex::FromACN2D()[j]};
if(!(conf->ChanMask&(1u<<acn))) continue;
- const size_t order{AmbiIndex::OrderFromChannel[acn]};
+ const size_t order{AmbiIndex::OrderFromChannel()[acn]};
const float gain{conf->HFOrderGain[order] / coeff_scale[acn]};
for(size_t i{0u};i < conf->NumSpeakers;++i)
{
@@ -83,9 +82,9 @@ BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const siz
const float ratio{std::pow(10.0f, conf->XOverRatio / 40.0f)};
for(size_t j{0},k{0};j < mChannelDec.size();++j)
{
- const size_t acn{periphonic ? j : AmbiIndex::FromACN2D[j]};
+ const size_t acn{periphonic ? j : AmbiIndex::FromACN2D()[j]};
if(!(conf->ChanMask&(1u<<acn))) continue;
- const size_t order{AmbiIndex::OrderFromChannel[acn]};
+ const size_t order{AmbiIndex::OrderFromChannel()[acn]};
const float hfGain{conf->HFOrderGain[order] * ratio / coeff_scale[acn]};
const float lfGain{conf->LFOrderGain[order] / ratio / coeff_scale[acn]};
for(size_t i{0u};i < conf->NumSpeakers;++i)
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 4e10b62a..2dec0dc6 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -76,23 +76,23 @@ void LoadSamples(double *RESTRICT dst, const al::byte *src, const size_t srcstep
}
-auto GetAmbiScales(AmbiScaling scaletype) noexcept -> const std::array<float,MaxAmbiChannels>&
+inline auto& GetAmbiScales(AmbiScaling scaletype) noexcept
{
- if(scaletype == AmbiScaling::FuMa) return AmbiScale::FromFuMa;
- if(scaletype == AmbiScaling::SN3D) return AmbiScale::FromSN3D;
- return AmbiScale::FromN3D;
+ if(scaletype == AmbiScaling::FuMa) return AmbiScale::FromFuMa();
+ if(scaletype == AmbiScaling::SN3D) return AmbiScale::FromSN3D();
+ return AmbiScale::FromN3D();
}
-auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const std::array<uint8_t,MaxAmbiChannels>&
+inline auto& GetAmbiLayout(AmbiLayout layouttype) noexcept
{
- if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa;
- return AmbiIndex::FromACN;
+ if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa();
+ return AmbiIndex::FromACN();
}
-auto GetAmbi2DLayout(AmbiLayout layouttype) noexcept -> const std::array<uint8_t,MaxAmbi2DChannels>&
+inline auto& GetAmbi2DLayout(AmbiLayout layouttype) noexcept
{
- if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa2D;
- return AmbiIndex::FromACN2D;
+ if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa2D();
+ return AmbiIndex::FromACN2D();
}
@@ -387,7 +387,7 @@ void ConvolutionState::update(const ALCcontext *context, const EffectSlot *slot,
}
mOutTarget = target.Main->Buffer;
- const auto &scales = GetAmbiScales(mAmbiScaling);
+ auto&& scales = GetAmbiScales(mAmbiScaling);
const uint8_t *index_map{(mChannels == FmtBFormat2D) ?
GetAmbi2DLayout(mAmbiLayout).data() :
GetAmbiLayout(mAmbiLayout).data()};
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp
index 891f9cb4..4e32a0ba 100644
--- a/alc/hrtf.cpp
+++ b/alc/hrtf.cpp
@@ -291,7 +291,7 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const uint irSize,
const double xover_norm{double{XOverFreq} / Hrtf->sampleRate};
for(size_t i{0};i < mChannels.size();++i)
{
- const size_t order{AmbiIndex::OrderFromChannel[i]};
+ const size_t order{AmbiIndex::OrderFromChannel()[i]};
mChannels[i].mSplitter.init(static_cast<float>(xover_norm));
mChannels[i].mHfScale = AmbiOrderHFGain[order];
}
diff --git a/alc/panning.cpp b/alc/panning.cpp
index c8a314b2..1ac3bb04 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -300,17 +300,17 @@ void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf,
}
-auto GetAmbiScales(DevAmbiScaling scaletype) noexcept -> const std::array<float,MaxAmbiChannels>&
+inline auto& GetAmbiScales(DevAmbiScaling scaletype) noexcept
{
- if(scaletype == DevAmbiScaling::FuMa) return AmbiScale::FromFuMa;
- if(scaletype == DevAmbiScaling::SN3D) return AmbiScale::FromSN3D;
- return AmbiScale::FromN3D;
+ if(scaletype == DevAmbiScaling::FuMa) return AmbiScale::FromFuMa();
+ if(scaletype == DevAmbiScaling::SN3D) return AmbiScale::FromSN3D();
+ return AmbiScale::FromN3D();
}
-auto GetAmbiLayout(DevAmbiLayout layouttype) noexcept -> const std::array<uint8_t,MaxAmbiChannels>&
+inline auto& GetAmbiLayout(DevAmbiLayout layouttype) noexcept
{
- if(layouttype == DevAmbiLayout::FuMa) return AmbiIndex::FromFuMa;
- return AmbiIndex::FromACN;
+ if(layouttype == DevAmbiLayout::FuMa) return AmbiIndex::FromFuMa();
+ return AmbiIndex::FromACN();
}
@@ -492,8 +492,8 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize=
if(device->FmtChans == DevFmtAmbi3D)
{
const char *devname{device->DeviceName.c_str()};
- const std::array<uint8_t,MaxAmbiChannels> &acnmap = GetAmbiLayout(device->mAmbiLayout);
- const std::array<float,MaxAmbiChannels> &n3dscale = GetAmbiScales(device->mAmbiScale);
+ auto&& acnmap = GetAmbiLayout(device->mAmbiLayout);
+ auto&& n3dscale = GetAmbiScales(device->mAmbiScale);
/* For DevFmtAmbi3D, the ambisonic order is already set. */
const size_t count{AmbiChannelsFromOrder(device->mAmbiOrder)};
@@ -554,7 +554,7 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize=
/* Built-in speaker decoders are always 2D. */
const size_t ambicount{Ambi2DChannelsFromOrder(decoder.mOrder)};
- std::transform(AmbiIndex::FromACN2D.begin(), AmbiIndex::FromACN2D.begin()+ambicount,
+ std::transform(AmbiIndex::FromACN2D().begin(), AmbiIndex::FromACN2D().begin()+ambicount,
std::begin(device->Dry.AmbiMap),
[](const uint8_t &index) noexcept { return BFChannelConfig{1.0f, index}; }
);
@@ -611,7 +611,7 @@ void InitCustomPanning(ALCdevice *device, const bool hqdec, const bool stablize,
if((conf->ChanMask&AmbiPeriphonicMask))
{
count = AmbiChannelsFromOrder(order);
- std::transform(AmbiIndex::FromACN.begin(), AmbiIndex::FromACN.begin()+count,
+ std::transform(AmbiIndex::FromACN().begin(), AmbiIndex::FromACN().begin()+count,
std::begin(device->Dry.AmbiMap),
[](const uint8_t &index) noexcept { return BFChannelConfig{1.0f, index}; }
);
@@ -619,7 +619,7 @@ void InitCustomPanning(ALCdevice *device, const bool hqdec, const bool stablize,
else
{
count = Ambi2DChannelsFromOrder(order);
- std::transform(AmbiIndex::FromACN2D.begin(), AmbiIndex::FromACN2D.begin()+count,
+ std::transform(AmbiIndex::FromACN2D().begin(), AmbiIndex::FromACN2D().begin()+count,
std::begin(device->Dry.AmbiMap),
[](const uint8_t &index) noexcept { return BFChannelConfig{1.0f, index}; }
);
@@ -812,7 +812,7 @@ void InitHrtfPanning(ALCdevice *device)
device->mAmbiOrder = ambi_order;
const size_t count{AmbiChannelsFromOrder(ambi_order)};
- std::transform(AmbiIndex::FromACN.begin(), AmbiIndex::FromACN.begin()+count,
+ std::transform(AmbiIndex::FromACN().begin(), AmbiIndex::FromACN().begin()+count,
std::begin(device->Dry.AmbiMap),
[](const uint8_t &index) noexcept { return BFChannelConfig{1.0f, index}; }
);
@@ -834,11 +834,10 @@ void InitUhjPanning(ALCdevice *device)
device->mAmbiOrder = 1;
- auto acnmap_end = AmbiIndex::FromFuMa.begin() + count;
- std::transform(AmbiIndex::FromFuMa.begin(), acnmap_end, std::begin(device->Dry.AmbiMap),
+ auto acnmap_begin = AmbiIndex::FromFuMa().begin();
+ std::transform(acnmap_begin, acnmap_begin + count, std::begin(device->Dry.AmbiMap),
[](const uint8_t &acn) noexcept -> BFChannelConfig
- { return BFChannelConfig{1.0f/AmbiScale::FromFuMa[acn], acn}; }
- );
+ { return BFChannelConfig{1.0f/AmbiScale::FromFuMa()[acn], acn}; });
AllocChannels(device, count, device->channelsFromFmt());
}
@@ -1092,8 +1091,8 @@ void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context)
WetBuffer *wetbuffer{slot->mWetBuffer = wetbuffer_iter->get()};
wetbuffer->mInUse = true;
- auto acnmap_end = AmbiIndex::FromACN.begin() + count;
- auto iter = std::transform(AmbiIndex::FromACN.begin(), acnmap_end, slot->Wet.AmbiMap.begin(),
+ auto acnmap_begin = AmbiIndex::FromACN().begin();
+ auto iter = std::transform(acnmap_begin, acnmap_begin + count, slot->Wet.AmbiMap.begin(),
[](const uint8_t &acn) noexcept -> BFChannelConfig
{ return BFChannelConfig{1.0f, acn}; });
std::fill(iter, slot->Wet.AmbiMap.end(), BFChannelConfig{});