Adding magnitude calculate/get for HDFT spectrum

parent b550f9b3
......@@ -123,7 +123,7 @@ public:
void setCoeffsMP(int iOffset, int iCount, float fMagnitude, float fPhase);
//! Betragswert setzen, vorhandene Phasen erhalten
void setMagnitudePreservePhase(int iIndex, float fMagnitude);
void setMagnitudePreservePhase( int iIndex, float fMagnitude );
void setMagnitudesPreservePhases(float fMagnitude);
void setMagnitudesPreservePhases(int iOffset, int iCount, float fMagnitude);
......@@ -154,7 +154,10 @@ public:
//! Betragsspektrum berechnen und in gegebenes Array speichern
// Zeiger drfen Null sein
void calcMagnitudes(float* pfMagnitudes);
void calcMagnitudes( float* pfMagnitudes ) const;
//! Calculates magnitude from real and imaginary part for a given frequency bin
float calcMagnitude( int iIndex ) const;
//! Phasenspektrum berechnen und in gegebenes Array speichern
// Zeiger drfen Null sein
......
......@@ -173,7 +173,7 @@ ITA_BASE_API double ratio_to_db20(double r);
+------------------------------------+ */
//! Betrag einer komplexen Zahl berechnen
ITA_BASE_API float cabsf(float re, float im);
ITA_BASE_API float cabsf( float re, float im );
//! Phase einer komplexen Zahl berechnen
ITA_BASE_API float canglef(float re, float im);
......
......@@ -338,10 +338,19 @@ void ITAHDFTSpectrum::div( const ITAHDFTSpectrum* pSource )
return;
}
void ITAHDFTSpectrum::calcMagnitudes(float* pfMagnitudes) {
if (pfMagnitudes)
for (int i=0; i<m_iSize; i++)
pfMagnitudes[i] = cabsf(m_pfData[2*i], m_pfData[2*i+1]);
float ITAHDFTSpectrum::calcMagnitude( int iIndex ) const
{
if( iIndex >= m_iDFTSize )
ITA_EXCEPT1( INVALID_PARAMETER, "Index out of range" );
return cabsf( m_pfData[ 2 * iIndex ], m_pfData[ 2 * iIndex + 1 ] );
}
void ITAHDFTSpectrum::calcMagnitudes( float* pfMagnitudes ) const
{
if( pfMagnitudes )
for( int i = 0; i < m_iSize; i++ )
pfMagnitudes[ i ] = calcMagnitude( i );
}
void ITAHDFTSpectrum::calcPhases(float* pfPhases) {
......
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