#define NOMINMAX #include #include #include // VA #include // 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); _output = new ITASampleFrame(2, listener->output->GetLength(), true); _curState.reset(new VABinauralClusteringState(_numClusters, _listener)); } ITASampleFrame* VABinauralClustering::getOutput() { // -- _output->zero(); // swap out clustering state _curState.reset(_nextState.release()); //TODO: only if next State is not null! std::map< int, VABinauralCluster*>::const_iterator it; for (it = _curState->clusters.begin(); it != _curState->clusters.end(); ++it) { ITASampleFrame* clusterOutput = it->second->getOutput(); (*_output)[0] += (*clusterOutput)[0]; (*_output)[1] += (*clusterOutput)[1]; } return _output; } void VABinauralClustering::update() { VABinauralClusteringState* state = new VABinauralClusteringState(*_curState); //VABinauralClusteringState* del = _newState; // 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(); _nextState.reset(state); // TODO: update fixed clustertrajectories } void VABinauralClustering::PreRequest(){}; void VABinauralClustering::PreRelease(){};