From 32057179d27c40e019f3c96eff977a89d91ecb2d Mon Sep 17 00:00:00 2001 From: henryjandrew Date: Mon, 8 Jul 2019 18:21:41 +0200 Subject: [PATCH] Fixing some problems with VDL processing, now writing and incrementing. --- .../Engine/VABinauralClustering.cpp | 2 +- .../Engine/VABinauralClusteringDirection.cpp | 3 ++- .../VABinauralOutdoorNoiseAudioRenderer.cpp | 25 +++++++++++++++++-- .../VABinauralOutdoorWaveFront.cpp | 10 +++++++- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Rendering/Binaural/Clustering/Engine/VABinauralClustering.cpp b/src/Rendering/Binaural/Clustering/Engine/VABinauralClustering.cpp index 439ac18..0b9eaec 100644 --- a/src/Rendering/Binaural/Clustering/Engine/VABinauralClustering.cpp +++ b/src/Rendering/Binaural/Clustering/Engine/VABinauralClustering.cpp @@ -72,7 +72,7 @@ void CVABinauralClustering::Init( int iSoundReceiverID, CVABinauralClusteringDir pHRIRFilterChR->identity(); pFIRConvolverChR->ExchangeFilter( pHRIRFilterChR ); - pFIRConvolverChR->ReleaseFilter( ^pHRIRFilterChR ); + pFIRConvolverChR->ReleaseFilter( pHRIRFilterChR ); mFIRConvolversR.insert( std::pair< int, ITAUPConvolution* >( i, pFIRConvolverChR ) ); } diff --git a/src/Rendering/Binaural/Clustering/Engine/VABinauralClusteringDirection.cpp b/src/Rendering/Binaural/Clustering/Engine/VABinauralClusteringDirection.cpp index 62b2559..3975294 100644 --- a/src/Rendering/Binaural/Clustering/Engine/VABinauralClusteringDirection.cpp +++ b/src/Rendering/Binaural/Clustering/Engine/VABinauralClusteringDirection.cpp @@ -101,7 +101,8 @@ ITASampleFrame* CVABinauralClusteringDirection::GetOutput() { IVABinauralWaveFront* pWaveFront( it->second ); - pWaveFront->SetClusteringPose( m_pClusteringDirectionReceiver->v3PredictedPosition, m_pClusteringDirectionReceiver->predView, m_pClusteringDirectionReceiver->predUp ); + pWaveFront->SetClusteringPose( m_v3ClusteringDirectionPos, m_pClusteringDirectionReceiver->predView, m_pClusteringDirectionReceiver->predUp ); //WARNING: THIS WAS CHANGED FROM PREVIOUS LINE + //pWaveFront->SetClusteringPose(m_pClusteringDirectionReceiver->v3PredictedPosition, m_pClusteringDirectionReceiver->predView, m_pClusteringDirectionReceiver->predUp); pWaveFront->GetOutput( &( m_sbTempChL ), &( m_sbTempChR ) ); ( *m_psfOutput )[ 0 ] += m_sbTempChL; diff --git a/src/Rendering/Binaural/OutdoorNoise/VABinauralOutdoorNoiseAudioRenderer.cpp b/src/Rendering/Binaural/OutdoorNoise/VABinauralOutdoorNoiseAudioRenderer.cpp index 08ac594..cbbd596 100644 --- a/src/Rendering/Binaural/OutdoorNoise/VABinauralOutdoorNoiseAudioRenderer.cpp +++ b/src/Rendering/Binaural/OutdoorNoise/VABinauralOutdoorNoiseAudioRenderer.cpp @@ -1,5 +1,6 @@ #include "VABinauralOutdoorNoiseAudioRenderer.h" +#include #include #include #include @@ -21,12 +22,14 @@ // VA Core Includes #include "../../../Scene/VAScene.h" +#include "../../../Scene/VASoundSourceDesc.h" // ITA includes #include #include #include #include +#include // Utils #include "../Clustering/VAConfig.h" @@ -143,7 +146,7 @@ ITADatasource* CVABinauralOutdoorNoiseRenderer::GetOutputDatasource() void CVABinauralOutdoorNoiseRenderer::SetParameters(const CVAStruct& oInArgs) { - + auto it = oInArgs.Begin(); while (it != oInArgs.End()) { const CVAStructValue path_value = it->second; //extract data for the current path from the iterator in a useful form @@ -192,7 +195,8 @@ void CVABinauralOutdoorNoiseRenderer::SetParameters(const CVAStruct& oInArgs) double delay = path["delay"]; - m_mPaths[path_ID]->setDelay(delay); + int idelay = (int)round(delay * m_oDefaultWaveFrontConf.sampleRate); + m_mPaths[path_ID]->setDelay(idelay); CVAStructValue position = path["position"]; // @@ -265,6 +269,16 @@ CVABinauralOutdoorNoiseRenderer::ProcessStream( const ITAStreamInfo* streamInfo double time = streamState->dSysTime; //updateTrajectories(time); // @todo jst: why is this outcommented? Trajectories must be updated here for Doppler shifts ... + + // -- copy new samples from source' signal stream and feed the SIMO VDLs + for (auto oSource : m_mSources) + { + CVABinauralOutdoorSource* pSource = oSource.second; + CVASoundSourceDesc* pSourceDesc = pSource->pData; + const ITASampleBuffer* pInBuf = pSourceDesc->pSignalSourceInputBuf; + pSource->pVDL->Write(GetBlocklength(), pInBuf->GetData()); + } + // -- create output for every listener for( auto const& clusteringIt : m_pClusterEngine->m_mClusteringInstances ) { @@ -276,6 +290,13 @@ CVABinauralOutdoorNoiseRenderer::ProcessStream( const ITAStreamInfo* streamInfo fm_copy( outputChR, ( *output )[ 1 ].data(), m_uiBlocklength ); } + // -- copy new samples from source' signal stream and feed the SIMO VDLs + for (auto oSource : m_mSources) + { + CVABinauralOutdoorSource* pSource = oSource.second; + pSource->pVDL->Increment(GetBlocklength()); + } + #ifdef BINAURAL_CLUSTERING_RENDERER_WITH_BENCHMARKING // stop timer diff --git a/src/Rendering/Binaural/OutdoorNoise/VABinauralOutdoorWaveFront.cpp b/src/Rendering/Binaural/OutdoorNoise/VABinauralOutdoorWaveFront.cpp index 3db61d3..8648dfb 100644 --- a/src/Rendering/Binaural/OutdoorNoise/VABinauralOutdoorWaveFront.cpp +++ b/src/Rendering/Binaural/OutdoorNoise/VABinauralOutdoorWaveFront.cpp @@ -30,11 +30,13 @@ CVABinauralOutdoorWaveFront::CVABinauralOutdoorWaveFront( const CVABinauralOutdo tempBuffer.Init(oConf.BufferSize); //initialise the buffers to a size which will not be exceeded interpolatedSignal.Init(oConf.BufferSize); + + m_pInterpolationRoutine = new CITASampleLinearInterpolation(); } CVABinauralOutdoorWaveFront::~CVABinauralOutdoorWaveFront() { - + delete m_pInterpolationRoutine; } @@ -82,6 +84,7 @@ void CVABinauralOutdoorWaveFront::GetOutput( ITASampleBuffer* pfLeftChannel, ITA int toaClusterLeft = (int)round( sound_receiver->pTimeOfArrivalEstimator->getTOALeft(clusterMetrics.phi, clusterMetrics.theta) ); //the TOA difference for a signal coming from the specified angles for the left ear int toaClusterRight = (int)round(sound_receiver->pTimeOfArrivalEstimator->getTOARight(clusterMetrics.phi, clusterMetrics.theta)); //TODO: test if this works/ how accurate + VARelationMetrics pathMetrics; //get metrics about the current path pathMetrics.calc(v3PredictedPos, m_v3PredictedClusteringView, m_v3PredictedClusteringUp, v3ReceiverPos); //TODO: add these variables in setMotion NOTE: uses same view and up vectors as for cluster, I THINK this is ok int toaPathLeft = (int)round(sound_receiver->pTimeOfArrivalEstimator->getTOALeft(pathMetrics.phi, pathMetrics.theta)); //the TOA difference for a signal coming from the specified angles for the left ear @@ -91,6 +94,11 @@ void CVABinauralOutdoorWaveFront::GetOutput( ITASampleBuffer* pfLeftChannel, ITA ITD_diff_margin_left = toaPathLeft - toaClusterLeft; ITD_diff_margin_right = toaPathRight - toaClusterRight; + float test = sound_receiver->pTimeOfArrivalEstimator->getTOALeft(clusterMetrics.phi, clusterMetrics.theta) * oConf.sampleRate; + float test1 = sound_receiver->pTimeOfArrivalEstimator->getTOALeft(pathMetrics.phi, pathMetrics.theta) * oConf.sampleRate; + if (toaClusterLeft > 0) { + int test = 1; + } int iCurrentDelay = VDL->GetCurrentDelaySamples(iCursorID); //get current and new delay in samples int iNewDelay = VDL->GetNewDelaySamples(iCursorID); -- GitLab