Adding more methods to HDFT spectrum classes

parent 769fe249
......@@ -65,9 +65,14 @@ namespace ITABase
*/
int GetDFTSize() const;
//! Returns the frequency of a bin by index (0 .. DFT-size - 1)
float GetFrequencyOfBin( const int iBinIndex ) const;
//! Return sampling rate
double GetSampleRate() const;
float GetFrequencyResolution() const;
//! Adds the given spectra channel-wise
void add( const CHDFTSpectra* );
......@@ -108,7 +113,6 @@ namespace ITABase
std::vector< CHDFTSpectrum* > m_vpSpectra; //! DFT spectra
};
}
#endif // INCLUDE_WATCHER_ITA_HDFT_SPECTRA
......@@ -103,21 +103,26 @@ namespace ITABase
void SetSampleRate( const float fSampleRate );
// Frequenzauflsung des Spektrums [Hz] zurckgeben
float GetFrequencyResolution() const;
float GetFrequencyResolution() const;
float GetFrequencyOfBin( const int iBinIndex ) const;
// Datenzeiger abrufen
float* GetData() const;
// DFT Koeffizient(en) setzen (Real-/Imaginrteil bzw. Betrag/Phase)
void SetCoeffRI( const int iIndex, const float fReal, const float fImag = 0 );
void SetCoeffRI( const int iIndex, const float fReal, const float fImag = 0 );
void SetCoeffsRI( const float fReal, const float fImag = 0 );
void SetCoeffsRI( const int iOffset, const int iCount, const float fReal, const float fImag = 0 );
void SetCoeffsRI( const int iOffset, const int iCount, const float fReal, const float fImag = 0 );
//! Get complex value by index
std::complex< float > GetCoeff( const int iIndex ) const;
//! Set coefficient by index
void SetCoeff( const int iIndex, std::complex< float >& cfCoeff );
void SetCoeffMP( const int iIndex, const float fMagnitude, const float fPhase );
void SetCoeffsMP( const float fMagnitude, const float fPhase );
void SetCoeffsMP( const float fMagnitude, const float fPhase );
void SetCoeffsMP( const int iOffset, const int iCount, const float fMagnitude, const float fPhase );
//! Betragswert setzen, vorhandene Phasen erhalten
......@@ -223,7 +228,6 @@ namespace ITABase
mutable std::vector< float > m_vfData;
};
}
#endif // __ITA_HDFT_SPECTRUM_H__
......@@ -196,3 +196,13 @@ ITABase::CHDFTSpectrum* ITABase::CHDFTSpectra::operator[]( const int iIdx )
{
return m_vpSpectra[ iIdx ];
}
float ITABase::CHDFTSpectra::GetFrequencyOfBin( const int iBinIndex ) const
{
return m_vpSpectra[ 0 ]->GetFrequencyOfBin( iBinIndex );
}
float ITABase::CHDFTSpectra::GetFrequencyResolution() const
{
return m_vpSpectra[ 0 ]->GetFrequencyResolution();
}
......@@ -510,3 +510,15 @@ void CHDFTSpectrum::SetCoeff( const int iIndex, std::complex< float >& cfCoeff )
{
SetCoeffRI( iIndex, cfCoeff.real(), cfCoeff.imag() );
}
float CHDFTSpectrum::GetFrequencyOfBin( const int iBinIndex ) const
{
return GetFrequencyResolution() * ( float ) iBinIndex;
}
std::complex< float > CHDFTSpectrum::GetCoeff( const int iIndex ) const
{
if( iIndex < 0 || 2 * iIndex + 1 >= m_vfData.size() )
ITA_EXCEPT_INVALID_PARAMETER( "Coefficient index out of bounds" );
return{ m_vfData[ 2 * iIndex ], m_vfData[ 2 * iIndex + 1 ] };
}
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