aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-05-28 16:22:36 -0700
committerChris Robinson <[email protected]>2019-05-28 16:22:36 -0700
commitc80ee5b7014d12675e2c615574c9f3f3354ffd1b (patch)
tree75ac5c7197ab7d8994854455c7261a9d42a99c82
parent7ce2b632f51292c26014ad2efeb4b5429c3bf04f (diff)
Use std::array for most mixing buffer arrays
-rw-r--r--Alc/alc.cpp2
-rw-r--r--Alc/alu.cpp58
-rw-r--r--Alc/bformatdec.cpp19
-rw-r--r--Alc/bformatdec.h4
-rw-r--r--Alc/effects/base.h2
-rw-r--r--Alc/mastering.cpp20
-rw-r--r--Alc/mastering.h4
-rw-r--r--Alc/mixvoice.cpp29
-rw-r--r--Alc/panning.cpp2
-rw-r--r--Alc/uhjfilter.cpp12
-rw-r--r--Alc/uhjfilter.h3
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h2
-rw-r--r--OpenAL32/Include/alMain.h8
-rw-r--r--OpenAL32/Include/alu.h4
14 files changed, 89 insertions, 80 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index eb6269ec..6d09b118 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -1937,7 +1937,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
num_chans*sizeof(device->MixBuffer[0]));
device->MixBuffer.resize(num_chans);
- device->Dry.Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(device->MixBuffer[0]);
+ device->Dry.Buffer = device->MixBuffer.data();
if(device->RealOut.NumChannels != 0)
device->RealOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels;
else
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index 94ba3aa8..2ce74537 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -133,8 +133,9 @@ void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo)
ASSUME(lidx >= 0 && ridx >= 0);
DirectHrtfState *state{device->mHrtfState.get()};
- MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], device->Dry.Buffer,
- device->HrtfAccumData, state, device->Dry.NumChannels, SamplesToDo);
+ MixDirectHrtf(device->RealOut.Buffer[lidx].data(), device->RealOut.Buffer[ridx].data(),
+ &reinterpret_cast<float(&)[BUFFERSIZE]>(device->Dry.Buffer[0]), device->HrtfAccumData,
+ state, device->Dry.NumChannels, SamplesToDo);
}
void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo)
@@ -165,8 +166,8 @@ void ProcessBs2b(ALCdevice *device, const ALsizei SamplesToDo)
ASSUME(lidx >= 0 && ridx >= 0);
/* Apply binaural/crossfeed filter */
- bs2b_cross_feed(device->Bs2b.get(), device->RealOut.Buffer[lidx],
- device->RealOut.Buffer[ridx], SamplesToDo);
+ bs2b_cross_feed(device->Bs2b.get(), device->RealOut.Buffer[lidx].data(),
+ device->RealOut.Buffer[ridx].data(), SamplesToDo);
}
} // namespace
@@ -1465,14 +1466,17 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
[SamplesToDo](const ALeffectslot *slot) -> void
{
EffectState *state{slot->Params.mEffectState};
- state->process(SamplesToDo, slot->Wet.Buffer, slot->Wet.NumChannels,
- state->mOutBuffer, state->mOutChannels);
+ state->process(SamplesToDo,
+ &reinterpret_cast<float(&)[BUFFERSIZE]>(slot->Wet.Buffer[0]),
+ slot->Wet.NumChannels,
+ &reinterpret_cast<float(&)[BUFFERSIZE]>(state->mOutBuffer[0]),
+ state->mOutChannels);
}
);
}
-void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*Buffer)[BUFFERSIZE], const int lidx,
+void ApplyStablizer(FrontStablizer *Stablizer, FloatBufferLine *Buffer, const int lidx,
const int ridx, const int cidx, const ALsizei SamplesToDo, const ALsizei NumChannels)
{
ASSUME(SamplesToDo > 0);
@@ -1487,16 +1491,17 @@ void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*Buffer)[BUFFERSIZE], co
continue;
auto &DelayBuf = Stablizer->DelayBuf[i];
- auto buffer_end = Buffer[i] + SamplesToDo;
+ auto buffer_end = Buffer[i].begin() + SamplesToDo;
if(LIKELY(SamplesToDo >= ALsizei{FrontStablizer::DelayLength}))
{
- auto delay_end = std::rotate(Buffer[i], buffer_end - FrontStablizer::DelayLength,
- buffer_end);
- std::swap_ranges(Buffer[i], delay_end, std::begin(DelayBuf));
+ auto delay_end = std::rotate(Buffer[i].begin(),
+ buffer_end - FrontStablizer::DelayLength, buffer_end);
+ std::swap_ranges(Buffer[i].begin(), delay_end, std::begin(DelayBuf));
}
else
{
- auto delay_start = std::swap_ranges(Buffer[i], buffer_end, std::begin(DelayBuf));
+ auto delay_start = std::swap_ranges(Buffer[i].begin(), buffer_end,
+ std::begin(DelayBuf));
std::rotate(std::begin(DelayBuf), delay_start, std::end(DelayBuf));
}
}
@@ -1509,7 +1514,7 @@ void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*Buffer)[BUFFERSIZE], co
/* This applies the band-splitter, preserving phase at the cost of some
* delay. The shorter the delay, the more error seeps into the result.
*/
- auto apply_splitter = [&APFilter,&tmpbuf,SamplesToDo](const ALfloat *Buffer,
+ auto apply_splitter = [&APFilter,&tmpbuf,SamplesToDo](const FloatBufferLine &Buffer,
ALfloat (&DelayBuf)[FrontStablizer::DelayLength], BandSplitter &Filter,
ALfloat (&splitbuf)[2][BUFFERSIZE]) -> void
{
@@ -1520,7 +1525,7 @@ void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*Buffer)[BUFFERSIZE], co
*/
auto tmpbuf_end = std::begin(tmpbuf) + SamplesToDo;
std::copy_n(std::begin(DelayBuf), FrontStablizer::DelayLength, tmpbuf_end);
- std::reverse_copy(Buffer, Buffer+SamplesToDo, std::begin(tmpbuf));
+ std::reverse_copy(Buffer.begin(), Buffer.begin()+SamplesToDo, std::begin(tmpbuf));
std::copy_n(std::begin(tmpbuf), FrontStablizer::DelayLength, std::begin(DelayBuf));
/* Apply an all-pass on the reversed signal, then reverse the samples
@@ -1568,8 +1573,8 @@ void ApplyStablizer(FrontStablizer *Stablizer, ALfloat (*Buffer)[BUFFERSIZE], co
}
}
-void ApplyDistanceComp(ALfloat (*Samples)[BUFFERSIZE], const DistanceComp &distcomp,
- const ALsizei SamplesToDo, const ALsizei numchans)
+void ApplyDistanceComp(FloatBufferLine *Samples, const DistanceComp &distcomp,
+ const ALsizei SamplesToDo, const ALsizei numchans)
{
ASSUME(SamplesToDo > 0);
ASSUME(numchans > 0);
@@ -1583,7 +1588,7 @@ void ApplyDistanceComp(ALfloat (*Samples)[BUFFERSIZE], const DistanceComp &distc
if(base < 1)
continue;
- ALfloat *inout{al::assume_aligned<16>(Samples[c])};
+ ALfloat *inout{al::assume_aligned<16>(Samples[c].data())};
auto inout_end = inout + SamplesToDo;
if(LIKELY(SamplesToDo >= base))
{
@@ -1599,8 +1604,8 @@ void ApplyDistanceComp(ALfloat (*Samples)[BUFFERSIZE], const DistanceComp &distc
}
}
-void ApplyDither(ALfloat (*Samples)[BUFFERSIZE], ALuint *dither_seed, const ALfloat quant_scale,
- const ALsizei SamplesToDo, const ALsizei numchans)
+void ApplyDither(FloatBufferLine *Samples, ALuint *dither_seed, const ALfloat quant_scale,
+ const ALsizei SamplesToDo, const ALsizei numchans)
{
ASSUME(numchans > 0);
@@ -1610,11 +1615,10 @@ void ApplyDither(ALfloat (*Samples)[BUFFERSIZE], ALuint *dither_seed, const ALfl
*/
const ALfloat invscale{1.0f / quant_scale};
ALuint seed{*dither_seed};
- auto dither_channel = [&seed,invscale,quant_scale,SamplesToDo](ALfloat *input) -> void
+ auto dither_channel = [&seed,invscale,quant_scale,SamplesToDo](FloatBufferLine &input) -> void
{
ASSUME(SamplesToDo > 0);
- ALfloat *buffer{al::assume_aligned<16>(input)};
- auto dither_sample = [&seed,invscale,quant_scale](ALfloat sample) noexcept -> ALfloat
+ auto dither_sample = [&seed,invscale,quant_scale](const ALfloat sample) noexcept -> ALfloat
{
ALfloat val{sample * quant_scale};
ALuint rng0{dither_rng(&seed)};
@@ -1622,7 +1626,7 @@ void ApplyDither(ALfloat (*Samples)[BUFFERSIZE], ALuint *dither_seed, const ALfl
val += static_cast<ALfloat>(rng0*(1.0/UINT_MAX) - rng1*(1.0/UINT_MAX));
return fast_roundf(val) * invscale;
};
- std::transform(buffer, buffer+SamplesToDo, buffer, dither_sample);
+ std::transform(input.begin(), input.begin()+SamplesToDo, input.begin(), dither_sample);
};
std::for_each(Samples, Samples+numchans, dither_channel);
*dither_seed = seed;
@@ -1660,7 +1664,7 @@ template<> inline ALubyte SampleConv(ALfloat val) noexcept
{ return SampleConv<ALbyte>(val) + 128; }
template<DevFmtType T>
-void Write(const ALfloat (*InBuffer)[BUFFERSIZE], ALvoid *OutBuffer, const ALsizei Offset,
+void Write(const FloatBufferLine *InBuffer, ALvoid *OutBuffer, const ALsizei Offset,
const ALsizei SamplesToDo, const ALsizei numchans)
{
using SampleType = typename DevFmtTypeTraits<T>::Type;
@@ -1668,7 +1672,7 @@ void Write(const ALfloat (*InBuffer)[BUFFERSIZE], ALvoid *OutBuffer, const ALsiz
ASSUME(Offset >= 0);
ASSUME(numchans > 0);
SampleType *outbase = static_cast<SampleType*>(OutBuffer) + Offset*numchans;
- auto conv_channel = [&outbase,SamplesToDo,numchans](const ALfloat *inbuf) -> void
+ auto conv_channel = [&outbase,SamplesToDo,numchans](const FloatBufferLine &inbuf) -> void
{
ASSUME(SamplesToDo > 0);
SampleType *out{outbase++};
@@ -1677,7 +1681,7 @@ void Write(const ALfloat (*InBuffer)[BUFFERSIZE], ALvoid *OutBuffer, const ALsiz
*out = SampleConv<SampleType>(s);
out += numchans;
};
- std::for_each(inbuf, inbuf+SamplesToDo, conv_sample);
+ std::for_each(inbuf.begin(), inbuf.begin()+SamplesToDo, conv_sample);
};
std::for_each(InBuffer, InBuffer+numchans, conv_channel);
}
@@ -1758,7 +1762,7 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
if(LIKELY(OutBuffer))
{
- ALfloat (*Buffer)[BUFFERSIZE]{device->RealOut.Buffer};
+ FloatBufferLine *Buffer{device->RealOut.Buffer};
ALsizei Channels{device->RealOut.NumChannels};
/* Finally, interleave and convert samples, writing to the device's
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp
index 563282a7..33659e04 100644
--- a/Alc/bformatdec.cpp
+++ b/Alc/bformatdec.cpp
@@ -146,7 +146,7 @@ BFormatDec::BFormatDec(const ALsizei inchans, const ALsizei chancount,
}
-void BFormatDec::process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo)
+void BFormatDec::process(FloatBufferLine *OutBuffer, const ALsizei OutChannels, const FloatBufferLine *InSamples, const ALsizei SamplesToDo)
{
ASSUME(OutChannels > 0);
ASSUME(mNumChannels > 0);
@@ -154,19 +154,19 @@ void BFormatDec::process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChan
if(mDualBand)
{
for(ALsizei i{0};i < mNumChannels;i++)
- mXOver[i].process(mSamplesHF[i].data(), mSamplesLF[i].data(), InSamples[i],
- SamplesToDo);
+ mXOver[i].process(mSamplesHF[i].data(), mSamplesLF[i].data(), InSamples[i].data(),
+ SamplesToDo);
for(ALsizei chan{0};chan < OutChannels;chan++)
{
if(UNLIKELY(!(mEnabled&(1<<chan))))
continue;
- MixRowSamples(OutBuffer[chan], mMatrix.Dual[chan][sHFBand],
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(mSamplesHF[0]),
+ MixRowSamples(OutBuffer[chan].data(), mMatrix.Dual[chan][sHFBand],
+ &reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(mSamplesHF[0]),
mNumChannels, 0, SamplesToDo);
- MixRowSamples(OutBuffer[chan], mMatrix.Dual[chan][sLFBand],
- &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(mSamplesLF[0]),
+ MixRowSamples(OutBuffer[chan].data(), mMatrix.Dual[chan][sLFBand],
+ &reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(mSamplesLF[0]),
mNumChannels, 0, SamplesToDo);
}
}
@@ -177,8 +177,9 @@ void BFormatDec::process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChan
if(UNLIKELY(!(mEnabled&(1<<chan))))
continue;
- MixRowSamples(OutBuffer[chan], mMatrix.Single[chan], InSamples,
- mNumChannels, 0, SamplesToDo);
+ MixRowSamples(OutBuffer[chan].data(), mMatrix.Single[chan],
+ &reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(InSamples[0]), mNumChannels, 0,
+ SamplesToDo);
}
}
}
diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h
index d82f08ac..ef81b41d 100644
--- a/Alc/bformatdec.h
+++ b/Alc/bformatdec.h
@@ -43,8 +43,8 @@ public:
const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]);
/* Decodes the ambisonic input to the given output channels. */
- void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels,
- const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo);
+ void process(FloatBufferLine *OutBuffer, const ALsizei OutChannels,
+ const FloatBufferLine *InSamples, const ALsizei SamplesToDo);
/* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */
static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order,
diff --git a/Alc/effects/base.h b/Alc/effects/base.h
index ba1fbf96..467fb5af 100644
--- a/Alc/effects/base.h
+++ b/Alc/effects/base.h
@@ -143,7 +143,7 @@ struct EffectTarget {
struct EffectState {
RefCount mRef{1u};
- ALfloat (*mOutBuffer)[BUFFERSIZE]{nullptr};
+ FloatBufferLine *mOutBuffer{nullptr};
ALsizei mOutChannels{0};
diff --git a/Alc/mastering.cpp b/Alc/mastering.cpp
index 23386cf4..2cf6acf5 100644
--- a/Alc/mastering.cpp
+++ b/Alc/mastering.cpp
@@ -97,7 +97,7 @@ void ShiftSlidingHold(SlidingHold *Hold, const ALsizei n)
/* Multichannel compression is linked via the absolute maximum of all
* channels.
*/
-void LinkChannels(Compressor *Comp, const ALsizei SamplesToDo, const ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE])
+void LinkChannels(Compressor *Comp, const ALsizei SamplesToDo, const FloatBufferLine *OutBuffer)
{
const ALsizei index{Comp->mLookAhead};
const ALsizei numChans{Comp->mNumChans};
@@ -109,9 +109,9 @@ void LinkChannels(Compressor *Comp, const ALsizei SamplesToDo, const ALfloat (*R
auto side_begin = std::begin(Comp->mSideChain) + index;
std::fill(side_begin, side_begin+SamplesToDo, 0.0f);
- auto fill_max = [SamplesToDo,side_begin](const ALfloat *input) -> void
+ auto fill_max = [SamplesToDo,side_begin](const FloatBufferLine &input) -> void
{
- const ALfloat *RESTRICT buffer{al::assume_aligned<16>(input)};
+ const ALfloat *RESTRICT buffer{al::assume_aligned<16>(input.data())};
auto max_abs = std::bind(maxf, _1, std::bind(static_cast<float(&)(float)>(std::fabs), _2));
std::transform(side_begin, side_begin+SamplesToDo, buffer, side_begin, max_abs);
};
@@ -293,7 +293,7 @@ void GainCompressor(Compressor *Comp, const ALsizei SamplesToDo)
* reaching the offending impulse. This is best used when operating as a
* limiter.
*/
-void SignalDelay(Compressor *Comp, const ALsizei SamplesToDo, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE])
+void SignalDelay(Compressor *Comp, const ALsizei SamplesToDo, FloatBufferLine *OutBuffer)
{
static constexpr ALsizei mask{BUFFERSIZE - 1};
const ALsizei numChans{Comp->mNumChans};
@@ -305,7 +305,7 @@ void SignalDelay(Compressor *Comp, const ALsizei SamplesToDo, ALfloat (*RESTRICT
for(ALsizei c{0};c < numChans;c++)
{
- ALfloat *RESTRICT inout{al::assume_aligned<16>(OutBuffer[c])};
+ ALfloat *RESTRICT inout{al::assume_aligned<16>(OutBuffer[c].data())};
ALfloat *RESTRICT delay{al::assume_aligned<16>(Comp->mDelay[c])};
for(ALsizei i{0};i < SamplesToDo;i++)
{
@@ -425,7 +425,7 @@ Compressor::~Compressor()
}
-void Compressor::process(const ALsizei SamplesToDo, ALfloat (*OutBuffer)[BUFFERSIZE])
+void Compressor::process(const ALsizei SamplesToDo, FloatBufferLine *OutBuffer)
{
const ALsizei numChans{mNumChans};
@@ -435,9 +435,9 @@ void Compressor::process(const ALsizei SamplesToDo, ALfloat (*OutBuffer)[BUFFERS
const ALfloat preGain{mPreGain};
if(preGain != 1.0f)
{
- auto apply_gain = [SamplesToDo,preGain](ALfloat *input) noexcept -> void
+ auto apply_gain = [SamplesToDo,preGain](FloatBufferLine &input) noexcept -> void
{
- ALfloat *buffer{al::assume_aligned<16>(input)};
+ ALfloat *buffer{al::assume_aligned<16>(input.data())};
std::transform(buffer, buffer+SamplesToDo, buffer,
std::bind(std::multiplies<float>{}, _1, preGain));
};
@@ -460,9 +460,9 @@ void Compressor::process(const ALsizei SamplesToDo, ALfloat (*OutBuffer)[BUFFERS
SignalDelay(this, SamplesToDo, OutBuffer);
const ALfloat (&sideChain)[BUFFERSIZE*2] = mSideChain;
- auto apply_comp = [SamplesToDo,&sideChain](ALfloat *input) noexcept -> void
+ auto apply_comp = [SamplesToDo,&sideChain](FloatBufferLine &input) noexcept -> void
{
- ALfloat *buffer{al::assume_aligned<16>(input)};
+ ALfloat *buffer{al::assume_aligned<16>(input.data())};
const ALfloat *gains{al::assume_aligned<16>(&sideChain[0])};
std::transform(gains, gains+SamplesToDo, buffer, buffer,
std::bind(std::multiplies<float>{}, _1, _2));
diff --git a/Alc/mastering.h b/Alc/mastering.h
index a9411bd0..6cc40ba3 100644
--- a/Alc/mastering.h
+++ b/Alc/mastering.h
@@ -6,7 +6,7 @@
#include "AL/al.h"
#include "almalloc.h"
-/* For BUFFERSIZE. */
+/* For FloatBufferLine/BUFFERSIZE. */
#include "alMain.h"
@@ -65,7 +65,7 @@ struct Compressor {
~Compressor();
- void process(const ALsizei SamplesToDo, ALfloat (*OutBuffer)[BUFFERSIZE]);
+ void process(const ALsizei SamplesToDo, FloatBufferLine *OutBuffer);
ALsizei getLookAhead() const noexcept { return mLookAhead; }
DEF_PLACE_NEWDEL()
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp
index 284621ab..6df9f430 100644
--- a/Alc/mixvoice.cpp
+++ b/Alc/mixvoice.cpp
@@ -744,10 +744,9 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
hrtfparams.Gain = 0.0f;
hrtfparams.GainStep = gain / static_cast<ALfloat>(fademix);
- MixHrtfBlendSamples(
- voice->mDirect.Buffer[OutLIdx], voice->mDirect.Buffer[OutRIdx],
- HrtfSamples, AccumSamples, OutPos, IrSize, &parms.Hrtf.Old,
- &hrtfparams, fademix);
+ MixHrtfBlendSamples(voice->mDirect.Buffer[OutLIdx].data(),
+ voice->mDirect.Buffer[OutRIdx].data(), HrtfSamples, AccumSamples,
+ OutPos, IrSize, &parms.Hrtf.Old, &hrtfparams, fademix);
/* Update the old parameters with the result. */
parms.Hrtf.Old = parms.Hrtf.Target;
if(fademix < Counter)
@@ -778,10 +777,9 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
hrtfparams.Gain = parms.Hrtf.Old.Gain;
hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) /
static_cast<ALfloat>(todo);
- MixHrtfSamples(
- voice->mDirect.Buffer[OutLIdx], voice->mDirect.Buffer[OutRIdx],
- HrtfSamples+fademix, AccumSamples+fademix, OutPos+fademix, IrSize,
- &hrtfparams, todo);
+ MixHrtfSamples(voice->mDirect.Buffer[OutLIdx].data(),
+ voice->mDirect.Buffer[OutRIdx].data(), HrtfSamples+fademix,
+ AccumSamples+fademix, OutPos+fademix, IrSize, &hrtfparams, todo);
/* Store the interpolated gain or the final target gain
* depending if the fade is done.
*/
@@ -803,8 +801,8 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
SilentTarget : parms.Gains.Target};
MixSamples(samples, voice->mDirect.ChannelsPerOrder[0],
- voice->mDirect.Buffer, parms.Gains.Current, TargetGains, Counter,
- OutPos, DstBufferSize);
+ &reinterpret_cast<float(&)[BUFFERSIZE]>(voice->mDirect.Buffer[0]),
+ parms.Gains.Current, TargetGains, Counter, OutPos, DstBufferSize);
ALfloat (&nfcsamples)[BUFFERSIZE] = Device->NfcSampleData;
ALsizei chanoffset{voice->mDirect.ChannelsPerOrder[0]};
@@ -815,8 +813,9 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
return;
(parms.NFCtrlFilter.*process)(nfcsamples, samples, DstBufferSize);
MixSamples(nfcsamples, voice->mDirect.ChannelsPerOrder[order],
- voice->mDirect.Buffer+chanoffset, parms.Gains.Current+chanoffset,
- TargetGains+chanoffset, Counter, OutPos, DstBufferSize);
+ &reinterpret_cast<float(&)[BUFFERSIZE]>(voice->mDirect.Buffer[chanoffset]),
+ parms.Gains.Current+chanoffset, TargetGains+chanoffset, Counter,
+ OutPos, DstBufferSize);
chanoffset += voice->mDirect.ChannelsPerOrder[order];
};
apply_nfc(&NfcFilter::process1, 1);
@@ -827,7 +826,8 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
{
const ALfloat *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ?
SilentTarget : parms.Gains.Target};
- MixSamples(samples, voice->mDirect.Channels, voice->mDirect.Buffer,
+ MixSamples(samples, voice->mDirect.Channels,
+ &reinterpret_cast<float(&)[BUFFERSIZE]>(voice->mDirect.Buffer[0]),
parms.Gains.Current, TargetGains, Counter, OutPos, DstBufferSize);
}
}
@@ -844,7 +844,8 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
const ALfloat *TargetGains{UNLIKELY(vstate==ALvoice::Stopping) ? SilentTarget :
parms.Gains.Target};
- MixSamples(samples, send.Channels, send.Buffer, parms.Gains.Current,
+ MixSamples(samples, send.Channels,
+ &reinterpret_cast<float(&)[BUFFERSIZE]>(send.Buffer[0]), parms.Gains.Current,
TargetGains, Counter, OutPos, DstBufferSize);
};
std::for_each(voice->mSend.begin(), voice->mSend.end(), mix_send);
diff --git a/Alc/panning.cpp b/Alc/panning.cpp
index a209c6cf..d1d40927 100644
--- a/Alc/panning.cpp
+++ b/Alc/panning.cpp
@@ -976,6 +976,6 @@ void aluInitEffectPanning(ALeffectslot *slot, ALCdevice *device)
{ return BFChannelConfig{1.0f, acn}; }
);
std::fill(iter, slot->Wet.AmbiMap.end(), BFChannelConfig{});
- slot->Wet.Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(slot->MixBuffer[0]);
+ slot->Wet.Buffer = slot->MixBuffer.data();
slot->Wet.NumChannels = static_cast<ALsizei>(count);
}
diff --git a/Alc/uhjfilter.cpp b/Alc/uhjfilter.cpp
index 64d5f76c..acdf6f0b 100644
--- a/Alc/uhjfilter.cpp
+++ b/Alc/uhjfilter.cpp
@@ -59,7 +59,7 @@ void allpass_process(AllPassState *state, ALfloat *dst, const ALfloat *src, cons
* know which is the intended result.
*/
-void Uhj2Encoder::encode(ALfloat *LeftOut, ALfloat *RightOut, ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo)
+void Uhj2Encoder::encode(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, FloatBufferLine *InSamples, const ALsizei SamplesToDo)
{
alignas(16) ALfloat D[MAX_UPDATE_SAMPLES], S[MAX_UPDATE_SAMPLES];
alignas(16) ALfloat temp[MAX_UPDATE_SAMPLES];
@@ -72,7 +72,7 @@ void Uhj2Encoder::encode(ALfloat *LeftOut, ALfloat *RightOut, ALfloat (*InSample
ASSUME(todo > 0);
/* D = 0.6554516*Y */
- const ALfloat *RESTRICT input{al::assume_aligned<16>(InSamples[2]+base)};
+ const ALfloat *RESTRICT input{al::assume_aligned<16>(InSamples[2].data()+base)};
for(ALsizei i{0};i < todo;i++)
temp[i] = 0.6554516f*input[i];
allpass_process(&mFilter1_Y[0], temp, temp, Filter1CoeffSqr[0], todo);
@@ -89,8 +89,8 @@ void Uhj2Encoder::encode(ALfloat *LeftOut, ALfloat *RightOut, ALfloat (*InSample
mLastY = temp[todo-1];
/* D += j(-0.3420201*W + 0.5098604*X) */
- const ALfloat *RESTRICT input0{al::assume_aligned<16>(InSamples[0]+base)};
- const ALfloat *RESTRICT input1{al::assume_aligned<16>(InSamples[1]+base)};
+ const ALfloat *RESTRICT input0{al::assume_aligned<16>(InSamples[0].data()+base)};
+ const ALfloat *RESTRICT input1{al::assume_aligned<16>(InSamples[1].data()+base)};
for(ALsizei i{0};i < todo;i++)
temp[i] = -0.3420201f*input0[i] + 0.5098604f*input1[i];
allpass_process(&mFilter2_WX[0], temp, temp, Filter2CoeffSqr[0], todo);
@@ -113,11 +113,11 @@ void Uhj2Encoder::encode(ALfloat *LeftOut, ALfloat *RightOut, ALfloat (*InSample
mLastWX = temp[todo-1];
/* Left = (S + D)/2.0 */
- ALfloat *RESTRICT left = al::assume_aligned<16>(LeftOut+base);
+ ALfloat *RESTRICT left = al::assume_aligned<16>(LeftOut.data()+base);
for(ALsizei i{0};i < todo;i++)
left[i] += (S[i] + D[i]) * 0.5f;
/* Right = (S - D)/2.0 */
- ALfloat *RESTRICT right = al::assume_aligned<16>(RightOut+base);
+ ALfloat *RESTRICT right = al::assume_aligned<16>(RightOut.data()+base);
for(ALsizei i{0};i < todo;i++)
right[i] += (S[i] - D[i]) * 0.5f;
diff --git a/Alc/uhjfilter.h b/Alc/uhjfilter.h
index 1351491b..181e036a 100644
--- a/Alc/uhjfilter.h
+++ b/Alc/uhjfilter.h
@@ -45,7 +45,8 @@ struct Uhj2Encoder {
/* Encodes a 2-channel UHJ (stereo-compatible) signal from a B-Format input
* signal. The input must use FuMa channel ordering and scaling.
*/
- void encode(ALfloat *LeftOut, ALfloat *RightOut, ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo);
+ void encode(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, FloatBufferLine *InSamples,
+ const ALsizei SamplesToDo);
DEF_NEWDEL(Uhj2Encoder)
};
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 06681276..9956c432 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -71,7 +71,7 @@ struct ALeffectslot {
ALuint id{};
/* Mixing buffer used by the Wet mix. */
- al::vector<std::array<ALfloat,BUFFERSIZE>,16> MixBuffer;
+ al::vector<FloatBufferLine, 16> MixBuffer;
/* Wet buffer configuration is ACN channel order with N3D scaling.
* Consequently, effects that only want to work with mono input can use
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 7019a6d4..7538ade2 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -305,6 +305,8 @@ struct BFChannelConfig {
*/
#define BUFFERSIZE 1024
+using FloatBufferLine = std::array<float,BUFFERSIZE>;
+
/* Maximum number of samples to pad on either end of a buffer for resampling.
* Note that both the beginning and end need padding!
*/
@@ -315,14 +317,14 @@ struct MixParams {
/* Coefficient channel mapping for mixing to the buffer. */
std::array<BFChannelConfig,MAX_OUTPUT_CHANNELS> AmbiMap;
- ALfloat (*Buffer)[BUFFERSIZE]{nullptr};
+ FloatBufferLine *Buffer{nullptr};
ALsizei NumChannels{0};
};
struct RealMixParams {
std::array<ALint,MaxChannels> ChannelIndex{};
- ALfloat (*Buffer)[BUFFERSIZE]{nullptr};
+ FloatBufferLine *Buffer{nullptr};
ALsizei NumChannels{0};
};
@@ -405,7 +407,7 @@ struct ALCdevice {
alignas(16) float2 HrtfAccumData[BUFFERSIZE + HRIR_LENGTH];
/* Mixing buffer used by the Dry mix and Real output. */
- al::vector<std::array<ALfloat,BUFFERSIZE>, 16> MixBuffer;
+ al::vector<FloatBufferLine, 16> MixBuffer;
/* The "dry" path corresponds to the main output. */
MixParams Dry;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 642aeddc..327adfc0 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -263,7 +263,7 @@ struct ALvoice {
int FilterType;
DirectParams Params[MAX_INPUT_CHANNELS];
- ALfloat (*Buffer)[BUFFERSIZE];
+ FloatBufferLine *Buffer;
ALsizei Channels;
ALsizei ChannelsPerOrder[MAX_AMBI_ORDER+1];
} mDirect;
@@ -272,7 +272,7 @@ struct ALvoice {
int FilterType;
SendParams Params[MAX_INPUT_CHANNELS];
- ALfloat (*Buffer)[BUFFERSIZE];
+ FloatBufferLine *Buffer;
ALsizei Channels;
};
al::FlexArray<SendData> mSend;