Refactoring FIR and HDFT classes

parent 07a04e35
......@@ -43,7 +43,7 @@ public:
/**
* \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
/**
......@@ -60,27 +60,27 @@ public:
virtual inline ~CITAFiniteImpulseResponse() {};
//! Sampling frequency of FIR filter (double of Nyquist frequency)
double GetSampleRate() const;
float GetSampleRate() const;
//! Nyquist frequency of FIR filter (half of sample rate)
double GetNyquistFrequency() const;
float GetNyquistFrequency() const;
//! Initialize
/**
* (Re-)Initialize a sample buffer
*
* @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
*/
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:
//! Disable this Init method from sample buffer
void Init( int, bool );
double m_dSampleRate; //!< Sampling rate
float m_fSampleRate; //!< Sampling rate
};
#endif // INCLUDE_WATCHER_ITA_FINITE_IMPULSE_RESPONSE
......@@ -21,6 +21,7 @@
#include <ITABaseDefinitions.h>
#include <ccomplex>
#include <string>
#include <vector>
......@@ -109,6 +110,9 @@ public:
void setCoeffsRI( 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 setCoeffsMP( float fMagnitude, float fPhase );
void setCoeffsMP( int iOffset, int iCount, float fMagnitude, float fPhase );
......
#include <ITAFiniteImpulseResponse.h>
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 )
, m_dSampleRate( dSampleRate )
, m_fSampleRate( fSampleRate )
{
}
......@@ -23,18 +23,18 @@ CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const CITAFiniteImpulseRes
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 );
}
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;
}
......@@ -58,7 +58,7 @@ void ITAHDFTSpectrum::Init( const int iDFTSize, const bool bZeroinit )
m_iDFTSize = iDFTSize;
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 )
m_vfData.resize( m_iSize * 2 + 2 );
......@@ -471,3 +471,8 @@ void ITAHDFTSpectrum::copy( const ITAHDFTSpectrum* pSource )
for( int i = 0; i < 2 * m_iSize; 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