Commit 2ab5d6f6 authored by Lucas Moesch's avatar Lucas Moesch

WIP

parent 80371cda
......@@ -18,11 +18,13 @@ VABinauralCluster::~VABinauralCluster()
}
void
VABinauralCluster::init(VABinauralSoundSource* source)
VABinauralCluster::init(int sourceID, VABinauralSoundSource* source)
{
_clusterSourcePos = _clusterSourcePos + source->predPos;
maxError = getDistError(source);
_sources.insert(std::pair<int, VABinauralSoundSource*>(sourceID, source));
++_numSources;
}
......@@ -35,13 +37,15 @@ VABinauralCluster::getDistError(VABinauralSoundSource* source)
}
void
VABinauralCluster::addSource(VABinauralSoundSource* source)
VABinauralCluster::addSource(int sourceID, VABinauralSoundSource* source)
{
double err = getDistError(source);
_clusterSourcePos = (source->predPos + _clusterSourcePos * _numSources) / (_numSources + 1);
maxError = std::max(err, maxError);
_sources.insert(std::pair<int, VABinauralSoundSource*>(sourceID, source));
++_numSources;
}
......
......@@ -20,13 +20,13 @@ public:
~VABinauralCluster();
void
init(VABinauralSoundSource* source);
init(int sourceID, VABinauralSoundSource* source);
double
getDistError(VABinauralSoundSource* source);
void
addSource(VABinauralSoundSource* source);
addSource(int sourceID, VABinauralSoundSource* source);
void
addSource(VABinauralSoundSource* source, double error);
......@@ -39,6 +39,7 @@ public:
private:
int _numSources;
std::map<int, VABinauralSoundSource* > _sources;
VAVec3 _clusterSourcePos;
......
......@@ -35,10 +35,17 @@ VABinauralClustering::init(int listenerID, VABinauralListener* listener, int num
_threshold = cos(180. / numClusters) * cos(180. / numClusters);
}
VABinauralClustering::binauralOutput_t
VABinauralClustering::getOutput()
{
_curState.reset(_nextState.release());
}
void
VABinauralClustering::update()
{
VABinauralClusteringState* state = new VABinauralClusteringState(*_clustering);
VABinauralClusteringState* state = new VABinauralClusteringState(*_curState);
//VABinauralClusteringState* del = _newState;
// update unassigned sources
std::map< int , VABinauralSoundSource* >::iterator it;
......@@ -56,6 +63,8 @@ VABinauralClustering::update()
_unassignedSources.clear();
_nextState.reset(state);
// TODO: update fixed clustertrajectories
}
......
......@@ -16,6 +16,11 @@
class VABinauralClustering : public CVAPoolObject
{
public:
struct binauralOutput_t {
ITASampleBuffer outputChL;
ITASampleBuffer outputChR;
};
~VABinauralClustering();
VABinauralClustering();
......@@ -23,6 +28,9 @@ public:
void
init(int listenerID, VABinauralListener* listener, int numClusters);
binauralOutput_t
getOutput();
void
update();
......@@ -35,7 +43,9 @@ private:
int _numClusters;
double _threshold;
VABinauralClusteringState* _clustering;
std::unique_ptr<VABinauralClusteringState> _curState;
std::unique_ptr<VABinauralClusteringState> _nextState;
VABinauralListener* _listener;
IVAObjectPool* _clusterPool;
......
......@@ -62,7 +62,7 @@ VABinauralClusteringState::addSource(int sourceID, VABinauralSoundSource* source
if ((minerr > threshold) && (numFreeClusters > 0))
{
std::pair< int, VABinauralCluster*> p;
p = createCluster(source);
p = createCluster(sourceID, source);
nearestClusterID = p.first;
nearestCluster = p.second;
......@@ -73,12 +73,12 @@ VABinauralClusteringState::addSource(int sourceID, VABinauralSoundSource* source
}
std::pair< int, VABinauralCluster*>
VABinauralClusteringState::createCluster(VABinauralSoundSource* source)
VABinauralClusteringState::createCluster(int sourceID, VABinauralSoundSource* source)
{
int clusterID = freeClusterIDs.back();
VABinauralCluster* cluster = dynamic_cast< VABinauralCluster* >(_clusterPool->RequestObject()); // Reference = 1
cluster->init(source);
cluster->init(sourceID, source);
clusters.insert(std::pair< int, VABinauralCluster* >(clusterID, cluster));
freeClusterIDs.pop();
......
......@@ -30,7 +30,7 @@ public:
addSource(int sourceID, VABinauralSoundSource* source, double threshold, int numBlockedClusters);
std::pair< int, VABinauralCluster*>
createCluster(VABinauralSoundSource* source);
createCluster(int sourceID, VABinauralSoundSource* source);
double getMaxError();
......
#include "VABinauralSoundSource.h"
VABinauralSoundSource::VABinauralSoundSource(const config_t& conf)
: _conf( conf )
{}
VABinauralSoundSource::VABinauralSoundSource(const config_t& conf) :
_conf( conf )
{
vdlChL = new CITAVariableDelayLine(_conf.sampleRate, _conf.blockLength, 3. * _conf.sampleRate, CITAVariableDelayLine::CUBIC_SPLINE_INTERPOLATION);
vdlChR = new CITAVariableDelayLine(_conf.sampleRate, _conf.blockLength, 3. * _conf.sampleRate, CITAVariableDelayLine::CUBIC_SPLINE_INTERPOLATION);
}
VABinauralSoundSource::~VABinauralSoundSource()
......@@ -13,15 +16,15 @@ VABinauralSoundSource::~VABinauralSoundSource()
void
VABinauralSoundSource::PreRequest()
{
CVABasicMotionModel::Config listenerMotionConf;
CVABasicMotionModel::Config sourceMotionConf;
listenerMotionConf.bLogEstimatedOutputEnabled = _conf.motionModelLogEstimated;
listenerMotionConf.bLogInputEnabled = _conf.motionModelLogInput;
listenerMotionConf.dWindowDelay = _conf.motionModelWindowDelay;
listenerMotionConf.dWindowSize = _conf.motionModelWindowSize;
listenerMotionConf.iNumHistoryKeys = _conf.motionModelNumHistoryKeys;
sourceMotionConf.bLogEstimatedOutputEnabled = _conf.motionModelLogEstimated;
sourceMotionConf.bLogInputEnabled = _conf.motionModelLogInput;
sourceMotionConf.dWindowDelay = _conf.motionModelWindowDelay;
sourceMotionConf.dWindowSize = _conf.motionModelWindowSize;
sourceMotionConf.iNumHistoryKeys = _conf.motionModelNumHistoryKeys;
motionModel = new CVASharedMotionModel(new CVABasicMotionModel(listenerMotionConf), true);
motionModel = new CVASharedMotionModel(new CVABasicMotionModel(sourceMotionConf), true);
data = nullptr;
}
......
......@@ -9,6 +9,9 @@
#include "../../../../../Motion/VASharedMotionModel.h"
#include "../../../../../Scene/VAScene.h"
// ITA includes
#include <ITAVariableDelayLine.h>
class VABinauralSoundSource : public CVAPoolObject
{
public:
......@@ -20,10 +23,15 @@ public:
double motionModelWindowDelay;
int motionModelNumHistoryKeys;
double sampleRate;
int blockLength;
};
CVASoundSourceDesc* data;
CVASharedMotionModel* motionModel;
CITAVariableDelayLine* vdlChL;
CITAVariableDelayLine* vdlChR;
VAVec3 predPos;
VAVec3 prefView;
......
......@@ -11,6 +11,8 @@
// ITA includes
#include <ITAException.h>
#include <ITAFastMath.h>
#include <ITAStreamInfo.h>
#include <ITAVariableDelayLine.h>
// Utils
......@@ -92,12 +94,28 @@ VABinauralRealTimeRenderer::init( const CVAStruct& oArgs )
if ((_defaultSourceConf.motionModelWindowSize <= 0) || (_defaultSourceConf.motionModelWindowDelay < 0))
VA_EXCEPT2(INVALID_PARAMETER, "Basic motion model window parameters parse error (zero or negative?)");
_defaultSourceConf.blockLength = GetBlocklength();
_defaultSourceConf.sampleRate = GetSampleRate();
}
void
VABinauralRealTimeRenderer::processStream(const ITAStreamInfo* streamInfo)
{
float* outputChL = GetWritePointer(0);
float* outputChR = GetWritePointer(1);
fm_zero(outputChL, GetBlocklength());
fm_zero(outputChR, GetBlocklength());
const CVAAudiostreamState* streamState = dynamic_cast< const CVAAudiostreamState* >(streamInfo);
double dListenerTime = streamState->dSysTime;
IncrementWritePointer();
return;
}
void
......@@ -122,12 +140,12 @@ VABinauralRealTimeRenderer::updateScene(CVASceneState* newSceneState)
updateSources(&diff);
}
/*
ITADatasource* VABinauralRealTimeRenderer::GetOutputDatasource()
{
return this;
}
*/
void
VABinauralRealTimeRenderer::updateSources( CVASceneStateDiff* diff )
......
......@@ -13,7 +13,7 @@
#include "./Utils/BinauralSoundSource/VABinauralSoundSource.h"
#include "./Utils/BinauralListener/VABinauralListener.h"
class VABinauralRealTimeRenderer : public IVAAudioRenderer, public CVAObject
class VABinauralRealTimeRenderer : public IVAAudioRenderer, public CVAObject, public ITADatasourceRealization
{
public:
VABinauralRealTimeRenderer( const CVAAudioRendererInitParams& );
......@@ -52,6 +52,8 @@ private:
VABinauralListener::config_t _defaultListenerConf; //!< Default listener config for factory object creation
VABinauralSoundSource::config_t _defaultSourceConf;
CVABFFUpdateMessage* _updateMessage;
int _defaultVDLSwitchingAlgorithm;
int _hrirFilterLength;
double _additionalStaticDelaySeconds;
......
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