Commit 2fdc7734 authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

Merge branch 'develop' of https://git.rwth-aachen.de/ita/ITASimulationScheduler into develop

parents 940ba052 a5758703
......@@ -31,62 +31,62 @@ namespace ITA
struct ITA_SIMULATION_SCHEDULER_API CalculationUtils
{
static ITABase::CMultichannelFiniteImpulseResponse Mean ( std::vector<ITABase::CMultichannelFiniteImpulseResponse> irsVector )
inline static ITABase::CMultichannelFiniteImpulseResponse Mean( std::vector<ITABase::CMultichannelFiniteImpulseResponse> irsVector )
{
if ( irsVector.size ( ) == 1 ) // mean over channels
if( irsVector.size() == 1 ) // mean over channels
{
// add every channel together.
auto mean = ITABase::CMultichannelFiniteImpulseResponse ( 1,
irsVector.at ( 0 ).GetLength ( ),
irsVector.at ( 0 ).GetSampleRate ( ),
true );
auto mean = ITABase::CMultichannelFiniteImpulseResponse( 1,
irsVector.at( 0 ).GetLength(),
irsVector.at( 0 ).GetSampleRate(),
true );
for ( auto i = 0; i < irsVector.at ( 0 ).GetNumChannels ( ); ++i )
for( auto i = 0; i < irsVector.at( 0 ).GetNumChannels(); ++i )
{
mean [0].add_buf ( irsVector.at ( 0 ) [i] );
mean[ 0 ].add_buf( irsVector.at( 0 )[ i ] );
}
mean [0].div_scalar ( irsVector.at ( 0 ).GetNumChannels ( ) );
mean[ 0 ].div_scalar( irsVector.at( 0 ).GetNumChannels() );
return mean;
}
else if ( irsVector.size ( ) > 1 ) // mean over multiple multichannel irs
else if( irsVector.size() > 1 ) // mean over multiple multichannel irs
{
// check all the same channel count
const auto channelCount = irsVector.at ( 0 ).GetNumChannels ( );
const auto channelCount = irsVector.at( 0 ).GetNumChannels();
auto sameChannelCount = true;
for ( auto& irs : irsVector )
for( auto& irs : irsVector )
{
sameChannelCount &= irs.GetNumChannels ( ) == channelCount;
sameChannelCount &= irs.GetNumChannels() == channelCount;
}
if ( !sameChannelCount )
if( !sameChannelCount )
{
ITA_EXCEPT_INVALID_PARAMETER ( "Not all CMultichannelFiniteImpulseResponses have the same channel count." )
ITA_EXCEPT_INVALID_PARAMETER( "Not all CMultichannelFiniteImpulseResponses have the same channel count." )
}
// add every object together.
auto mean = ITABase::CMultichannelFiniteImpulseResponse ( irsVector.at ( 0 ).GetNumChannels ( ),
irsVector.at ( 0 ).GetLength ( ),
irsVector.at ( 0 ).GetSampleRate ( ),
true );
auto mean = ITABase::CMultichannelFiniteImpulseResponse( irsVector.at( 0 ).GetNumChannels(),
irsVector.at( 0 ).GetLength(),
irsVector.at( 0 ).GetSampleRate(),
true );
for ( auto& irs : irsVector )
for( auto& irs : irsVector )
{
mean.add_frame ( irs );
mean.add_frame( irs );
}
// divide by number of objects.
mean.div_scalar ( irsVector.size ( ) );
mean.div_scalar( irsVector.size() );
return mean;
}
else
ITA_EXCEPT_INVALID_PARAMETER ( "Somehting went wrong with the channel count." )
}
ITA_EXCEPT_INVALID_PARAMETER( "Somehting went wrong with the channel count." )
};
static std::vector<double> CalculateStdDevOfAbsSpectralDifference ( const ITABase::CMultichannelFiniteImpulseResponse& reference,
inline static std::vector<double> CalculateStdDevOfAbsSpectralDifference( const ITABase::CMultichannelFiniteImpulseResponse& reference,
const std::vector<ITABase::CMultichannelFiniteImpulseResponse>& results )
{
auto referenceCopy = reference;
......@@ -111,9 +111,9 @@ namespace ITA
}
return stdDev;
}
};
static double CalculateAzimuthOnTargetInDegree ( const VistaVector3D& positionOrigin, const VistaQuaternion& orientation, const VistaVector3D& positionTarget )
inline static double CalculateAzimuthOnTargetInDegree( const VistaVector3D& positionOrigin, const VistaQuaternion& orientation, const VistaVector3D& positionTarget )
{
auto direction = positionTarget - positionOrigin;
direction.Normalize ( );
......@@ -121,32 +121,23 @@ namespace ITA
const auto azimuthAngle = atan2 ( direction.Dot ( orientation.GetRightDir ( ) ), direction.Dot ( orientation.GetViewDir ( ) ) ) * 180 / ITAConstants::PI_D;
return azimuthAngle < 0 ? azimuthAngle + 360 : azimuthAngle;
}
};
static double CalculateElevationOnTargetInDegree ( const VistaVector3D& positionOrigin, const VistaQuaternion& orientation, const VistaVector3D& positionTarget )
inline static double CalculateElevationOnTargetInDegree( const VistaVector3D& positionOrigin, const VistaQuaternion& orientation, const VistaVector3D& positionTarget )
{
auto direction = positionTarget - positionOrigin;
direction.Normalize ( );
return asin ( direction.Dot ( orientation.GetUpDir ( ) ) ) * 180 / ITAConstants::PI_D;
}
};
static void Normalize ( ITABase::CMultichannelFiniteImpulseResponse& irs )
inline static void Normalize( ITABase::CMultichannelFiniteImpulseResponse& irs )
{
auto data = DataTypeUtils::ConvertToValueArray ( irs );
auto globalPeak = 0.0f;
for ( const auto& values : data )
{
globalPeak = (std::max)( globalPeak, abs( values ).max() );
}
irs.mul_scalar ( 1 / globalPeak );
irs.Normalize();
irs.mul_scalar ( 0.99 );
}
};
static std::valarray<float> NormalizedCrossCorrelation ( const ITABase::CFiniteImpulseResponse& x, const ITABase::CFiniteImpulseResponse& y )
inline static std::valarray<float> NormalizedCrossCorrelation( const ITABase::CFiniteImpulseResponse& x, const ITABase::CFiniteImpulseResponse& y )
{
const auto nx = x.GetLength ( );
const auto ny = y.GetLength ( );
......@@ -176,9 +167,9 @@ namespace ITA
const auto cyy0 = pow ( abs ( DataTypeUtils::ConvertToValueArray ( y ) ), 2.0f ).sum ( );
const auto scaleCoeffCross = sqrt ( cxx0 * cyy0 );
return correlation /= scaleCoeffCross;
}
};
static std::vector<std::valarray<float>> NormalizedCrossCorrelation ( const ITASampleFrame& x, const ITASampleFrame& y )
inline static std::vector<std::valarray<float>> NormalizedCrossCorrelation( const ITASampleFrame& x, const ITASampleFrame& y )
{
if ( x.GetNumChannels ( ) != y.GetNumChannels ( ) )
ITA_EXCEPT_INVALID_PARAMETER ( "Different number of channels not supported." );
......@@ -191,9 +182,9 @@ namespace ITA
}
return returnVec;
}
};
static std::vector<std::valarray<float>> NormalizedCrossCorrelation ( const ITABase::CMultichannelFiniteImpulseResponse& x, const ITABase::CMultichannelFiniteImpulseResponse& y )
inline static std::vector<std::valarray<float>> NormalizedCrossCorrelation( const ITABase::CMultichannelFiniteImpulseResponse& x, const ITABase::CMultichannelFiniteImpulseResponse& y )
{
if ( x.GetNumChannels ( ) != y.GetNumChannels ( ) )
ITA_EXCEPT_INVALID_PARAMETER ( "Different number of channels not supported." );
......@@ -206,14 +197,14 @@ namespace ITA
}
return returnVec;
}
};
static std::valarray<float> NormalizedCrossCorrelation ( const ITASampleBuffer& x, const ITASampleBuffer& y )
inline static std::valarray<float> NormalizedCrossCorrelation( const ITASampleBuffer& x, const ITASampleBuffer& y )
{
return NormalizedCrossCorrelation ( DataTypeUtils::Convert ( x ), DataTypeUtils::Convert ( y ) );
}
};
static std::valarray<double> NormalizedCrossCorrelation ( const std::valarray<double>& x, const std::valarray<double>& y )
inline static std::valarray<double> NormalizedCrossCorrelation( const std::valarray<double>& x, const std::valarray<double>& y )
{
const auto nx = x.size ( );
const auto ny = y.size ( );
......@@ -234,7 +225,7 @@ namespace ITA
const auto cyy0 = pow ( abs ( y ), 2.0 ).sum ( );
const auto scaleCoeffCross = sqrt ( cxx0 * cyy0 );
return correlation /= scaleCoeffCross;
}
};
};
inline ITABase::CHDFTSpectra* operator/( const ITABase::CMultichannelFiniteImpulseResponse& lhs,
......@@ -267,10 +258,10 @@ namespace ITA
}
return result;
}
};
template<class T>
std::vector<T> operator+( const std::vector<T>& lhs, const std::vector<T>& rhs )
inline std::vector<T> operator+( const std::vector<T>& lhs, const std::vector<T>& rhs )
{
if ( lhs.size ( ) != rhs.size ( ) )
std::exception ( "Size miss match." );
......@@ -283,7 +274,7 @@ namespace ITA
}
return result;
}
};
} // namespace Utils
......@@ -294,7 +285,7 @@ namespace ITA
retArray [1] = rhs.b - lhs.b;
retArray [2] = rhs.c - lhs.c;
return retArray;
}
};
} // namespace SimulationScheduler
} // namespace ITA
......
......@@ -52,6 +52,9 @@ namespace ITA
auto workerConfig = CWorkerFactory::CreateConfig ( type );
if( !workerConfig )
ITA_EXCEPT_INVALID_PARAMETER( "Could not create simulation worker thread of type '" + type + "'" );
workerConfig->Load ( configProperties );
vpWorkerConfigs.push_back ( workerConfig );
}
......
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