diff --git a/Source/sg_StereoSpatAlgorithm.cpp b/Source/sg_StereoSpatAlgorithm.cpp index 0bc0a094..0b97c593 100644 --- a/Source/sg_StereoSpatAlgorithm.cpp +++ b/Source/sg_StereoSpatAlgorithm.cpp @@ -19,6 +19,9 @@ #include "sg_StereoSpatAlgorithm.hpp" #include "sg_DummySpatAlgorithm.hpp" +#include "sg_VbapSpatAlgorithm.hpp" +#include "sg_MbapSpatAlgorithm.hpp" +#include "sg_HybridSpatAlgorithm.hpp" #include "sg_StaticMap.hpp" #include "sg_StrongArray.hpp" #include "sg_TaggedAudioBuffer.hpp" @@ -34,6 +37,8 @@ void StereoSpatAlgorithm::updateSpatData(source_index_t const sourceIndex, Sourc return; } + mInnerAlgorithm->updateSpatData(sourceIndex, sourceData); + // using fast = juce::dsp::FastMathApproximations; auto & queue{ mData[sourceIndex].gainsUpdater }; @@ -62,7 +67,7 @@ void StereoSpatAlgorithm::updateSpatData(source_index_t const sourceIndex, Sourc //============================================================================== void StereoSpatAlgorithm::process(AudioConfig const & config, SourceAudioBuffer & sourcesBuffer, - SpeakerAudioBuffer & /*speakersBuffer*/, + SpeakerAudioBuffer & speakersBuffer, juce::AudioBuffer & stereoBuffer, SourcePeaks const & sourcePeaks, [[maybe_unused]] SpeakersAudioConfig const * altSpeakerConfig) @@ -74,6 +79,9 @@ void StereoSpatAlgorithm::process(AudioConfig const & config, auto const & gainInterpolation{ config.spatGainsInterpolation }; auto const gainFactor{ std::pow(gainInterpolation, 0.1f) * 0.0099f + 0.99f }; + mInnerAlgorithm + ->process(config, sourcesBuffer, speakersBuffer, stereoBuffer, sourcePeaks, altSpeakerConfig); + auto const numSamples{ sourcesBuffer.getNumSamples() }; for (auto const & source : config.sourcesAudioConfig) { if (source.value.isMuted || source.value.directOut || sourcePeaks[source.key] < SMALL_GAIN) { @@ -150,6 +158,23 @@ std::unique_ptr StereoSpatAlgorithm::make(SpeakerSetup co StereoSpatAlgorithm::StereoSpatAlgorithm(SpeakerSetup const & speakerSetup, SourcesData const & sources) { JUCE_ASSERT_MESSAGE_THREAD; + + switch (speakerSetup.spatMode) { + case SpatMode::vbap: + mInnerAlgorithm = std::make_unique(speakerSetup.speakers); + break; + case SpatMode::mbap: + mInnerAlgorithm = std::make_unique(speakerSetup); + break; + case SpatMode::hybrid: + mInnerAlgorithm = std::make_unique(speakerSetup); + break; + case SpatMode::invalid: + break; + } + + jassert(mInnerAlgorithm); + fixDirectOutsIntoPlace(sources, speakerSetup); } diff --git a/Source/sg_StereoSpatAlgorithm.hpp b/Source/sg_StereoSpatAlgorithm.hpp index ad5f8e42..c445336b 100644 --- a/Source/sg_StereoSpatAlgorithm.hpp +++ b/Source/sg_StereoSpatAlgorithm.hpp @@ -39,6 +39,7 @@ using StereoSourcesData = StrongArray mInnerAlgorithm{}; StereoSourcesData mData{}; public: