ITAIIRFilterEngine.h 2.94 KB
Newer Older
1
2
3
4
5
/*
 * ----------------------------------------------------------------
 *
 *		ITA core libs
 *		(c) Copyright Institute of Technical Acoustics (ITA)
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
6
 *		RWTH Aachen University, Germany, 2015-2020
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * ----------------------------------------------------------------
 *				    ____  __________  _______
 *				   //  / //__   ___/ //  _   |
 *				  //  /    //  /    //  /_|  |
 *				 //  /    //  /    //  ___   |
 *				//__/    //__/    //__/   |__|
 *
 * ----------------------------------------------------------------
 *
 */

#ifndef IW_ITA_IIR_FILTER_ENGINE
#define IW_ITA_IIR_FILTER_ENGINE

#include <ITADSPDefinitions.h>
23
24
#include <ITAIIRCoefficients.h>

25
#include <vector>
26
#include <atomic>
27
28
29
30
31
32
33
34
35
36
37
38
39

//! Implements digital biquad component for IIR filtering
/**
  * @todo jst: translate comments to English.
  *
  * Diese Klasse realisiert ein Biquad IIR Filter. Es hat einen globalen Verstärkungsfaktor (Gain),
  * damit eine Kaskadierung vieler Biquads zur Bandfilterung benutzt werden kann.
  * Die Umsetzung erfolgt in Kanonischer Form, um möglichst wenig Multiplizierer/Addierer und
  * Verzögerer zu benutzen.
  */
class ITA_DSP_API CITAIIRFilterEngine
{
public:
40
	CITAIIRFilterEngine( unsigned int iOrder = 0, bool bIsARMA = false );
41
42
43

	virtual inline ~CITAIIRFilterEngine() {};

44
	void Initialise( unsigned int uiOrder, bool bIsArma );
henryjandrew's avatar
henryjandrew committed
45
46


47
48
	void Reset();

49
50
51
	//! Clears all accumulators
	void ClearAccumulators();

52
	unsigned int GetOrder() const;
53

54
55
	void SetCoefficientsToZero();
	void SetCoefficientsToIdentity();
56
	void SetCoefficients( const ITADSP::CFilterCoefficients& oCoefficients );
57
58
59
60
61
62
63
64
65
66
67
68

	//! Filter samples, simple variant without any gain (factor)
	/**
	  * Direct second canonical form.
	  *
	  * @param[in] pfInputData Input samples
	  * @param[out] pfOutputData Output samples
	  * @param[in] iNumSamples Number of samples to be processed
	  *
	  * @note Input and output samples must have same length
	  */
	void Process( const float* pfInputData, float* pfOutputData, const int iNumSamples );
69

70
71
72
73
74
75
76
77
78
79
80
81
82
	//! Filter samples, simple variant with given gain (factor)
	/**
	  * Direct second canonical form.
	  *
	  * @param[in] pfInputData Input samples
	  * @param[out] pfOutputData Output samples
	  * @param[in] iNumSamples Number of samples to be processed
	  * @param[in] fOutputGain Gain (factor) for output
	  * @param[in] iOutputMode Add to or overwrite output buffer
	  *
	  * @note Input and output samples must have same length
	  */
	void Process( const float* pfInputData, float* pfOutputData, const int iNumSamples, const float fOutputGain, const int iOutputMode );
83
84

	void Process( const float* pfInputData, float* pfOutputData, const int iNumSamples, const float fOutputGain1, const float fOutputGain2, const int iOutputWriteMode );
henryjandrew's avatar
henryjandrew committed
85

86
87

private:
88
89
90
	ITADSP::CFilterCoefficients m_oCoeffs;
	ITADSP::CFilterCoefficients m_oCoeffsNew;
	std::atomic< bool > m_bNewFilterCoefficients;
91
	std::vector< float > m_vfAccumulator; //!< Accumulators
henryjandrew's avatar
WIP    
henryjandrew committed
92
	unsigned int m_uiCursor;
93
94
95
};

#endif // IW_ITA_IIR_FILTER_ENGINE