VABinauralClusterEngine.cpp 1.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#include "VABinauralClusterEngine.h"

// VA includes
#include <VAObjectPool.h>


VABinauralClusterEngine::VABinauralClusterEngine()
{

}


VABinauralClusterEngine::~VABinauralClusterEngine()
{
}

void
VABinauralClusterEngine::update()
{
	std::map< int, VABinauralClustering* >::iterator it;
	for (it = _clusterings.begin(); it != _clusterings.end(); ++it)
	{
		it->second->update();
	}
}

27 28 29 30 31 32 33 34
VABinauralClustering*
VABinauralClusterEngine::getClustering(int listenerID)
{
	std::map< int, VABinauralClustering* >::iterator it = _clusterings.find(listenerID);

	return it->second;
}

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
void
VABinauralClusterEngine::addSource( int sourceID, VABinauralSoundSource* source )
{
	std::map< int, VABinauralClustering* >::iterator it;
	for (it = _clusterings.begin(); it != _clusterings.end(); ++it)
	{
		it->second->addSource(sourceID, source);
	}
}

void 
VABinauralClusterEngine::addListener(int listenerID, VABinauralListener* listener, clusterConfig_t& conf)
{
	VABinauralClustering* clustering = dynamic_cast< VABinauralClustering* >(_clusteringPool->RequestObject()); // Reference = 1

	clustering->init(listenerID, listener, conf.numCluster);

	// add local reference
	_clusterings.insert(std::pair< int, VABinauralClustering* >(listenerID, clustering));

}

void
VABinauralClusterEngine::removeListener(int listenerID)
{
	std::map< int, VABinauralClustering* >::iterator it = _clusterings.find(listenerID);
61
	VABinauralClustering* clustering = it->second;
62 63
	_clusterings.erase(it);

64 65
	clustering->RemoveReference();

66 67 68 69
	/*
		TODO: foreach cluster in CL delete cluster
	*/
}