VABinauralClustering.cpp 1.54 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 27 28 29 30 31 32 33 34 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 61 62 63 64 65 66
#define NOMINMAX

#include <limits>
#include <algorithm>

#include <math.h>

// VA
#include <VAObjectPool.h>

// Utils
#include "./VABinauralClustering.h"
#include "./VABinauralClusterPoolFactory.h"

VABinauralClustering::~VABinauralClustering()
{
	IVAPoolObjectFactory* clusterFactory = new VABinauralClusterPoolFactory();
	_clusterPool = IVAObjectPool::Create(16, 2, clusterFactory, true);
};

VABinauralClustering::VABinauralClustering(){};

void
VABinauralClustering::addSource(int sourceID, VABinauralSoundSource* source)
{
	_unassignedSources.insert(std::pair< int, VABinauralSoundSource* >(sourceID, source));
};

void
VABinauralClustering::init(int listenerID, VABinauralListener* listener, int numClusters)
{
	_listenerID = listenerID;
	_listener = listener;
	_numClusters = numClusters;
	_threshold = cos(180. / numClusters) * cos(180. / numClusters);
}

void
VABinauralClustering::update()
{
	VABinauralClusteringState* state = new VABinauralClusteringState(*_clustering);

	// update unassigned sources
	std::map< int , VABinauralSoundSource* >::iterator it;

	for (it = _unassignedSources.begin(); it != _unassignedSources.end(); ++it)
	{
		state->addSource(it->first, it->second, _threshold, 0);
	}

	// TODO: refinement
	for (it = _unassignedSources.begin(); it != _unassignedSources.end(); ++it)
	{
		_assignedSources.insert(std::pair< int, VABinauralSoundSource* >(it->first, it->second));
	}

	_unassignedSources.clear();

	// TODO: update fixed clustertrajectories
}

void
VABinauralClustering::PreRequest(){};

void
VABinauralClustering::PreRelease(){};