Refactoring FIR and HDFT classes

parent 07a04e35
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
/** /**
* \param iLength Length (size) of buffer in samples * \param iLength Length (size) of buffer in samples
*/ */
explicit CITAFiniteImpulseResponse( const int iLength, const double dSampleRate, const bool bZeroInit = true ); explicit CITAFiniteImpulseResponse( const int iLength, const float fSampleRate, const bool bZeroInit = true );
//! Copy constructor as pointer //! Copy constructor as pointer
/** /**
...@@ -60,27 +60,27 @@ public: ...@@ -60,27 +60,27 @@ public:
virtual inline ~CITAFiniteImpulseResponse() {}; virtual inline ~CITAFiniteImpulseResponse() {};
//! Sampling frequency of FIR filter (double of Nyquist frequency) //! Sampling frequency of FIR filter (double of Nyquist frequency)
double GetSampleRate() const; float GetSampleRate() const;
//! Nyquist frequency of FIR filter (half of sample rate) //! Nyquist frequency of FIR filter (half of sample rate)
double GetNyquistFrequency() const; float GetNyquistFrequency() const;
//! Initialize //! Initialize
/** /**
* (Re-)Initialize a sample buffer * (Re-)Initialize a sample buffer
* *
* @param[in] iLength Number of new samples * @param[in] iLength Number of new samples
* @param[in] dSampleRate Sampling rate of FIR filter (double of Nyquist frequency) * @param[in] fSampleRate Sampling rate of FIR filter (double of Nyquist frequency)
* @param[in] bZeroInit Init with zeros * @param[in] bZeroInit Init with zeros
*/ */
void Init( const int iLength, const double dSampleRate, const bool bZeroInit = true ); void Init( const int iLength, const float fSampleRate, const bool bZeroInit = true );
private: private:
//! Disable this Init method from sample buffer //! Disable this Init method from sample buffer
void Init( int, bool ); void Init( int, bool );
double m_dSampleRate; //!< Sampling rate float m_fSampleRate; //!< Sampling rate
}; };
#endif // INCLUDE_WATCHER_ITA_FINITE_IMPULSE_RESPONSE #endif // INCLUDE_WATCHER_ITA_FINITE_IMPULSE_RESPONSE
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <ITABaseDefinitions.h> #include <ITABaseDefinitions.h>
#include <ccomplex>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -109,6 +110,9 @@ public: ...@@ -109,6 +110,9 @@ public:
void setCoeffsRI( float fReal, float fImag = 0 ); void setCoeffsRI( float fReal, float fImag = 0 );
void setCoeffsRI( int iOffset, int iCount, float fReal, float fImag = 0 ); void setCoeffsRI( int iOffset, int iCount, float fReal, float fImag = 0 );
//! Set coefficient by index
void SetCoeff( const int iIndex, std::complex< float >& cfCoeff );
void setCoeffMP( int iIndex, float fMagnitude, float fPhase ); void setCoeffMP( int iIndex, float fMagnitude, float fPhase );
void setCoeffsMP( float fMagnitude, float fPhase ); void setCoeffsMP( float fMagnitude, float fPhase );
void setCoeffsMP( int iOffset, int iCount, float fMagnitude, float fPhase ); void setCoeffsMP( int iOffset, int iCount, float fMagnitude, float fPhase );
......
#include <ITAFiniteImpulseResponse.h> #include <ITAFiniteImpulseResponse.h>
CITAFiniteImpulseResponse::CITAFiniteImpulseResponse() CITAFiniteImpulseResponse::CITAFiniteImpulseResponse()
: m_dSampleRate( 0 ) : m_fSampleRate( 0 )
{ {
} }
CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const int iLength, const double dSampleRate, const bool bZeroInit /*= true */ ) CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const int iLength, const float fSampleRate, const bool bZeroInit /*= true */ )
: ITASampleBuffer( iLength, bZeroInit ) : ITASampleBuffer( iLength, bZeroInit )
, m_dSampleRate( dSampleRate ) , m_fSampleRate( fSampleRate )
{ {
} }
...@@ -23,18 +23,18 @@ CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const CITAFiniteImpulseRes ...@@ -23,18 +23,18 @@ CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const CITAFiniteImpulseRes
ITASampleBuffer::write( sbSource, sbSource.GetLength() ); ITASampleBuffer::write( sbSource, sbSource.GetLength() );
} }
void CITAFiniteImpulseResponse::Init( const int iLength, const double dSampleRate, const bool bZeroInit /*= true */ ) void CITAFiniteImpulseResponse::Init( const int iLength, const float fSampleRate, const bool bZeroInit /*= true */ )
{ {
m_dSampleRate = dSampleRate; m_fSampleRate = fSampleRate;
ITASampleBuffer::Init( iLength, bZeroInit ); ITASampleBuffer::Init( iLength, bZeroInit );
} }
double CITAFiniteImpulseResponse::GetSampleRate() const float CITAFiniteImpulseResponse::GetSampleRate() const
{ {
return m_dSampleRate; return m_fSampleRate;
} }
double CITAFiniteImpulseResponse::GetNyquistFrequency() const float CITAFiniteImpulseResponse::GetNyquistFrequency() const
{ {
return GetSampleRate() / 2.0f; return GetSampleRate() / 2.0f;
} }
...@@ -58,7 +58,7 @@ void ITAHDFTSpectrum::Init( const int iDFTSize, const bool bZeroinit ) ...@@ -58,7 +58,7 @@ void ITAHDFTSpectrum::Init( const int iDFTSize, const bool bZeroinit )
m_iDFTSize = iDFTSize; m_iDFTSize = iDFTSize;
m_iSize = ( int ) floor( ( float ) m_iDFTSize / 2.0 ) + 1; m_iSize = ( int ) floor( ( float ) m_iDFTSize / 2.0 ) + 1;
// +2 wegen 4-Byte Ausrichtung // +2 wegen 4-Byte Ausrichtung @jst todo
if( m_iSize > 0 ) if( m_iSize > 0 )
m_vfData.resize( m_iSize * 2 + 2 ); m_vfData.resize( m_iSize * 2 + 2 );
...@@ -471,3 +471,8 @@ void ITAHDFTSpectrum::copy( const ITAHDFTSpectrum* pSource ) ...@@ -471,3 +471,8 @@ void ITAHDFTSpectrum::copy( const ITAHDFTSpectrum* pSource )
for( int i = 0; i < 2 * m_iSize; i++ ) for( int i = 0; i < 2 * m_iSize; i++ )
m_vfData[ i ] = pSource->GetData()[ i ]; m_vfData[ i ] = pSource->GetData()[ i ];
} }
void ITAHDFTSpectrum::SetCoeff( const int iIndex, std::complex< float >& cfCoeff )
{
setCoeffRI( iIndex, cfCoeff.real(), cfCoeff.imag() );
}
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