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

#ifndef IW_ITA_THIRD_OCTAVE_FILTERBANK_IIR
#define IW_ITA_THIRD_OCTAVE_FILTERBANK_IIR

#include <ITADSPDefinitions.h>
#include <ITAThirdOctaveFilterbank.h>
24
#include <ITAThirdOctaveMagnitudeSpectrum.h>
25
#include <ITABiquad.h>
26
#include <ITASampleBuffer.h>
27
28
29
30

#include <vector>
#include <tbb/concurrent_queue.h>

31
//! Third octave magnitude filtering using Biquads (IIR filter)
32
33
34
35
36
37
/**
  *
  */
class ITA_DSP_API CITAThirdOctaveFilterbankIIR : public CITAThirdOctaveFilterbank
{
public:
38
	//! Constructor
39
	/**
40
41
	  * @param[in] dSampleRate Samplingrate
	  * @param[in] iBlockLength Block length
42
43
44
	  */
	CITAThirdOctaveFilterbankIIR( const double dSampleRate, const int iBlockLength );

45
	virtual inline ~CITAThirdOctaveFilterbankIIR() {};
46
47
48
49

	//! Filterlatenz in Samples zurückgeben
	int GetLatency() const;

50
	//! Set magnitudes (in decibel) of filter bank
51
	/**
52
53
	  * @param[in] oMagnitudes Filter magnitudes (dB)
	  * @param[in] bSmoothChangeover If true, switching is smoothed
54
	  */
55
	void SetMagnitudes( const CITAThirdOctaveGainMagnitudeSpectrum& oMagnitudes, const bool bSmoothChangeover = true );
56

57
	//! Clear all internal accumulators
58
59
60
61
62
63
64
65
66
67
68
	void Clear();

	//! Verarbeite Samples (Filtern)
	/**
	  * \param pfInputSamples Eingabesamples (Anzahl = Blocklänge)
	  * \param pfOutputSamples Ausgabesamples (Anzahl = Blocklänge)
	  */
	void Process( const float* pfInputSamples, float* pfOutputSamples );

private:
	//! Interne Datenklasse für das Verarbeiten eines neuen Gain Datensatzes
69
	class MagnitudeUpdate
70
71
	{
	public:
72
		CITAThirdOctaveGainMagnitudeSpectrum oMags; //! New magnitudes
73
74
75
76
77
78
79
		int iBlendSamples;				 //!< Anzahl Samples zum Überblenden
	};

	double m_dSampleRate;	  //!< Samplingrate
	int m_iBlockLength;		  //!< Blocklänge
	int m_nBandsInternal;	  //!< Anzahl der internen Bänder
	int m_nBiquadsPerBand;	  //!< Anzahl von Biqads pro Band
80
81
	std::vector< CITABiquad > m_vBiquads; //!< Biquads, access: [Band][BiquadNummer]
	tbb::strict_ppl::concurrent_queue< CITAThirdOctaveFilterbankIIR::MagnitudeUpdate > m_vMagnitudesQueue; //!< Liste von neuen Verstärkungsfaktoren
82
	CITAThirdOctaveGainMagnitudeSpectrum m_oMagnitudesInternal; //!< Interne Verstärkungsfaktoren
83
84
	ITASampleBuffer m_sfTempFilterBuf; //!< Intermediate buffer for filter
	ITASampleBuffer m_pfTempOutputBuf; //!< Intermediate buffer for output assembly
85
86
87
};

#endif // IW_ITA_THIRD_OCTAVE_FILTERBANK_IIR