Commit dd5f0ae5 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merge branch 'feature/reusable_clustering' into develop

parents ec1bee53 4b2f0252
......@@ -280,6 +280,7 @@ if( ITA_VACORE_WITH_RENDERER_BINAURAL_FREE_FIELD )
add_definitions( "-DVACORE_WITH_RENDERER_BINAURAL_FREE_FIELD" )
endif( )
if( ITA_VACORE_WITH_RENDERER_BINAURAL_ARTIFICIAL_REVERB )
vista_use_package( DspFilters REQUIRED FIND_DEPENDENCIES )
add_definitions( "-DVACORE_WITH_RENDERER_BINAURAL_ARTIFICIAL_REVERB" )
endif( )
if( ITA_VACORE_WITH_RENDERER_BINAURAL_ROOM_ACOUSTICS )
......
......@@ -48,7 +48,6 @@ public:
inline void SetDefaults()
{
bLogEstimatedOutputEnabled = false;
bLogInputEnabled = false;
iNumHistoryKeys = 100;
......
#define NOMINMAX
#include <limits>
#include <algorithm>
#include <memory>
#include <math.h>
// VA
#include <VAObjectPool.h>
// ITA includes
#include <ITAUPFilter.h>
// Utils
#include "../VAConfig.h"
#include "VABinauralClustering.h"
#include "VABinauralClusteringDirectionPoolFactory.h"
CVABinauralClustering::CVABinauralClustering()
{
IVAPoolObjectFactory* clusterFactory = new CVABinauralClusteringDirectionPoolFactory();
clusterPool = IVAObjectPool::Create( 16, 2, clusterFactory, true );
}
CVABinauralClustering::~CVABinauralClustering()
{
}
void CVABinauralClustering::AddWaveFront( int sourceID, IVABinauralWaveFront* source )
{
m_mUnassignedWaveFronts.insert( std::pair< int, IVABinauralWaveFront* >( sourceID, source ) );
}
void CVABinauralClustering::RemoveWaveFront( int sourceID )
{
m_iDelWaveFrontIDs.insert( sourceID );
}
void CVABinauralClustering::Init( int iSoundReceiverID, CVABinauralClusteringDirectionReceiver* pSoundReceiver, int iNumClusters )
{
m_iSoundReceiverID = iSoundReceiverID;
m_pReceiver = pSoundReceiver;
m_iNumClusters = iNumClusters;
m_dDistanceThreshold = 4. / iNumClusters;
m_pOutput = new ITASampleFrame( 2, pSoundReceiver->pOutput->GetLength(), true );
for( int i = 0; i < iNumClusters; ++i )
{
// initialize left channel convolver for each cluster
ITAUPConvolution* pFIRConvolverChL = new ITAUPConvolution( VAConfig::blockLength, VAConfig::hrirLength );
pFIRConvolverChL->SetFilterExchangeFadingFunction( ITABase::FadingFunction::COSINE_SQUARE );
pFIRConvolverChL->SetFilterCrossfadeLength( ( std::min )( VAConfig::blockLength, 32 ) );
pFIRConvolverChL->SetGain( 1.0f, true );
ITAUPFilter* pHRIRFilterChL = pFIRConvolverChL->RequestFilter();
pHRIRFilterChL->identity();
pFIRConvolverChL->ExchangeFilter( pHRIRFilterChL );
pFIRConvolverChL->ReleaseFilter( pHRIRFilterChL );
mFIRConvolversL.insert( std::pair< int, ITAUPConvolution* >( i, pFIRConvolverChL ) );
// initialize right channel convolver for each cluster
ITAUPConvolution* pFIRConvolverChR = new ITAUPConvolution( VAConfig::blockLength, VAConfig::hrirLength );
pFIRConvolverChR->SetFilterExchangeFadingFunction( ITABase::FadingFunction::COSINE_SQUARE );
pFIRConvolverChR->SetFilterCrossfadeLength( ( std::min )( VAConfig::blockLength, 32 ) );
pFIRConvolverChR->SetGain( 1.0f, true );
ITAUPFilter* pHRIRFilterChR = pFIRConvolverChR->RequestFilter();
pHRIRFilterChR->identity();
pFIRConvolverChR->ExchangeFilter( pHRIRFilterChR );
pFIRConvolverChR->ReleaseFilter( pHRIRFilterChR );
mFIRConvolversR.insert( std::pair< int, ITAUPConvolution* >( i, pFIRConvolverChR ) );
}
m_pCurState.reset( new CVABinauralClusteringState( m_iNumClusters, m_pReceiver, clusterPool, &mFIRConvolversL, &mFIRConvolversR ) );
m_pPrevState = m_pCurState;
}
ITASampleFrame* CVABinauralClustering::GetOutput()
{
m_pOutput->zero();
// swap out clustering state
if( m_pNextState != nullptr )
m_pCurState = m_pNextState;
std::map< int, CVABinauralClusteringDirection* >::const_iterator cit;
for( cit = m_pCurState->clusters.begin(); cit != m_pCurState->clusters.end(); ++cit )
{
CVABinauralClusteringDirection* pClusteringDirection( cit->second );
ITASampleFrame* pClusteringDirectionOutput = pClusteringDirection->GetOutput();
( *m_pOutput )[ 0 ] += ( *pClusteringDirectionOutput )[ 0 ];
( *m_pOutput )[ 1 ] += ( *pClusteringDirectionOutput )[ 1 ];
// *pOutput += *pClusteringDirectionOutput; // @todo jst: switch to this implementation
}
return m_pOutput;
}
void CVABinauralClustering::Update()
{
// if (_nextState == nullptr)
// {
//VABinauralClusteringState* state = new VABinauralClusteringState(_numClusters, _listener, clusterPool, FIRConvolversL, FIRConvolversR); //new VABinauralClusteringState(*m_pCurState);
//std::shared_ptr<VABinauralClusteringState> state = std::make_shared<VABinauralClusteringState>(*_prevState);
std::shared_ptr<CVABinauralClusteringState> state = std::make_shared<CVABinauralClusteringState>( m_iNumClusters, m_pReceiver, clusterPool, &mFIRConvolversL, &mFIRConvolversR );
// remove removed sources
std::set< int >::const_iterator it;
for( it = m_iDelWaveFrontIDs.begin(); it != m_iDelWaveFrontIDs.end(); ++it )
{
// remove if in unassigned sources
std::map< int, IVABinauralWaveFront* >::iterator delIt = m_mUnassignedWaveFronts.find( *it );
IVABinauralWaveFront* source = delIt->second;
state->removeSource( *it );
m_mUnassignedWaveFronts.erase( delIt );
// remove if in assigned sources
delIt = m_mAssignedWaveFronts.find( *it );
source = delIt->second;
m_mAssignedWaveFronts.erase( delIt );
}
// add unassigned sources
std::map< int, IVABinauralWaveFront* >::iterator sourceIt;
for( sourceIt = m_mUnassignedWaveFronts.begin(); sourceIt != m_mUnassignedWaveFronts.end(); ++sourceIt )
{
if( sourceIt->second->GetValidTrajectory() )
{
state->addSource( sourceIt->first, sourceIt->second, m_dDistanceThreshold, 0 );
}
}
// TODO: refinement
// update source status
/*for (auto const& unassignedSources : _unassignedSources)
{
_assignedSources.insert(std::pair< int, VABinauralSoundSource* >(assignedSources.first, assignedSources.second));
}*/
//_unassignedSources.clear();
m_pNextState = state;
m_pPrevState = m_pNextState;
// }
}
void CVABinauralClustering::PreRequest()
{
};
void CVABinauralClustering::PreRelease()
{
}
\ No newline at end of file
#ifndef IW_VACORE_BINAURALCLUSTERING
#define IW_VACORE_BINAURALCLUSTERING
#include <queue>
// VA Includes
#include <VA.h>
#include <VAPoolObject.h>
// Ita includes
#include <ITAUPConvolution.h>
// Utils
#include "VABinauralClusteringDirection.h"
#include "VABinauralClusteringState.h"
#include "../VABinauralTOAEstimator.h"
#include "../Receiver/VABinauralClusteringDirectionReceiver.h"
#include "../WaveFront/VABinauralWaveFront.h"
//! Binaural clustering engine providing directional clustering of wave fronts for binaural a sound receiver
/**
* Processes the output by gathering processing data from all linked wave fronts.
* Convolves the clustering direction by an HRIR set using an FIR filter engine, while
* individual wave fronts are expected to individually adjust the time-of-arrival from
* the difference to the clustering direction kernel (this instance).
*
*/
class CVABinauralClustering : public CVAPoolObject
{
public:
IVAObjectPool* clusterPool;
~CVABinauralClustering();
CVABinauralClustering();
//! Initialize clustering instance for a binaural receiver
void Init( int iReceiverID, CVABinauralClusteringDirectionReceiver* pReceiver, int iNumClusters );
//! Processes the audio stream and returns the calculated samples
ITASampleFrame* GetOutput();
void Update();
void AddWaveFront( int iWaveFrontID, IVABinauralWaveFront* pWaveFront );
void RemoveWaveFront( int iWaveFrontID );
std::map< int, ITAUPConvolution* > mFIRConvolversL;
std::map< int, ITAUPConvolution* > mFIRConvolversR;
private:
int m_iSoundReceiverID;
int m_iNumClusters; //!< Cluster budget (maximum number of usable clusters)
double m_dDistanceThreshold; //!< Threshold for clustering algorithm (abstract "distance"), see MA 2019 Msch
ITASampleFrame* m_pOutput;
CVABinauralClusteringDirectionReceiver* m_pReceiver;
std::set< int > m_iDelWaveFrontIDs;
std::shared_ptr< CVABinauralClusteringState > m_pCurState;
std::shared_ptr< CVABinauralClusteringState > m_pPrevState;
std::shared_ptr< CVABinauralClusteringState > m_pNextState;
std::map< int, IVABinauralWaveFront* > m_mUnassignedWaveFronts;
std::map< int, IVABinauralWaveFront* > m_mAssignedWaveFronts;
void PreRequest();
void PreRelease();
};
#endif // IW_VACORE_BINAURALCLUSTERING
#define NOMINMAX
#include <stdlib.h>
#include <math.h>
#include "VABinauralClusteringDirection.h"
// VA includes
#include "../../../../directivities/VADirectivityDAFFHRIR.h"
// ITA includes
#include <ITAUPFilter.h>
#include <ITAUPFilterPool.h>
#include <ITAConstants.h>
#include <ITAVariableDelayLine.h>
// Utils
#include "../VAConfig.h"
#include "../VARelationMetrics.h"
#include "../VABinauralTOAEstimator.h"
CVABinauralClusteringDirection::CVABinauralClusteringDirection()
: m_iLastHRIRIndex( -1 )
, m_pClusteringDirectionReceiver( NULL )
, m_pFIRConvolverChL( NULL )
, m_pFIRConvolverChR( NULL )
{
m_psfOutput = new ITASampleFrame( 2, VAConfig::blockLength, true );
m_psfTempHRIR = new ITASampleFrame( 2, VAConfig::hrirLength, true );
}
CVABinauralClusteringDirection::~CVABinauralClusteringDirection()
{}
void CVABinauralClusteringDirection::Init( int iID, IVABinauralWaveFront* pWaveFront, CVABinauralClusteringDirectionReceiver* pReceiver, ITAUPConvolution* pFIRConvolverChL, ITAUPConvolution* pFIRConvolverChR )
{
m_pClusteringDirectionReceiver = pReceiver;
m_v3ClusteringDirectionPos = pWaveFront->GetPosition() - pReceiver->v3PredictedPosition;
m_v3ClusteringDirectionPos.Norm();
m_pFIRConvolverChL = pFIRConvolverChL;
m_pFIRConvolverChR = pFIRConvolverChR;
int iOutputLength = pReceiver->pOutput->GetLength();
if( m_psfOutput->length() != iOutputLength )
m_psfOutput->init( 2, iOutputLength, true );
if( m_sbTempChL.length() != iOutputLength || m_sbTempChR.length() != iOutputLength )
{
m_sbTempChL.Init( iOutputLength, true );
m_sbTempChR.Init( iOutputLength, true );
}
dMaxError = GetDistError( pWaveFront );
m_mWaveFronts.insert( std::pair< int, IVABinauralWaveFront* >( iID, pWaveFront ) );
// --
pWaveFront->AddReference();
++iNumWaveFronts;
}
void CVABinauralClusteringDirection::Init( CVABinauralClusteringDirection* pClusterDirection )
{
m_pClusteringDirectionReceiver = pClusterDirection->m_pClusteringDirectionReceiver;
m_v3ClusteringDirectionPos = pClusterDirection->m_v3ClusteringDirectionPos;
const int iOutputLength = m_pClusteringDirectionReceiver->pOutput->GetLength();
if( m_psfOutput->length() != iOutputLength )
m_psfOutput->init( 2, iOutputLength, true );
m_sbTempChL.Init( m_pClusteringDirectionReceiver->pOutput->GetLength(), true );
m_sbTempChR.Init( m_pClusteringDirectionReceiver->pOutput->GetLength(), true );
iNumWaveFronts = 0;
}
ITASampleFrame* CVABinauralClusteringDirection::GetOutput()
{
// @todo jst: this methods seems to be messy, careful update is required
// Reset output buffer for this direction
m_psfOutput->zero();
// Get time-of-arrival for this clustering direction
VARelationMetrics oClusterSourceMetrics;
oClusterSourceMetrics.calc( m_pClusteringDirectionReceiver->v3PredictedPosition, m_pClusteringDirectionReceiver->predView, m_pClusteringDirectionReceiver->predUp, m_pClusteringDirectionReceiver->v3PredictedPosition + m_v3ClusteringDirectionPos );
// double toaHRTFChL = _listener->toaEstimator->getTOALeft(clusterSourceMetrics.phi, clusterSourceMetrics.theta);
// double toaHRTFChR = _listener->toaEstimator->getTOARight(clusterSourceMetrics.phi, clusterSourceMetrics.theta);
// @todo use listener orientation (quaternion?) to roate the ears in the global coordinate systems
double toaHRTFChL = m_pClusteringDirectionReceiver->pTimeOfArrivalEstimator->getTOA( VAVec3( -1, 0, 0 ), m_v3ClusteringDirectionPos );
double toaHRTFChR = m_pClusteringDirectionReceiver->pTimeOfArrivalEstimator->getTOA( VAVec3( 1, 0, 0 ), m_v3ClusteringDirectionPos );
// Process wave fronts connected to this clustering direction (binaurally)
std::map< int, IVABinauralWaveFront* >::const_iterator it;
for( it = m_mWaveFronts.begin(); it != m_mWaveFronts.end(); ++it )
{
IVABinauralWaveFront* pWaveFront( it->second );
pWaveFront->SetClusteringPose( m_v3ClusteringDirectionPos, m_pClusteringDirectionReceiver->predView, m_pClusteringDirectionReceiver->predUp ); //WARNING: THIS WAS CHANGED FROM PREVIOUS LINE
//pWaveFront->SetClusteringPose(m_pClusteringDirectionReceiver->v3PredictedPosition, m_pClusteringDirectionReceiver->predView, m_pClusteringDirectionReceiver->predUp);
pWaveFront->GetOutput( &( m_sbTempChL ), &( m_sbTempChR ) );
( *m_psfOutput )[ 0 ] += m_sbTempChL;
( *m_psfOutput )[ 1 ] += m_sbTempChR;
}
// Convolution of HRIR
CVADirectivityDAFFHRIR* pHRIR = ( CVADirectivityDAFFHRIR* ) m_pClusteringDirectionReceiver->pDirectivity;
if( pHRIR )
{
const int iHRIRFilterLength = pHRIR->GetProperties()->iFilterLength;
if( m_psfTempHRIR->GetLength() != iHRIRFilterLength )
m_psfTempHRIR->Init( 2, iHRIRFilterLength, false );
float fAzimuthDeg = ( float ) oClusterSourceMetrics.phi * 180 / ITAConstants::PI_F;
float fElevationDeg = ( float ) oClusterSourceMetrics.theta * 180 / ITAConstants::PI_F;
float fDistance = (float) oClusterSourceMetrics.dist;
int iIndex;
pHRIR->GetNearestNeighbour( fAzimuthDeg, fElevationDeg, &iIndex );
if( m_iLastHRIRIndex != iIndex )
{
pHRIR->GetHRIRByIndex( m_psfTempHRIR, iIndex, fDistance );
ITAUPFilter* pHRIRFilterChL = m_pFIRConvolverChL->GetFilterPool()->RequestFilter();
ITAUPFilter* pHRIRFilterChR = m_pFIRConvolverChR->GetFilterPool()->RequestFilter();
pHRIRFilterChL->Zeros();
pHRIRFilterChR->Zeros();
pHRIRFilterChL->Load( ( *m_psfTempHRIR )[ 0 ].data(), iHRIRFilterLength );
pHRIRFilterChR->Load( ( *m_psfTempHRIR )[ 1 ].data(), iHRIRFilterLength );
m_pFIRConvolverChL->ExchangeFilter( pHRIRFilterChL );
m_pFIRConvolverChR->ExchangeFilter( pHRIRFilterChR );
m_pFIRConvolverChL->ReleaseFilter( pHRIRFilterChL );
m_pFIRConvolverChR->ReleaseFilter( pHRIRFilterChR );
}
m_pFIRConvolverChL->Process( ( *m_psfOutput )[ 0 ].data(), ( *m_psfOutput )[ 0 ].data(), ITABase::MixingMethod::OVERWRITE );
m_pFIRConvolverChR->Process( ( *m_psfOutput )[ 1 ].data(), ( *m_psfOutput )[ 1 ].data(), ITABase::MixingMethod::OVERWRITE );
}
return m_psfOutput;
}
double CVABinauralClusteringDirection::GetDistError( IVABinauralWaveFront* pWaveFront )
{
VAVec3 v3WaveFrontEmissionPoseToClusteringDirectionPos = pWaveFront->GetPosition() - m_pClusteringDirectionReceiver->v3PredictedPosition;
v3WaveFrontEmissionPoseToClusteringDirectionPos.Norm();
VAVec3 v3Distance;
v3Distance = v3WaveFrontEmissionPoseToClusteringDirectionPos - m_v3ClusteringDirectionPos;
return v3Distance.Dot( v3Distance ); // Error metric = squared distance
}
void CVABinauralClusteringDirection::AddWaveFront( int iWaveFrontID, IVABinauralWaveFront* pWaveFront )
{
VAVec3 v3WaveFrontEmssissionPosToReceiverPos = pWaveFront->GetPosition() - m_v3ReceiverPos;
v3WaveFrontEmssissionPosToReceiverPos.Norm();
m_v3ClusteringDirectionPos = m_v3ClusteringDirectionPos + ( v3WaveFrontEmssissionPosToReceiverPos - m_v3ClusteringDirectionPos ) / ( iNumWaveFronts + 1 );
m_v3ClusteringDirectionPos.Norm();
double dError = GetDistError( pWaveFront );
dMaxError = std::max( dError, dMaxError );
m_mWaveFronts.insert( std::pair<int, IVABinauralWaveFront*>( iWaveFrontID, pWaveFront ) );
// --
pWaveFront->AddReference();
++iNumWaveFronts;
}
void CVABinauralClusteringDirection::AddWaveFront( int iWaveFrontID, IVABinauralWaveFront* pWaveFront, double dError )
{
VAVec3 v3WaveFrontEmittingPosToReceiverPos = pWaveFront->GetPosition() - m_v3ReceiverPos;
v3WaveFrontEmittingPosToReceiverPos.Norm();
double dDistanceError = GetDistError( pWaveFront );
dMaxError = std::max( dDistanceError, dMaxError );
m_v3ClusteringDirectionPos = m_v3ClusteringDirectionPos + ( v3WaveFrontEmittingPosToReceiverPos - m_v3ClusteringDirectionPos ) / ( iNumWaveFronts + 1 );
m_v3ClusteringDirectionPos.Norm(); // Projected to unity sphere ...
m_v3ClusteringDirectionToReceiverPos = m_v3ClusteringDirectionPos - m_v3ReceiverPos;
m_mWaveFronts.insert( std::pair<int, IVABinauralWaveFront*>( iWaveFrontID, pWaveFront ) );
// --
pWaveFront->AddReference();
++iNumWaveFronts;
}
void CVABinauralClusteringDirection::RemoveWaveFront( int iWaveFrontID )
{
std::map< int, IVABinauralWaveFront* >::const_iterator it = m_mWaveFronts.find( iWaveFrontID );
IVABinauralWaveFront* pWaveFront = it->second;
m_mWaveFronts.erase( it );
pWaveFront->RemoveReference();
m_v3ClusteringDirectionPos = ( m_v3ClusteringDirectionPos * iNumWaveFronts - pWaveFront->GetPosition() ) / ( iNumWaveFronts - 1 );
//TODO: MaxError
--iNumWaveFronts;
}
void CVABinauralClusteringDirection::PreRelease()
{
IVABinauralWaveFront* pWaveFront;
std::map< int, IVABinauralWaveFront* >::const_iterator it;
// clear all references from this cluster
for( it = m_mWaveFronts.begin(); it != m_mWaveFronts.end(); )
{
pWaveFront = it->second;
it = m_mWaveFronts.erase( it );
pWaveFront->RemoveReference();
}
}
#ifndef IW_VACORE_BINAURAL_CLUSTERING_DIRECTION
#define IW_VACORE_BINAURAL_CLUSTERING_DIRECTION
// VA Includes
#include <VA.h>
// ITA includes
#include <ITAUPConvolution.h>
// Utils
#include "../WaveFront/VABinauralWaveFront.h"
#include "../Receiver/VABinauralClusteringDirectionReceiver.h"
//! Class representing a binaural clustering direction that combines and processes multiple incident wave fronts in the sector of the direction
/**
* The GetOutput method subsequently processes all linked wave fronts / propagation paths
*
*/
class CVABinauralClusteringDirection : public CVAPoolObject
{
public:
int iNumWaveFronts;
double dMaxError;
CVABinauralClusteringDirection();
~CVABinauralClusteringDirection();
void Init( int iID, IVABinauralWaveFront* pWaveFront, CVABinauralClusteringDirectionReceiver* pClusteringDirectionReceiver, ITAUPConvolution* pFIRRight, ITAUPConvolution* pFIRLeft );
void Init( CVABinauralClusteringDirection* pClusteringDirection );
ITASampleFrame* GetOutput();
double GetDistError( IVABinauralWaveFront* pWaveFront );
void AddWaveFront( int iID, IVABinauralWaveFront* pWaveFront );
void AddWaveFront( int iID, IVABinauralWaveFront* pWaveFront, double dError ); // @todo jst: appears to be unused, confirm
void RemoveWaveFront( int iID );
void Reset();
void PreRelease();
private:
ITASampleBuffer m_sbTempChL;
ITASampleBuffer m_sbTempChR;
ITASampleFrame* m_psfOutput;
ITASampleFrame* m_psfTempHRIR;
CVABinauralClusteringDirectionReceiver* m_pClusteringDirectionReceiver; // Receiver instance connected to this clustering direction (principle direction)
ITAUPConvolution* m_pFIRConvolverChL;
ITAUPConvolution* m_pFIRConvolverChR;
VAVec3 m_v3ReceiverPos;
VAVec3 m_v3ClusteringDirectionPos; // Target position of the clustering direction projected to the unity sphere around receiver ( norm == 1 )
VAVec3 m_v3ClusteringDirectionToReceiverPos;
std::map< int, IVABinauralWaveFront* > m_mWaveFronts;
int m_iLastHRIRIndex;
double CummulativeMovingAverage( int n, double average, double value );
};
#endif // IW_VACORE_BINAURAL_CLUSTERING_DIRECTION
#include "VABinauralClusteringDirectionPoolFactory.h"
#include "VABinauralClusteringDirection.h"
CVABinauralClusteringDirectionPoolFactory::CVABinauralClusteringDirectionPoolFactory()
{
}
CVABinauralClusteringDirectionPoolFactory::~CVABinauralClusteringDirectionPoolFactory()
{
}
CVAPoolObject* CVABinauralClusteringDirectionPoolFactory::CreatePoolObject()
{
return new CVABinauralClusteringDirection();
}
#ifndef IW_VACORE_BINAURAL_CLUSTERING_DIRECTION_POOL_FACTORY
#define IW_VACORE_BINAURAL_CLUSTERING_DIRECTION_POOL_FACTORY
// VA Includes
#include <VA.h>
#include <VAPoolObject.h>
//! Clustering direction pool factory
/**
*
*/
class CVABinauralClusteringDirectionPoolFactory : public IVAPoolObjectFactory
{
public:
CVABinauralClusteringDirectionPoolFactory();
~CVABinauralClusteringDirectionPoolFactory();
CVAPoolObject* CreatePoolObject();
};
#endif // IW_VACORE_BINAURAL_CLUSTERING_DIRECTION_POOL_FACTORY
#include "VABinauralClusteringEngine.h"
#include "VABinauralClusteringPoolFactory.h"
// VA includes
#include <VAObjectPool.h>
CVABinauralClusteringEngine::CVABinauralClusteringEngine()
{
IVAPoolObjectFactory* clusteringFactory = new CVABinauralClusteringPoolFactory();
m_pClusteringPool = IVAObjectPool::Create( 16, 2, clusteringFactory, true );
}
CVABinauralClusteringEngine::~CVABinauralClusteringEngine()
{
}
void CVABinauralClusteringEngine::Update()
{
for( auto const& clustering : m_mClusteringInstances )
{
clustering.second->Update();
}
}
CVABinauralClustering* CVABinauralClusteringEngine::GetClustering( const int iReceiverID )
{
const int id = iReceiverID;
auto it = m_mClusteringInstances.find( id );
return it->second;
}
void CVABinauralClusteringEngine::AddWaveFront( int sourceID, IVABinauralWaveFront* source )
{
std::map< int, CVABinauralClustering* >::iterator it;
for( it = m_mClusteringInstances.begin(); it != m_mClusteringInstances.end(); ++it )
{
it->second->AddWaveFront( sourceID, source );