aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-01-04 00:37:59 -0800
committerChris Robinson <[email protected]>2020-01-04 00:37:59 -0800
commit462bcd4ab7ba1603bef159ec48dc995045ced036 (patch)
tree9dc56ee0aed89c522e1f044a4afdb4197dc8980c /alc
parenta42a586f0fbea0f84fc6b16f41fe705c1a8b83c0 (diff)
Use a span instead of an array+size
Diffstat (limited to 'alc')
-rw-r--r--alc/bformatdec.cpp20
-rw-r--r--alc/bformatdec.h5
-rw-r--r--alc/panning.cpp7
3 files changed, 12 insertions, 20 deletions
diff --git a/alc/bformatdec.cpp b/alc/bformatdec.cpp
index a9510574..bef5ae20 100644
--- a/alc/bformatdec.cpp
+++ b/alc/bformatdec.cpp
@@ -65,10 +65,7 @@ BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALu
mEnabled = std::accumulate(std::begin(chanmap), std::begin(chanmap)+conf->Speakers.size(), 0u,
[](ALuint mask, const ALuint &chan) noexcept -> ALuint
- { return mask | (1 << chan); }
- );
-
- const ALfloat xover_norm{conf->XOverFreq / static_cast<float>(srate)};
+ { return mask | (1 << chan); });
const bool periphonic{(conf->ChanMask&AMBI_PERIPHONIC_MASK) != 0};
const std::array<float,MAX_AMBI_CHANNELS> &coeff_scale = GetAmbiScales(conf->CoeffScale);
@@ -93,7 +90,7 @@ BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALu
}
else
{
- mXOver[0].init(xover_norm);
+ mXOver[0].init(conf->XOverFreq / static_cast<float>(srate));
std::fill(std::begin(mXOver)+1, std::end(mXOver), mXOver[0]);
const float ratio{std::pow(10.0f, conf->XOverRatio / 40.0f)};
@@ -118,18 +115,15 @@ BFormatDec::BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALu
}
}
-BFormatDec::BFormatDec(const ALuint inchans, const ALsizei chancount,
- const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
- const ALuint (&chanmap)[MAX_OUTPUT_CHANNELS])
+BFormatDec::BFormatDec(const ALuint inchans, const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
+ const al::span<const ALuint> chanmap)
{
mSamples.resize(2);
mNumChannels = inchans;
- ASSUME(chancount > 0);
- mEnabled = std::accumulate(std::begin(chanmap), std::begin(chanmap)+chancount, 0u,
+ mEnabled = std::accumulate(chanmap.begin(), chanmap.end(), 0u,
[](ALuint mask, const ALuint &chan) noexcept -> ALuint
- { return mask | (1 << chan); }
- );
+ { return mask | (1 << chan); });
const ChannelDec *incoeffs{chancoeffs};
auto set_coeffs = [this,inchans,&incoeffs](const ALuint chanidx) noexcept -> void
@@ -140,7 +134,7 @@ BFormatDec::BFormatDec(const ALuint inchans, const ALsizei chancount,
ASSUME(inchans > 0);
std::copy_n(std::begin(coeffs), inchans, std::begin(mtx));
};
- std::for_each(chanmap, chanmap+chancount, set_coeffs);
+ std::for_each(chanmap.begin(), chanmap.end(), set_coeffs);
}
diff --git a/alc/bformatdec.h b/alc/bformatdec.h
index edbb6d50..b4649108 100644
--- a/alc/bformatdec.h
+++ b/alc/bformatdec.h
@@ -44,9 +44,8 @@ class BFormatDec {
public:
BFormatDec(const AmbDecConf *conf, const bool allow_2band, const ALuint inchans,
const ALuint srate, const ALuint (&chanmap)[MAX_OUTPUT_CHANNELS]);
- BFormatDec(const ALuint inchans, const ALsizei chancount,
- const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
- const ALuint (&chanmap)[MAX_OUTPUT_CHANNELS]);
+ BFormatDec(const ALuint inchans, const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS],
+ const al::span<const ALuint> chanmap);
/* Decodes the ambisonic input to the given output channels. */
void process(const al::span<FloatBufferLine> OutBuffer, const FloatBufferLine *InSamples,
diff --git a/alc/panning.cpp b/alc/panning.cpp
index a934b58a..cbe6d58f 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -460,10 +460,9 @@ void InitPanning(ALCdevice *device)
TRACE("Enabling %s-order%s ambisonic decoder\n",
(coeffcount > 5) ? "third" :
(coeffcount > 3) ? "second" : "first",
- ""
- );
- device->AmbiDecoder = al::make_unique<BFormatDec>(coeffcount,
- static_cast<ALsizei>(chanmap.size()), chancoeffs, idxmap);
+ "");
+ device->AmbiDecoder = al::make_unique<BFormatDec>(coeffcount, chancoeffs,
+ al::span<const ALuint>{idxmap, chanmap.size()});
}
}