Adding benchmark lines and fixing problems with binaural outdoor noise renderer

parent 61ad1df4
......@@ -113,7 +113,7 @@ if( NOT DEFINED ITA_RAVEN_DATA_PATH )
endif( )
# drivers
# Drivers
if( NOT DEFINED ITA_VACORE_WITH_AUDIO_BACKEND_ASIO )
set( ITA_VACORE_WITH_AUDIO_BACKEND_ASIO ON CACHE BOOL "Build VACore with ASIO audio backend support" )
endif( )
......@@ -131,6 +131,11 @@ if( NOT DEFINED ITA_VACORE_REPRODUCTION_NCTC_WITH_SWEET_SPOT_WIDENING )
endif( )
# Benchmarking
if( NOT DEFINED ITA_VACORE_BINAURAL_OUTDOOR_NOISE_INSOURCE_BENCHMARKS )
set( ITA_VACORE_BINAURAL_OUTDOOR_NOISE_INSOURCE_BENCHMARKS OFF CACHE BOOL "Enable in-source benchmarking for binaural outdoor noise renderer" )
endif( )
# Rendering modules
......@@ -156,9 +161,6 @@ if( NOT DEFINED ITA_VACORE_WITH_RENDERER_BINAURAL_AIR_TRAFFIC_NOISE )
endif( )
if( NOT DEFINED ITA_VACORE_WITH_RENDERER_BINAURAL_OUTDOOR_NOISE )
set( ITA_VACORE_WITH_RENDERER_BINAURAL_OUTDOOR_NOISE OFF CACHE BOOL "Build VACore with rendering module: outdoor noise" )
if( NOT DEFINED ITA_VACORE_BINAURAL_OUTDOOR_NOISE_INSOURCE_BENCHMARKS )
set( ITA_VACORE_BINAURAL_OUTDOOR_NOISE_INSOURCE_BENCHMARKS OFF CACHE BOOL "Enable in-source benchmarking for binaural outdoor noise renderer" )
endif( )
endif( )
if( NOT DEFINED ITA_VACORE_WITH_RENDERER_BINAURAL_CLUSTERING )
set( ITA_VACORE_WITH_RENDERER_BINAURAL_CLUSTERING ON CACHE BOOL "Build VACore with rendering module: clustering renderer" )
......
......@@ -75,6 +75,10 @@ CVABinauralOutdoorNoiseRenderer::CVABinauralOutdoorNoiseRenderer( const CVAAudio
CVABinauralOutdoorNoiseRenderer::~CVABinauralOutdoorNoiseRenderer()
{
#ifdef BINAURAL_OUTDOOR_NOISE_INSOURCE_BENCHMARKS
std::cout << "BinauralOutdoorNoiseRenderer GetOutput statistics: " << m_swProcessStream << std::endl;
#endif
}
void CVABinauralOutdoorNoiseRenderer::Init( const CVAStruct& oArgs )
......@@ -181,8 +185,11 @@ void CVABinauralOutdoorNoiseRenderer::SetParameters( const CVAStruct& oInArgs )
else
iPathID = m_mHashIdentifier2PathID.find( sIdentifierHash )->second; //get path identifier from simulation engine. In future iterations, this will be generated within VA
bool delete_path = oPath[ "delete" ];
if( delete_path )
bool bDeletePathRequested = false;
if( oPath.HasKey( "delete" ) )
bDeletePathRequested = oPath[ "delete" ];
if( bDeletePathRequested )
{
if( m_mPaths.find( iPathID ) != m_mPaths.end() && false ) // @todo fix removing wave fronts!
{
......@@ -199,22 +206,40 @@ void CVABinauralOutdoorNoiseRenderer::SetParameters( const CVAStruct& oInArgs )
auto path_pos = m_mPaths.find( iPathID ); //find the position of "path_ID" in the map
if( path_pos == m_mPaths.end() )
{ //if the path ID is not found, create a new path with this ID
CVABinauralOutdoorWaveFront* wave_front = dynamic_cast< CVABinauralOutdoorWaveFront* >( m_pWaveFrontPool->RequestObject() ); //request a new path from the pool
m_mPaths.insert( std::pair<int, CVABinauralOutdoorWaveFront*>( iPathID, wave_front ) ); //put that path into the map with the label path_ID
//TODO: might need to add a reference to the new path here? *******************************************
int path_source_ID = 1;// path[ "source" ]; //get source ID from incoming data
auto checksrc = m_mSources.find( path_source_ID );
if( checksrc == m_mSources.end() )
VA_EXCEPT1( "Source ID not found, make sure the source associated with each path exists." );
m_mPaths[ iPathID ]->SetSource( m_mSources[ path_source_ID ] ); //set the source for this path
int path_receiver_ID = 1; // = path[ "receiver" ];
auto checkrec = m_mBinauralReceivers.find( path_receiver_ID );
if( checkrec == m_mBinauralReceivers.end() )
VA_EXCEPT1( "Receiver ID not found, make sure the Receiver associated with each path exists." );
m_mPaths[ iPathID ]->SetReceiver( m_mBinauralReceivers[ path_receiver_ID ] ); //set the sound receiver for this path
{
// Source
if( !oPath.HasKey( "source" ) )
{
VA_WARN( "BinauralOutdoorNoiseRenderer", "Called SetParameters with a path missing the 'source' key, skipping this path." );
continue;
}
int iPathSourceID = oPath[ "source" ];
auto its = m_mSources.find( iPathSourceID );
if( its == m_mSources.end() )
{
VA_WARN( "BinauralOutdoorNoiseRenderer", "Source ID not (yet) found, make sure the source associated with each path exists." );
continue;
}
// Receiver
if( !oPath.HasKey( "receiver" ) )
{
VA_WARN( "BinauralOutdoorNoiseRenderer", "Called SetParameters with a path missing the 'receiver' key, skipping this path." );
continue;
}
int iPathReceiverID = oPath[ "receiver" ];
auto itr = m_mBinauralReceivers.find( iPathReceiverID );
if( itr == m_mBinauralReceivers.end() )
{
VA_WARN( "BinauralOutdoorNoiseRenderer", "Receiver ID not (yet) found, make sure the source associated with each path exists." );
continue;
}
// If the path ID is not found, create a new path with this ID
CVABinauralOutdoorWaveFront* pWaveFront = dynamic_cast< CVABinauralOutdoorWaveFront* >( m_pWaveFrontPool->RequestObject() ); //request a new path from the pool
m_mPaths.insert( std::pair<int, CVABinauralOutdoorWaveFront*>( iPathID, pWaveFront ) ); //put that path into the map with the label path_ID
m_mPaths[ iPathID ]->SetSource( m_mSources[ iPathSourceID ] ); //set the source for this path
m_mPaths[ iPathID ]->SetReceiver( m_mBinauralReceivers[ iPathReceiverID ] ); //set the sound receiver for this path
}
bool audible_ok = false; //if this is the first time this path is used, and it does not have the right keys,needs to be set inaudible
......@@ -270,11 +295,17 @@ void CVABinauralOutdoorNoiseRenderer::SetParameters( const CVAStruct& oInArgs )
audible_ok = true;
}
if( oPath.HasKey( "print_benchmarks" ) )
{
m_mPaths[ iPathID ]->SetParameters( oPath );
}
//Add the newly created wavefront to the clustering engine (but only if audible ok)
if( ( path_pos == m_mPaths.end() ) && ( audible_ok == true ) )
{
m_pClusterEngine->AddWaveFront( iPathID, m_mPaths[ iPathID ] ); //add new wave front to the clustering engine
}
}
}
......@@ -307,7 +338,7 @@ void CVABinauralOutdoorNoiseRenderer::ProcessStream( const ITAStreamInfo* stream
fm_zero( pfOutputR, GetBlocklength() );
/* @todo jst: why is this outcommented? Trajectories must be updated here for Doppler shifts ...
const CVAAudiostreamState* streamState = dynamic_cast< const CVAAudiostreamState* >( streamInfo );
const CVAAudiostreamState* streamState = dynamic_cast< const CVAAudiostreamState* >( streamInfo );
double time = streamState->dSysTime;
updateTrajectories(time);
*/
......@@ -400,7 +431,7 @@ void CVABinauralOutdoorNoiseRenderer::UpdateSoundSources( CVASceneStateDiff* dif
{
const int& iID( *it++ );
CreateSoundSource( iID, m_pNewSceneState->GetSoundSourceState( iID ) );
}
}
// Update wave front trajectories
std::map< int, CVABinauralOutdoorSource* >::iterator it;
......
......@@ -168,7 +168,7 @@ void CVABinauralOutdoorWaveFront::GetOutput( ITASampleBuffer* pfLeftChannel, ITA
}
else
{
VA_EXCEPT1( "Unknown interpolation type forwarded to VABinaurlWaveFront, please use either 'LINEAR_INTERPOLATION' or 'SWITCH'." );
VA_EXCEPT1( "Can't switch interpolation, unknown interpolation type forwarded to BinauralOutdoorNoiseRenderer, please use either 'LINEAR_INTERPOLATION' or 'SWITCH'." );
}
// Apply ITD correction
......@@ -197,7 +197,17 @@ void CVABinauralOutdoorWaveFront::GetOutput( ITASampleBuffer* pfLeftChannel, ITA
void CVABinauralOutdoorWaveFront::SetParameters( const CVAStruct &oInArgs )
{
VA_EXCEPT_NOT_IMPLEMENTED;
#ifdef BINAURAL_OUTDOOR_NOISE_INSOURCE_BENCHMARKS
if( oInArgs.HasKey( "print_benchmarks" ) )
{
std::cout << "WaveFront GetOutput statistics: " << m_swGetOutput << std::endl;
std::cout << "WaveFront VDL statistics: " << m_swVDL << std::endl;
std::cout << "WaveFront IIR filter statistics: " << m_swIIRFilter << std::endl;
std::cout << "WaveFront Interpolation statistics: " << m_swInterpolation << std::endl;
}
#else
VA_INFO( "CVABinauralOutdoorWaveFront", "SetParameters called, but this function does not do anything" );
#endif
}
void CVABinauralOutdoorWaveFront::SetFilterCoefficients( const ITABase::CThirdOctaveGainMagnitudeSpectrum &oMags )
......
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