Commit f796164b authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Progress on RMS detector

parent 70eb7f34
...@@ -132,7 +132,9 @@ target_link_libraries( ITADataSources ${VISTA_USE_PACKAGE_LIBRARIES} ) ...@@ -132,7 +132,9 @@ target_link_libraries( ITADataSources ${VISTA_USE_PACKAGE_LIBRARIES} )
#target_compile_features(ITADataSources PRIVATE cxx_range_for) #target_compile_features(ITADataSources PRIVATE cxx_range_for)
add_definitions( -std=c++11 ) if( NOT WIN32
add_definitions( -std=c++11 )
endif()
set( BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_TEMP} ) set( BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_TEMP} )
......
/* /*
* ---------------------------------------------------------------- * ----------------------------------------------------------------
* *
* ITA core libs * ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA) * (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016 * RWTH Aachen University, Germany, 2015-2016
* *
* ---------------------------------------------------------------- * ----------------------------------------------------------------
* ____ __________ _______ * ____ __________ _______
* // / //__ ___/ // _ | * // / //__ ___/ // _ |
* // / // / // /_| | * // / // / // /_| |
* // / // / // ___ | * // / // / // ___ |
* //__/ //__/ //__/ |__| * //__/ //__/ //__/ |__|
* *
* ---------------------------------------------------------------- * ----------------------------------------------------------------
* *
*/ */
#ifndef INCLUDE_WATCHER_ITA_RMS_DETECTOR #ifndef INCLUDE_WATCHER_ITA_RMS_DETECTOR
#define INCLUDE_WATCHER_ITA_RMS_DETECTOR #define INCLUDE_WATCHER_ITA_RMS_DETECTOR
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
//! Detector for RMS values //! Detector for RMS values
/** /**
* *
* \note Die Klasse ist Thread-safe * \note not thread-safe
*/ */
class ITA_DATA_SOURCES_API ITARMSDetector : public ITADatasource class ITA_DATA_SOURCES_API ITARMSDetector : public ITADatasource
{ {
...@@ -41,11 +41,10 @@ public: ...@@ -41,11 +41,10 @@ public:
}; };
void Reset(); void Reset();
void GetOverallRMS( float* pfPeak, unsigned int* puiChannel = 0, bool bReset = true ); void GetOverallRMS( float* pfRMS, unsigned int* puiChannel = 0, bool bReset = true );
void GetOverallRMSDecibel( double* pdPeakDecibel, unsigned int* puiChannel = 0, bool bReset = true ); void GetOverallRMSDecibel( double* pdRMSDecibel, unsigned int* puiChannel = 0, bool bReset = true );
float GetRMS( unsigned int uiChannel, bool bReset = true ); float GetRMS( unsigned int uiChannel, bool bReset = true );
double GetRMSDecibel( unsigned int uiChannel, bool bReset = true ); double GetRMSDecibel( unsigned int uiChannel, bool bReset = true );
void GetRMSs( float* pfDest, bool bReset = true );
void GetRMSs( std::vector<float>& vfDest, bool bReset = true ); void GetRMSs( std::vector<float>& vfDest, bool bReset = true );
void GetRMSsDecibel( std::vector<double>& vdDestDecibel, bool bReset = true ); void GetRMSsDecibel( std::vector<double>& vdDestDecibel, bool bReset = true );
...@@ -61,21 +60,21 @@ public: ...@@ -61,21 +60,21 @@ public:
inline double GetSampleRate() const inline double GetSampleRate() const
{ {
return m_dSamplerate; return m_dSampleRate;
}; };
virtual const float* GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* pStreamInfo ); virtual const float* GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* pStreamInfo );
virtual void IncrementBlockPointer(); virtual void IncrementBlockPointer();
protected: protected:
ITADatasource* m_pDataSource; // Angeschlossene Datenquelle ITADatasource* m_pDataSource;
double m_dSamplerate; // Abtastrate [Hz] double m_dSampleRate;
unsigned int m_uiChannels; // Anzahl Kanle unsigned int m_uiChannels;
unsigned int m_uiBlocklength; // Streaming Puffergre [Samples] unsigned int m_uiBlocklength;
ITACriticalSection m_cs; // Sichert exklusiven Zugriff auf die Daten (s.u.) ITACriticalSection m_cs;
float* m_pfRMSs; // Spitzenwerte der einzelnen Kanle float* m_pfRMSs;
float m_fOverallRMS; // Spitzenwert ber alle Kanle float m_fOverallRMS;
unsigned int m_uiOverallRMSChannel; // Kanal in dem der Spitzenwert auftrat unsigned int m_uiOverallRMSChannel;
}; };
#endif // INCLUDE_WATCHER_ITA_RMS_DETECTOR #endif // INCLUDE_WATCHER_ITA_RMS_DETECTOR
\ No newline at end of file
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
ITARMSDetector::ITARMSDetector( ITADatasource* pDataSource ) ITARMSDetector::ITARMSDetector( ITADatasource* pDataSource )
: m_pDataSource( pDataSource ) : m_pDataSource( pDataSource )
{ {
m_dSamplerate = pDataSource->GetSampleRate(); m_dSampleRate = pDataSource->GetSampleRate();
m_uiChannels = pDataSource->GetNumberOfChannels(); m_uiChannels = pDataSource->GetNumberOfChannels();
m_uiBlocklength = pDataSource->GetBlocklength(); m_uiBlocklength = pDataSource->GetBlocklength();
m_pfRMSs = 0; m_pfRMSs = 0;
if( ( m_uiBlocklength == 0 ) || ( m_uiChannels == 0 ) || ( m_dSamplerate == 0 ) ) if( ( m_uiBlocklength == 0 ) || ( m_uiChannels == 0 ) || ( m_dSampleRate == 0 ) )
ITA_EXCEPT0( INVALID_PARAMETER ); ITA_EXCEPT0( INVALID_PARAMETER );
m_pfRMSs = new float[ m_uiChannels ]; m_pfRMSs = new float[ m_uiChannels ];
...@@ -96,22 +96,7 @@ double ITARMSDetector::GetRMSDecibel( unsigned int uiChannel, bool bReset ) ...@@ -96,22 +96,7 @@ double ITARMSDetector::GetRMSDecibel( unsigned int uiChannel, bool bReset )
return ratio_to_db20( GetRMS( uiChannel, bReset ) ); return ratio_to_db20( GetRMS( uiChannel, bReset ) );
} }
void ITARMSDetector::GetRMSs( float* pfDest, bool bReset ) void ITARMSDetector::GetRMSs( std::vector< float >& vfDest, bool bReset )
{
if( !pfDest )
ITA_EXCEPT0( INVALID_PARAMETER );
m_cs.enter();
for( unsigned int c = 0; c < m_uiChannels; c++ )
{
pfDest[ c ] = m_pfRMSs[ c ];
if( bReset )
m_pfRMSs[ c ] = 0;
}
m_cs.leave();
}
void ITARMSDetector::GetRMSs( std::vector<float>& vfDest, bool bReset )
{ {
if( ( ( unsigned int ) vfDest.size() ) < m_uiChannels ) if( ( ( unsigned int ) vfDest.size() ) < m_uiChannels )
vfDest.resize( m_uiChannels ); vfDest.resize( m_uiChannels );
......
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