diff options
author | Chris Robinson <[email protected]> | 2019-02-21 04:57:56 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-02-21 04:57:56 -0800 |
commit | 169a11dffc459a37c61b1dc6e7d66a303a935c62 (patch) | |
tree | ca4f02f68580c0fa1642f603b1513eada93f0918 | |
parent | 8ac2d34706d1dea7c33f2b33c156cc23dde7b197 (diff) |
Add some preliminary fields for mix-time ambisonic upsampling
-rw-r--r-- | OpenAL32/Include/alu.h | 13 | ||||
-rw-r--r-- | OpenAL32/alSource.cpp | 14 |
2 files changed, 23 insertions, 4 deletions
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 9792026c..6713c490 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -20,6 +20,7 @@ #include "logging.h" #include "math_defs.h" #include "filters/biquad.h" +#include "filters/splitter.h" #include "filters/nfc.h" #include "almalloc.h" #include "alnumeric.h" @@ -204,10 +205,11 @@ struct ALvoiceProps : public ALvoicePropsBase { DEF_NEWDEL(ALvoiceProps) }; -#define VOICE_IS_STATIC (1<<0) -#define VOICE_IS_FADING (1<<1) /* Fading sources use gain stepping for smooth transitions. */ -#define VOICE_HAS_HRTF (1<<2) -#define VOICE_HAS_NFC (1<<3) +#define VOICE_IS_STATIC (1u<<0) +#define VOICE_IS_FADING (1u<<1) /* Fading sources use gain stepping for smooth transitions. */ +#define VOICE_IS_AMBISONIC (1u<<2) /* Voice needs HF scaling for ambisonic upsampling. */ +#define VOICE_HAS_HRTF (1u<<3) +#define VOICE_HAS_NFC (1u<<4) struct ALvoice { std::atomic<ALvoiceProps*> Update{nullptr}; @@ -253,6 +255,9 @@ struct ALvoice { InterpState ResampleState; + std::array<ALfloat,MAX_AMBI_ORDER+1> AmbiScales; + BandSplitter AmbiSplitter[MAX_INPUT_CHANNELS]; + struct { int FilterType; DirectParams Params[MAX_INPUT_CHANNELS]; diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index cf466c32..fbf6bfe6 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -41,6 +41,7 @@ #include "alFilter.h" #include "alAuxEffectSlot.h" #include "ringbuffer.h" +#include "bformatdec.h" #include "backends/base.h" @@ -2828,6 +2829,19 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) voice->Flags = start_fading ? VOICE_IS_FADING : 0; if(source->SourceType == AL_STATIC) voice->Flags |= 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. + */ + if(((*buffer)->mFmtChannels == FmtBFormat2D || (*buffer)->mFmtChannels == FmtBFormat3D) && + device->mAmbiOrder > 1) + { + voice->AmbiScales = AmbiUpsampler::GetHFOrderScales(1, device->mAmbiOrder); + voice->AmbiSplitter[0].init(400.0f / static_cast<ALfloat>(device->Frequency)); + for(ALsizei i{1};i < voice->NumChannels;++i) + voice->AmbiSplitter[i] = voice->AmbiSplitter[0]; + voice->Flags |= VOICE_IS_AMBISONIC; + } + std::fill_n(std::begin(voice->Direct.Params), voice->NumChannels, DirectParams{}); std::for_each(voice->Send.begin(), voice->Send.end(), [voice](ALvoice::SendData &send) -> void |