Commit fd01c5fc authored by lmoesch's avatar lmoesch

Added relation metrics and HRTF TOA substraction.

parent 32449d41
......@@ -3,7 +3,11 @@
#include <math.h>
#include "VABinauralCluster.h"
// ITA includes
#include <ITAConstants.h>
// Utils
#include "../RelationMetrics/VARelationMetrics.h"
#include "../BinauralTimeOfArrivalEstimator/VABinauralTOAEstimator.h"
VABinauralCluster::VABinauralCluster()
......@@ -88,6 +92,13 @@ VABinauralCluster::getOutput()
// reset output Buffer
_output->zero();
// get cluster HRTF TOA
VARelationMetrics clusterSourceMetrics;
clusterSourceMetrics.calc(_listener->predPos, _listener->predView, _listener->predUp, _clusterSourcePos);
double toaHRTFChL = _listener->toaEstimator->getTOALeft(clusterSourceMetrics.phi, clusterSourceMetrics.theta);
double toaHRTFChR = _listener->toaEstimator->getTOARight(clusterSourceMetrics.phi, clusterSourceMetrics.theta);
// set VDL Values
std::map<int, VABinauralSoundSource*>::const_iterator it;
for (it = _sources.begin(); it != _sources.end(); ++it)
......@@ -95,18 +106,16 @@ VABinauralCluster::getOutput()
VABinauralSoundSource* source = it->second;
const ITASampleBuffer* input = source->data->pSignalSourceInputBuf;
VAVec3 sourceToListenerPos = source->predPos - _listenerPos;
sourceToListenerPos.Norm();
VARelationMetrics sourceMetrics;
sourceMetrics.calc(_listener->predPos, _listener->predView, _listener->predUp, source->predPos);
double phi = atan2(sourceToListenerPos.y, sourceToListenerPos.x);
double theta = acos(sourceToListenerPos.z);
double toaDistance = sourceMetrics.dist / 343; // TODO: Medium Propagation....
//TODO: add general distance VDL
double toaChL = _listener->toaEstimator->getTOALeft(phi, theta);
double toaChR = _listener->toaEstimator->getTOARight(phi, theta);
double toaSourceChL = _listener->toaEstimator->getTOALeft(sourceMetrics.phi, sourceMetrics.theta);
double toSourceaChR = _listener->toaEstimator->getTOARight(sourceMetrics.phi, sourceMetrics.theta);
source->vdlChL->SetDelayTime(toaChL);
source->vdlChR->SetDelayTime(toaChR);
source->vdlChL->SetDelayTime(toaDistance + toaSourceChL - toaHRTFChL);
source->vdlChR->SetDelayTime(toaDistance + toSourceaChR - toaHRTFChR);
source->vdlChL->Process(input, &(_tmpChL));
source->vdlChR->Process(input, &(_tmpChR));
......@@ -115,7 +124,7 @@ VABinauralCluster::getOutput()
(*_output)[1] += _tmpChR;
}
// convolve
// convolve here!
return _output;
}
......
#include "VARelationMetrics.h"
VARelationMetrics::VARelationMetrics()
{
}
VARelationMetrics::~VARelationMetrics()
{
}
void
VARelationMetrics::calc(const VAVec3& sourcePos, const VAVec3& sourceView, const VAVec3& sourceUp, const VAVec3& targetPos)
{
VAVec3 relTargetPos = targetPos - sourcePos;
VAVec3 sourceViewMinusZ = sourceView * (-1.0f);
VAVec3 sourceRight = sourceViewMinusZ.Cross(sourceUp);
dist = relTargetPos.Length();
relTargetPos = relTargetPos / dist;
phi = atan2(relTargetPos.Dot(sourceRight), relTargetPos.Dot(sourceViewMinusZ));
theta = asin(relTargetPos.Dot(sourceUp));
}
#ifndef IW_VACORE_RELATIONMETRICS
#define IW_VACORE_RELATIONMETRICS
// VA Includes
#include <VA.h>
class VARelationMetrics
{
public:
double theta;
double phi;
double dist;
VARelationMetrics();
~VARelationMetrics();
void
calc(const VAVec3& sourcePos, const VAVec3& sourceView, const VAVec3& sourceUp, const VAVec3& targetPos);
};
#endif \\ IW_VACORE_RELATIONMETRICS
\ No newline at end of file
# $Id:$
set( RelativeDir "src/Rendering/Binaural/RealTime/Utils/RelationMetrics" )
set( RelativeSourceGroup "Source Files\\Rendering\\Binaural\\Realtime\\Utils\\RelationMetrics" )
set( DirFiles
VARelationMetrics.cpp
VARelationMetrics.h
_SourceFiles.cmake
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
......@@ -2,7 +2,7 @@
set( RelativeDir "src/Rendering/Binaural/Realtime/Utils" )
set( RelativeSourceGroup "Source Files\\Rendering\\Binaural\\Realtime\\Utils" )
set( SubDirs BinauralListener BinauralClusterEngine BinauralSoundSource BinauralTimeOfArrivalEstimator)
set( SubDirs BinauralListener BinauralClusterEngine BinauralSoundSource BinauralTimeOfArrivalEstimator RelationMetrics)
set( DirFiles
_SourceFiles.cmake
......
......@@ -276,7 +276,6 @@ double GetElevationOnTarget_DEG( const VAVec3& vOriginPos, const VAVec3& vView,
{
VAVec3 vDir = vTargetPos - vOriginPos;
vDir.Norm();
const VAVec3 vRight = vView.Cross( vUp );
const double dElevationAngleDeg = asin( vDir.Dot( vUp ) ) * 180.0f / ITAConstants::PI_D;
return dElevationAngleDeg;
}
......
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