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

WIP - fixing bugs

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