aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-12-05 00:18:01 -0800
committerChris Robinson <[email protected]>2019-12-05 00:18:01 -0800
commit863171efc9ed02b902111e15f7a63bcca83e407c (patch)
tree965d383144a57833aa7303544238fcecdcdb969f
parentbbe1c4c64ef4d0640cebd6a901ac1c56c0c1ecbf (diff)
Check the voice's ambisonic order when starting
-rw-r--r--al/source.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/al/source.cpp b/al/source.cpp
index 11049eab..75d4a803 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -2802,11 +2802,11 @@ START_API_FUNC
voice->mFlags = start_fading ? VOICE_IS_FADING : 0;
if(source->SourceType == AL_STATIC) voice->mFlags |= VOICE_IS_STATIC;
- /* Don't need to set the VOICE_IS_AMBISONIC flag if the device is
- * mixing in first order. No HF scaling is necessary to mix it.
+ /* Don't need to set the VOICE_IS_AMBISONIC flag if the device is not
+ * higher order than the voice. No HF scaling is necessary to mix it.
*/
if((voice->mFmtChannels == FmtBFormat2D || voice->mFmtChannels == FmtBFormat3D)
- && device->mAmbiOrder > 1)
+ && device->mAmbiOrder > voice->mAmbiOrder)
{
const ALuint *OrderFromChan;
if(voice->mFmtChannels == FmtBFormat2D)
@@ -2822,14 +2822,17 @@ START_API_FUNC
OrderFromChan = Order3DFromChan;
}
- BandSplitter splitter{400.0f / static_cast<float>(device->Frequency)};
+ const BandSplitter splitter{400.0f / static_cast<float>(device->Frequency)};
- const auto scales = BFormatDec::GetHFOrderScales(1, device->mAmbiOrder);
- auto init_ambi = [scales,&OrderFromChan,&splitter](ALvoice::ChannelData &chandata) -> void
+ const auto scales = BFormatDec::GetHFOrderScales(voice->mAmbiOrder,
+ device->mAmbiOrder);
+ auto init_ambi = [device,&scales,&OrderFromChan,splitter](ALvoice::ChannelData &chandata) -> void
{
chandata.mPrevSamples.fill(0.0f);
chandata.mAmbiScale = scales[*(OrderFromChan++)];
chandata.mAmbiSplitter = splitter;
+ chandata.mDryParams = DirectParams{};
+ std::fill_n(chandata.mWetParams.begin(), device->NumAuxSends, SendParams{});
};
std::for_each(voice->mChans.begin(), voice->mChans.begin()+voice->mNumChannels,
init_ambi);
@@ -2839,20 +2842,16 @@ START_API_FUNC
else
{
/* Clear previous samples. */
- auto clear_prevs = [](ALvoice::ChannelData &chandata) -> void
- { chandata.mPrevSamples.fill(0.0f); };
+ auto clear_prevs = [device](ALvoice::ChannelData &chandata) -> void
+ {
+ chandata.mPrevSamples.fill(0.0f);
+ chandata.mDryParams = DirectParams{};
+ std::fill_n(chandata.mWetParams.begin(), device->NumAuxSends, SendParams{});
+ };
std::for_each(voice->mChans.begin(), voice->mChans.begin()+voice->mNumChannels,
clear_prevs);
}
- auto clear_params = [device](ALvoice::ChannelData &chandata) -> void
- {
- chandata.mDryParams = DirectParams{};
- std::fill_n(chandata.mWetParams.begin(), device->NumAuxSends, SendParams{});
- };
- std::for_each(voice->mChans.begin(), voice->mChans.begin()+voice->mNumChannels,
- clear_params);
-
if(device->AvgSpeakerDist > 0.0f)
{
const ALfloat w1{SPEEDOFSOUNDMETRESPERSEC /