ITARMSDetector.h 2.1 KB
Newer Older
1
/*
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 * ----------------------------------------------------------------
 *
 *		ITA core libs
 *		(c) Copyright Institute of Technical Acoustics (ITA)
 *		RWTH Aachen University, Germany, 2015-2016
 *
 * ----------------------------------------------------------------
 *				    ____  __________  _______
 *				   //  / //__   ___/ //  _   |
 *				  //  /    //  /    //  /_|  |
 *				 //  /    //  /    //  ___   |
 *				//__/    //__/    //__/   |__|
 *
 * ----------------------------------------------------------------
 *
 */
18 19 20 21 22 23 24 25 26 27 28 29 30

#ifndef INCLUDE_WATCHER_ITA_RMS_DETECTOR
#define INCLUDE_WATCHER_ITA_RMS_DETECTOR

#include <ITADataSourcesDefinitions.h>

#include <ITACriticalSection.h>
#include <ITADataSource.h>
#include <vector>

//! Detector for RMS values
/**
 *
31
 * \note not thread-safe
32 33 34 35 36 37 38 39 40 41 42 43
 */
class ITA_DATA_SOURCES_API ITARMSDetector : public ITADatasource
{
public:
	ITARMSDetector( ITADatasource* pDatasource );
	virtual ~ITARMSDetector();
	inline ITADatasource* GetDatasource() const
	{
		return m_pDataSource;
	};

	void Reset();
44 45
	void GetOverallRMS( float* pfRMS, unsigned int* puiChannel = 0, bool bReset = true );
	void GetOverallRMSDecibel( double* pdRMSDecibel, unsigned int* puiChannel = 0, bool bReset = true );
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
	float GetRMS( unsigned int uiChannel, bool bReset = true );
	double GetRMSDecibel( unsigned int uiChannel, bool bReset = true );
	void GetRMSs( std::vector<float>& vfDest, bool bReset = true );
	void GetRMSsDecibel( std::vector<double>& vdDestDecibel, bool bReset = true );
	
	inline unsigned int GetBlocklength() const 
	{ 
		return m_uiBlocklength;
	};

	inline unsigned int GetNumberOfChannels() const
	{ 
		return m_uiChannels;
	};

	inline double GetSampleRate() const 
	{ 
63
		return m_dSampleRate;
64 65 66 67 68 69
	};

	virtual const float* GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* pStreamInfo );
	virtual void IncrementBlockPointer();

protected:
70 71 72 73 74 75 76 77
	ITADatasource* m_pDataSource;
	double m_dSampleRate;
	unsigned int m_uiChannels;
	unsigned int m_uiBlocklength;
	ITACriticalSection m_cs;
	float* m_pfRMSs;
	float m_fOverallRMS;
	unsigned int m_uiOverallRMSChannel;
78 79 80
};

#endif // INCLUDE_WATCHER_ITA_RMS_DETECTOR