Commit 32449d41 authored by Lucas Moesch's avatar Lucas Moesch

WIP - fixing bugs

parent 172dbc8c
......@@ -34,9 +34,11 @@ VABinauralClusterEngine::update()
}
VABinauralClustering*
VABinauralClusterEngine::getClustering(int listenerID)
VABinauralClusterEngine::getClustering(const int listenerID)
{
std::map< int, VABinauralClustering* >::iterator it = _clusterings.find(listenerID);
const int id = listenerID;
auto it = _clusterings.find(id);
return it->second;
}
......@@ -49,6 +51,8 @@ VABinauralClusterEngine::addSource( int sourceID, VABinauralSoundSource* source
{
it->second->addSource(sourceID, source);
}
_sources.insert(std::pair< int, VABinauralSoundSource* >(sourceID, source));
}
void
......@@ -70,7 +74,13 @@ VABinauralClusterEngine::addListener(int listenerID, VABinauralListener* listene
// add local reference
_clusterings.insert(std::pair< int, VABinauralClustering* >(listenerID, clustering));
_listeners.insert(std::pair< int, VABinauralListener* >(listenerID, listener));
// add preexisting sources
for (auto const& sourceIt : _sources)
{
clustering->addSource(sourceIt.first, sourceIt.second);
}
}
void
......
......@@ -21,6 +21,8 @@ public:
int numCluster;
};
std::map< int, VABinauralClustering* > _clusterings;
~VABinauralClusterEngine();
VABinauralClusterEngine();
......@@ -29,7 +31,7 @@ public:
update();
VABinauralClustering*
getClustering(int listenerID);
getClustering(const int listenerID);
void
addSource( int sourceID, VABinauralSoundSource* source );
......@@ -45,13 +47,12 @@ public:
private:
std::map< int, VABinauralSoundSource* > _newSources;
std::map< int, VABinauralClustering* > _clusterings;
IVAObjectPool* _sourcePool;
IVAObjectPool* _clusteringPool;
//std::map< int, VABinauralSoundSource* > _sources;
//std::map< int, VABinauralListener* > _listener;
std::map< int, VABinauralSoundSource* > _sources;
std::map< int, VABinauralListener* > _listeners;
};
......
......@@ -69,49 +69,56 @@ VABinauralClustering::getOutput()
void
VABinauralClustering::update()
{
VABinauralClusteringState* state = new VABinauralClusteringState(*_curState);
//TODO: DIRTY HACK
// remove removed sources
std::set< int >::const_iterator it;
for (it = _delSourceIDs.begin(); it != _delSourceIDs.end(); ++it)
if (_nextState == nullptr)
{
// remove if in unassigned sources
std::map< int, VABinauralSoundSource* >::iterator delIt = _unassignedSources.find(*it);
VABinauralSoundSource* source = delIt->second;
state->removeSource(*it);
VABinauralClusteringState* state = new VABinauralClusteringState(*_curState);
_unassignedSources.erase(delIt);
// remove removed sources
std::set< int >::const_iterator it;
// remove if in assigned sources
delIt = _assignedSources.find(*it);
source = delIt->second;
for (it = _delSourceIDs.begin(); it != _delSourceIDs.end(); ++it)
{
// remove if in unassigned sources
std::map< int, VABinauralSoundSource* >::iterator delIt = _unassignedSources.find(*it);
VABinauralSoundSource* source = delIt->second;
_assignedSources.erase(delIt);
}
state->removeSource(*it);
// add unassigned sources
std::map< int , VABinauralSoundSource* >::iterator sourceIt;
_unassignedSources.erase(delIt);
for (sourceIt = _unassignedSources.begin(); sourceIt != _unassignedSources.end(); ++sourceIt)
{
state->addSource(sourceIt->first, sourceIt->second, _threshold, 0);
}
// remove if in assigned sources
delIt = _assignedSources.find(*it);
source = delIt->second;
// TODO: refinement
_assignedSources.erase(delIt);
}
// update source status
for (auto const& assignedSources: _assignedSources)
{
_assignedSources.insert(std::pair< int, VABinauralSoundSource* >(assignedSources.first, assignedSources.second));
}
// add unassigned sources
std::map< int, VABinauralSoundSource* >::iterator sourceIt;
_unassignedSources.clear();
for (sourceIt = _unassignedSources.begin(); sourceIt != _unassignedSources.end(); ++sourceIt)
{
state->addSource(sourceIt->first, sourceIt->second, _threshold, 0);
}
_nextState.reset(state);
// TODO: refinement
// TODO: update fixed clustertrajectories
// update source status
for (auto const& assignedSources : _assignedSources)
{
_assignedSources.insert(std::pair< int, VABinauralSoundSource* >(assignedSources.first, assignedSources.second));
}
_unassignedSources.clear();
_nextState.reset(state);
// TODO: update fixed clustertrajectories
}
}
void
......
......@@ -28,12 +28,13 @@ public:
int motionModelNumHistoryKeys;
};
bool hasValidTrajectory;
CVAListenerDesc* data;
CVASharedMotionModel* motionModel;
VAVec3 predPos;
VAVec3 prefView;
VAVec3 predView;
VAVec3 predUp;
ITASampleFrame* output;
......
......@@ -146,7 +146,7 @@ VABinauralRealTimeRenderer::ProcessStream(const ITAStreamInfo* streamInfo)
updateTrajectories(time);
// -- create output for every listener
std::map< int, VABinauralListener* >::const_iterator it;
/* std::map< int, VABinauralListener* >::const_iterator it;
for (it = _listeners.begin(); it != _listeners.end(); ++it)
{
VABinauralClustering* clustering = _clusterEngine.getClustering(it->first);
......@@ -157,6 +157,17 @@ VABinauralRealTimeRenderer::ProcessStream(const ITAStreamInfo* streamInfo)
fm_copy(outputChL, (*output)[0].data(), m_uiBlocklength);
fm_copy(outputChR, (*output)[1].data(), m_uiBlocklength);
}
} */
// TEST
for (auto const& clusteringIt : _clusterEngine._clusterings)
{
VABinauralClustering* clustering = clusteringIt.second;
output = clustering->getOutput();
fm_copy(outputChL, (*output)[0].data(), m_uiBlocklength);
fm_copy(outputChR, (*output)[1].data(), m_uiBlocklength);
}
IncrementWritePointer();
......@@ -184,6 +195,12 @@ VABinauralRealTimeRenderer::UpdateScene(CVASceneState* newSceneState)
// update sources
updateSources(&diff);
// Alte Szene freigeben (dereferenzieren)
if (_curSceneState) _curSceneState->RemoveReference();
_curSceneState = _newSceneState;
_newSceneState = nullptr;
}
/*
......@@ -273,6 +290,7 @@ VABinauralRealTimeRenderer::updateListeners( CVASceneStateDiff* diff )
}
}
_clusterEngine.update();
}
void
......@@ -372,15 +390,27 @@ void VABinauralRealTimeRenderer::updateMotionStates()
void
VABinauralRealTimeRenderer::updateTrajectories( double time )
{
std::map<int, VABinauralSoundSource*>::iterator it;
for ( it=_sources.begin(); it != _sources.end(); ++it)
for (auto const& sourceIt: _sources)
{
bool isValid = true;
VABinauralSoundSource* source = it->second;
VABinauralSoundSource* source = sourceIt.second;
source->motionModel->HandleMotionKeys();
isValid &= source->motionModel->EstimatePosition(time, source->predPos);
isValid &= source->motionModel->EstimateOrientation(time, source->predView, source->predUp);
source->hasValidTrajectory = isValid;
}
for (auto const& listenerIt: _listeners)
{
bool isValid = true;
VABinauralListener* listener = listenerIt.second;
listener->motionModel->HandleMotionKeys();
isValid &= listener->motionModel->EstimatePosition(time, listener->predPos);
isValid &= listener->motionModel->EstimateOrientation(time, listener->predView, listener->predUp);
listener->hasValidTrajectory = isValid;
}
}
......@@ -73,8 +73,8 @@ int main( int, char** )
{
try
{
//va = VACore::CreateCoreInstance( "../conf/VACore.ini" );
va = VACore::CreateCoreInstance( GetCoreConfig() );
va = VACore::CreateCoreInstance( "../conf/VACore.ini" );
//va = VACore::CreateCoreInstance( GetCoreConfig() );
// Attach (register) event handler
//va->AttachEventHandler( &dumper );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment