Introducing ITABaser namespace, starting with data classes

parent 6dc041dc
......@@ -24,8 +24,9 @@
// STL
#include <cmath>
#include <numeric>
#include <limits>
#include <numeric>
#include <vector>
namespace ITAConstants
{
......@@ -58,6 +59,12 @@ namespace ITAConstants
static float MINUS_INFINITY_F = -std::numeric_limits< float >::infinity();
static double INFINITY_D = std::numeric_limits< double >::infinity();
static double MINUS_INFINITY_D = -std::numeric_limits< double >::infinity();
static std::vector< float > THIRD_OCTAVE_CENTER_FREQUENCIES_ISO_F = { 20, 25, 31.5f, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000 };
static std::vector< double > THIRD_OCTAVE_CENTER_FREQUENCIES_ISO_D = { 20, 25, 31.5f, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000 };
static std::vector< float > OCTAVE_CENTER_FREQUENCIES_ISO_F = { 31.5f, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000 };
static std::vector< double > OCTAVE_CENTER_FREQUENCIES_ISO_D = { 31.5f, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000 };
};
#endif // INCLUDE_WATCHER_ITA_CONSTANTS
......@@ -25,39 +25,42 @@
#include <string>
//! Single channel finite impulse response class / FIR filter
/**
namespace ITABase
{
//! Single channel finite impulse response class / FIR filter
/**
* ITASampleBuffer with a sampling rate = finite impulse response.
* For multi channel FIR filter, @sa ITAMultichannelFiniteImpulseResponse
*/
class ITA_BASE_API CITAFiniteImpulseResponse : public ITASampleBuffer
{
public:
class ITA_BASE_API CFiniteImpulseResponse : public ITASampleBuffer
{
public:
//! Create empty FIR filter
/**
* Requires initialization to be used, otherwise methods will throw ITAException.
*/
CITAFiniteImpulseResponse();
CFiniteImpulseResponse();
//! Create FIR filter of certain size with given sampling frequency
/**
* \param iLength Length (size) of buffer in samples
*/
explicit CITAFiniteImpulseResponse( const int iLength, const float fSampleRate, const bool bZeroInit = true );
explicit CFiniteImpulseResponse( const int iLength, const float fSampleRate, const bool bZeroInit = true );
//! Copy constructor as pointer
/**
* \param pSource Pointer to source buffer
*/
CITAFiniteImpulseResponse( const CITAFiniteImpulseResponse* pSource );
CFiniteImpulseResponse( const CFiniteImpulseResponse* pSource );
//! Copy constructor as reference
/**
* \param pbSource Reference to source buffer
*/
CITAFiniteImpulseResponse( const CITAFiniteImpulseResponse& sbSource );
CFiniteImpulseResponse( const CFiniteImpulseResponse& sbSource );
virtual inline ~CITAFiniteImpulseResponse() {};
virtual inline ~CFiniteImpulseResponse() {};
//! Sampling frequency of FIR filter (double of Nyquist frequency)
float GetSampleRate() const;
......@@ -76,11 +79,13 @@ public:
void Init( const int iLength, const float fSampleRate, const bool bZeroInit = true );
private:
private:
//! Disable this Init method from sample buffer
void Init( int, bool );
float m_fSampleRate; //!< Sampling rate
};
};
}
#endif // INCLUDE_WATCHER_ITA_FINITE_IMPULSE_RESPONSE
......@@ -26,10 +26,13 @@
// STL includes
#include <vector>
class ITAHDFTSpectrum;
namespace ITABase
{
class CHDFTSpectrum;
//! Multi-channel half-sided discrete fourier spectra
/**
//! Multi-channel half-sided discrete fourier spectra
/**
*
* This class describes DFT spectrum data with variable number channels
* and provides functionality for manipulation and math operations.
......@@ -37,18 +40,18 @@ class ITAHDFTSpectrum;
* This class extends the \ITAHDFTSpectrum for multi-channel applications.
*
*/
class ITA_BASE_API ITAHDFTSpectra
{
public:
class ITA_BASE_API CHDFTSpectra
{
public:
//! Constructor that initializes the
ITAHDFTSpectra( const float fSampleRate, const int iNumChannels, const int iDFTSize, const bool bZeroInit=true );
CHDFTSpectra( const float fSampleRate, const int iNumChannels, const int iDFTSize, const bool bZeroInit = true );
//! Constructor that uses a non-empty HDFTSpectrum vector
ITAHDFTSpectra( const std::vector< ITAHDFTSpectrum* >& vpSpectrumVec );
CHDFTSpectra( const std::vector< CHDFTSpectrum* >& vpSpectrumVec );
//! Standard destructor
~ITAHDFTSpectra();
~CHDFTSpectra();
//! Return number of channels
/**
......@@ -66,22 +69,22 @@ public:
double GetSampleRate() const;
//! Adds the given spectra channel-wise
void add( const ITAHDFTSpectra* );
void add( const CHDFTSpectra* );
//! Subtracts the given spectra channel-wise
void sub( const ITAHDFTSpectra* );
void sub( const CHDFTSpectra* );
//! Multiplies the given spectra channel-wise
void mul( const ITAHDFTSpectra* );
void mul( const CHDFTSpectra* );
//! Multiplies the conjugate of the given spectra without data copy channel-wise
void mul_conj( const ITAHDFTSpectra* );
void mul_conj( const CHDFTSpectra* );
//! Multiplies a scalar
void mul_scalar( double );
//! Divides the given spectra channel-wise
void div( const ITAHDFTSpectra* );
void div( const CHDFTSpectra* );
//! Set unity (all coefficiants real one)
void SetUnity();
......@@ -90,20 +93,22 @@ public:
void SetZero();
//! Copy from another Spectra
void CopyFrom(const ITAHDFTSpectra* otherSpectra);
void CopyFrom( const CHDFTSpectra* otherSpectra );
//! Returns maximum energy from all spectra
float GetMaxEnergy( int* piChannelIndex = nullptr ) const;
//! Subscript operator gives direct access to spectrum channel
const ITAHDFTSpectrum* operator[]( const int ) const;
ITAHDFTSpectrum* operator[]( const int );
const CHDFTSpectrum* operator[]( const int ) const;
CHDFTSpectrum* operator[]( const int );
private:
private:
//! Standard constructor
ITAHDFTSpectra();
CHDFTSpectra();
std::vector< CHDFTSpectrum* > m_vpSpectra; //! DFT spectra
};
std::vector< ITAHDFTSpectrum* > m_vpSpectra; //! DFT spectra
};
}
#endif // INCLUDE_WATCHER_ITA_HDFT_SPECTRA
......@@ -25,7 +25,10 @@
#include <string>
#include <vector>
/**
namespace ITABase
{
/**
* Diese Klasse realisiert half-size DFT-Spektren. Dies sind die DFT-Spektren
* rein reellwertiger Signale, wie sie in der Akustik/Audiosignalverarbeitung
* blich sind. Das DFT-Spektrum solcher Signale erfllt die Hermitische Symetrie.
......@@ -40,11 +43,11 @@
*
*/
class ITA_BASE_API ITAHDFTSpectrum
{
public:
class ITA_BASE_API CHDFTSpectrum
{
public:
//! Standard-Konstruktor
ITAHDFTSpectrum();
CHDFTSpectrum();
//! Constructor
/**
......@@ -54,7 +57,7 @@ public:
* \param iDFTSize DFT-Spektrum-Gre
* \param bZeroInit Setzt den Speicher bei wahr auf Null
*/
explicit ITAHDFTSpectrum( const float fSampleRate, const int iDFTSize, const bool bZeroInit );
explicit CHDFTSpectrum( const float fSampleRate, const int iDFTSize, const bool bZeroInit );
//! Kopierkonstruktor (Zeiger)
/**
......@@ -64,7 +67,7 @@ public:
*
* \param pSource Zeiger auf das Quellspektrum
*/
explicit ITAHDFTSpectrum( const ITAHDFTSpectrum* pSource );
explicit CHDFTSpectrum( const CHDFTSpectrum* pSource );
//! Kopierkonstruktor (Referenz)
/**
......@@ -74,10 +77,10 @@ public:
*
* \param oSource Zeiger auf das Quellspektrum
*/
explicit ITAHDFTSpectrum( const ITAHDFTSpectrum& oSource );
explicit CHDFTSpectrum( const CHDFTSpectrum& oSource );
//! Destruktor
virtual ~ITAHDFTSpectrum();
virtual ~CHDFTSpectrum();
// Initialisieren
/**
......@@ -132,20 +135,20 @@ public:
void Sub( const float fReal, const float fImag = 0 );
// Spektrum addieren
void Add( const ITAHDFTSpectrum& s );
void Add( const ITAHDFTSpectrum* );
void Sub( const ITAHDFTSpectrum& s );
void Sub( const ITAHDFTSpectrum* );
void Mul( const ITAHDFTSpectrum& s );
void Add( const CHDFTSpectrum& s );
void Add( const CHDFTSpectrum* );
void Sub( const CHDFTSpectrum& s );
void Sub( const CHDFTSpectrum* );
void Mul( const CHDFTSpectrum& s );
void Mul( const float fFactor );
void Mul( const ITAHDFTSpectrum* );
void Mul( const CHDFTSpectrum* );
//! Multiplies the conjugate of the given spectrum without data copy
void MulConj( const ITAHDFTSpectrum* );
void MulConj( const CHDFTSpectrum* );
//! Devide spectrum
void Div( const ITAHDFTSpectrum& s );
void Div( const ITAHDFTSpectrum* );
void Div( const CHDFTSpectrum& s );
void Div( const CHDFTSpectrum* );
//! Betragsspektrum berechnen und in gegebenes Array speichern
// Zeiger drfen Null sein
......@@ -189,11 +192,11 @@ public:
void Exp( const bool bComplex = true );
//! Alle Filterkoeffizienten eines anderen Spektrums in dieses kopieren
void CopyFrom( const ITAHDFTSpectrum& s );
void Copy( const ITAHDFTSpectrum* );
void CopyFrom( const CHDFTSpectrum& s );
void Copy( const CHDFTSpectrum* );
//! Einen Teil der Filterkoeffizienten eines anderen Spektrums in dieses kopieren
void CopyFrom( const ITAHDFTSpectrum& s, const int iOffset, const int iCount );
void CopyFrom( const CHDFTSpectrum& s, const int iOffset, const int iCount );
//! Zuweisungsoperator
/**
......@@ -201,7 +204,7 @@ public:
* Hierzu wird zunchst die Gre des Spektrums angepasst.
* Anschlieend werden alle Koeffizienten kopiert.
*/
ITAHDFTSpectrum& operator=( const ITAHDFTSpectrum& rhs );
CHDFTSpectrum& operator=( const CHDFTSpectrum& rhs );
//! Zeichenkette mit den Werten zurckgeben
std::string ToString();
......@@ -213,12 +216,14 @@ public:
float GetEnergy() const;
private:
private:
int m_iSize;
int m_iDFTSize;
float m_fSampleRate;
mutable std::vector< float > m_vfData;
};
};
}
#endif // __ITA_HDFT_SPECTRUM_H__
......@@ -22,20 +22,23 @@
#include <ITABaseDefinitions.h>
#include <ITASpectrum.h>
// Forward for aliasing classes
class CITAGainMagnitudeSpectrum;
namespace ITABase
{
// Forward for aliasing classes
class CGainMagnitudeSpectrum;
//! A factor magnitude spectrum with linear values that are greater zero and usually between 0..1, but can also exceed.
/**
//! A factor magnitude spectrum with linear values that are greater zero and usually between 0..1, but can also exceed.
/**
* This alias class is used to give the user a hint that the underlying data should be treated as linear values (factors)
* or gains, because a magnitude spectrum does not specify on that. It is used like a CITAMagnitudeSpectrum.
* There is no real difference between a factor and a gain except that gains are commonly used in DSP (i.e. for "gain" control
* of audio signal channels) and factors are more common in acoustic materials such as absorption and transmission "factor".
*/
typedef CITAGainMagnitudeSpectrum CITAFactorMagnitudeSpectrum;
typedef CGainMagnitudeSpectrum CFactorMagnitudeSpectrum;
//! Magnitude spectrum of arbitrary size and base frequencies
/**
//! Magnitude spectrum of arbitrary size and base frequencies
/**
* Implementation class for magnitude spectra, that does not specify on underlying data. To be more precise in your code and
* for validation of data it is recommended to use the alias classes CITADecibelMagnitudeSpectrum, CITAGainMagnitudeSpectrum or CITAFactorMagnitudeSpectrum,
* which implement the abstract methods and are ready to use.
......@@ -45,11 +48,11 @@ typedef CITAGainMagnitudeSpectrum CITAFactorMagnitudeSpectrum;
* @sa CITAThirdOctaveSpectrum, CITAPhaseSpectrum, CITAHDFTSpectrum
*
*/
class ITA_BASE_API CITAMagnitudeSpectrum : public CITASpectrum
{
public:
CITAMagnitudeSpectrum( const int nNumBands );
virtual inline ~CITAMagnitudeSpectrum() {};
class ITA_BASE_API CMagnitudeSpectrum : public CITASpectrum
{
public:
CMagnitudeSpectrum( const int nNumBands );
virtual inline ~CMagnitudeSpectrum() {};
std::vector< float > GetMagnitudesCopy() const;
const std::vector< float >& GetMagnitudes() const;
......@@ -57,41 +60,43 @@ public:
void SetMagnitudes( const std::vector< float >& vfMagnitudes );
void SetMagnitude( const int iFrequencyBandIndex, const float fMagnitudeValue );
bool CompareEqualValues( const CITAMagnitudeSpectrum& oOtherSpectrum, const float fThreshold = 10.0e-10 ) const;
};
bool CompareEqualValues( const CMagnitudeSpectrum& oOtherSpectrum, const float fThreshold = 10.0e-10 ) const;
};
//! A decibel magnitude spectrum with values that have been transformed into logarithmic scale. Values are mostly between -\infinity and 0, but can also exceed.
/**
* This alias class is used to give the user a hint that the underlying data should be treated as decibel values (log scale),
* because a magnitude spectrum does not specify on that. It is used like a CITAMagnitudeSpectrum.
*/
class ITA_BASE_API CITADecibelMagnitudeSpectrum : public CITAMagnitudeSpectrum
{
public:
CITADecibelMagnitudeSpectrum( const int nNumBands );
virtual ~CITADecibelMagnitudeSpectrum();
//! A decibel magnitude spectrum with values that have been transformed into logarithmic scale. Values are mostly between -\infinity and 0, but can also exceed.
/**
* This alias class is used to give the user a hint that the underlying data should be treated as decibel values (log scale),
* because a magnitude spectrum does not specify on that. It is used like a CITAMagnitudeSpectrum.
*/
class ITA_BASE_API CDecibelMagnitudeSpectrum : public CMagnitudeSpectrum
{
public:
CDecibelMagnitudeSpectrum( const int nNumBands );
virtual ~CDecibelMagnitudeSpectrum();
void SetIdentity();
void SetZero();
bool IsIdentity() const;
bool IsZero() const;
};
};
//! A gain magnitude spectrum with linear values that are greater zero and usually between 0..1, but can also exceed.
/**
//! A gain magnitude spectrum with linear values that are greater zero and usually between 0..1, but can also exceed.
/**
* @sa CITAFactorMagnitudeSpectrum
*/
class ITA_BASE_API CITAGainMagnitudeSpectrum : public CITAMagnitudeSpectrum
{
public:
CITAGainMagnitudeSpectrum( const int nNumBands );
virtual ~CITAGainMagnitudeSpectrum();
class ITA_BASE_API CGainMagnitudeSpectrum : public CMagnitudeSpectrum
{
public:
CGainMagnitudeSpectrum( const int nNumBands );
virtual ~CGainMagnitudeSpectrum();
void SetIdentity();
void SetZero();
bool IsIdentity() const;
bool IsZero() const;
};
};
}
#endif // INCLUDE_WATCHER_ITA_MAGNITUDE_SPECTRUM
......@@ -23,19 +23,22 @@
#include <ITAMagnitudeSpectrum.h>
#include <ITAConstants.h>
//! Third octave magnitude spectrum
/**
namespace ITABase
{
//! Third octave magnitude spectrum
/**
* Class for third octave magnitude spectra with predefined center frequencies.
*
* Will raise CITAException on errors.
*
* @sa CITAWholeOctaveMagnitudeSpectrum
*/
class CITAThirdOctaveMagnitudeSpectrum : public CITAMagnitudeSpectrum
{
public:
inline CITAThirdOctaveMagnitudeSpectrum()
: CITAMagnitudeSpectrum( GetNumBands() )
class CThirdOctaveMagnitudeSpectrum : public CMagnitudeSpectrum
{
public:
inline CThirdOctaveMagnitudeSpectrum()
: CMagnitudeSpectrum( GetNumBands() )
{
m_vfCenterFrequencies = GetCenterFrequencies();
};
......@@ -47,36 +50,31 @@ public:
inline static std::vector< float > GetCenterFrequencies()
{
return
{
20, 25, 31.5f, 40, 50, 63, 80, 100, 125, 160, 200,
250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000,
2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000
};
return ITAConstants::THIRD_OCTAVE_CENTER_FREQUENCIES_ISO_F;
};
virtual inline ~CITAThirdOctaveMagnitudeSpectrum() {};
virtual inline ~CThirdOctaveMagnitudeSpectrum() {};
virtual inline bool CompareEqualValues( const CITAThirdOctaveMagnitudeSpectrum& oOtherSpectrum, const float fThreshold = 10.0e-10 )
virtual inline bool CompareEqualValues( const CThirdOctaveMagnitudeSpectrum& oOtherSpectrum, const float fThreshold = 10.0e-10 )
{
return CITASpectrum::CompareEqualValues( oOtherSpectrum, fThreshold );
};
protected:
protected:
void SetCenterFrequencies( const std::vector< float >& vfCenterFrequencies );
};
};
//! Implementation of magnitude spectrum for gain values
class CITAThirdOctaveGainMagnitudeSpectrum : public CITAThirdOctaveMagnitudeSpectrum
{
public:
inline CITAThirdOctaveGainMagnitudeSpectrum()
: CITAThirdOctaveMagnitudeSpectrum()
//! Implementation of magnitude spectrum for gain values
class CThirdOctaveGainMagnitudeSpectrum : public CThirdOctaveMagnitudeSpectrum
{
public:
inline CThirdOctaveGainMagnitudeSpectrum()
: CThirdOctaveMagnitudeSpectrum()
{
};
virtual ~CITAThirdOctaveGainMagnitudeSpectrum() {};
virtual ~CThirdOctaveGainMagnitudeSpectrum() {};
inline void SetIdentity()
{
......@@ -111,26 +109,26 @@ public:
return true;
};
};
};
//! A factor magnitude spectrum with linear values that are greater zero and usually between 0..1, but can also exceed.
/**
//! A factor magnitude spectrum with linear values that are greater zero and usually between 0..1, but can also exceed.
/**
* This alias class is used to give the user a hint that the underlying data should be treated as linear values (factors)
* or gains, because a magnitude spectrum does not specify on that. It is used like a CITAThirdOctaveMagnitudeSpectrum.
* There is no real difference between a factor and a gain except that gains are commonly used in DSP (i.e. for "gain" control
* of audio signal channels) and factors are more common in acoustic materials such as absorption and transmission "factor".
*/
typedef CITAThirdOctaveGainMagnitudeSpectrum CITAThirdOctaveFactorMagnitudeSpectrum;
typedef CThirdOctaveGainMagnitudeSpectrum CITAThirdOctaveFactorMagnitudeSpectrum;
//! A decibel magnitude spectrum with values that have been transformed into logarithmic scale. Values are mostly between -\infinity and 0, but can also exceed.
class CITAThirdOctaveDecibelMagnitudeSpectrum : public CITAThirdOctaveMagnitudeSpectrum
{
public:
//! A decibel magnitude spectrum with values that have been transformed into logarithmic scale. Values are mostly between -\infinity and 0, but can also exceed.
class CITAThirdOctaveDecibelMagnitudeSpectrum : public CThirdOctaveMagnitudeSpectrum
{
public:
inline CITAThirdOctaveDecibelMagnitudeSpectrum()
: CITAThirdOctaveMagnitudeSpectrum()
: CThirdOctaveMagnitudeSpectrum()
{
};
......@@ -170,6 +168,8 @@ public:
return true;
};
};
};
}
#endif // INCLUDE_WATCHER_ITA_THIRD_OCTAVE_MAGNITUDE_SPECTRUM
......@@ -21,10 +21,14 @@
#include <ITABaseDefinitions.h>
#include <ITAMagnitudeSpectrum.h>
#include <ITAConstants.h>
//! Third octave Magnitude spectrum
/**
namespace ITABase
{
//! Third octave Magnitude spectrum
/**
* Class for third octave magnitude spectra with predefined center frequencies.
*
* Will raise CITAException on errors.
......@@ -32,19 +36,21 @@
* @sa
*
*/
class ITA_BASE_API CITAThirdOctaveMagnitudeSpectrum : public CITAMagnitudeSpectrum
{
public:
inline CITAThirdOctaveMagnitudeSpectrum()
: CITAMagnitudeSpectrum( 10 )
class ITA_BASE_API CThirdOctaveMagnitudeSpectrum : public CMagnitudeSpectrum
{
m_vfCenterFrequencies = { 31.5f, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000 };
public:
inline CThirdOctaveMagnitudeSpectrum()
: CMagnitudeSpectrum( 10 )
{
m_vfCenterFrequencies = ITAConstants::OCTAVE_CENTER_FREQUENCIES_ISO_F;
};
virtual inline ~CITAThirdOctaveMagnitudeSpectrum() {};
virtual inline ~CThirdOctaveMagnitudeSpectrum() {};
protected:
protected:
void SetCenterFrequencies( const std::vector<float>& vfCenterFrequencies );
};
};
}
#endif // INCLUDE_WATCHER_ITA_THIRD_OCTAVE_MAGNITUDE_SPECTRUM
#include <ITAFiniteImpulseResponse.h>
CITAFiniteImpulseResponse::CITAFiniteImpulseResponse()
using namespace ITABase;
CFiniteImpulseResponse::CFiniteImpulseResponse()
: m_fSampleRate( 0 )
{
}
CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const int iLength, const float fSampleRate, const bool bZeroInit /*= true */ )
CFiniteImpulseResponse::CFiniteImpulseResponse( const int iLength, const float fSampleRate, const bool bZeroInit /*= true */ )
: ITASampleBuffer( iLength, bZeroInit )
, m_fSampleRate( fSampleRate )
{
}
CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const CITAFiniteImpulseResponse* pSource )
CFiniteImpulseResponse::CFiniteImpulseResponse( const CFiniteImpulseResponse* pSource )
{
Init( pSource->GetLength(), pSource->GetSampleRate() );
ITASampleBuffer::write( pSource, pSource->GetLength() );
}
CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const CITAFiniteImpulseResponse& sbSource )
CFiniteImpulseResponse::CFiniteImpulseResponse( const CFiniteImpulseResponse& sbSource )
{
Init( sbSource.GetLength(), sbSource.GetSampleRate() );
ITASampleBuffer::write( sbSource, sbSource.GetLength() );
}
void CITAFiniteImpulseResponse::Init( const int iLength, const float fSampleRate, const bool bZeroInit /*= true */ )
void CFiniteImpulseResponse::Init( const int iLength, const float fSampleRate, const bool bZeroInit /*= true */ )
{
m_fSampleRate = fSampleRate;
ITASampleBuffer::Init( iLength, bZeroInit );
}
float CITAFiniteImpulseResponse::GetSampleRate() const
float CFiniteImpulseResponse::GetSampleRate() const
{
return m_fSampleRate;
}
float CITAFiniteImpulseResponse::GetNyquistFrequency() const
float CFiniteImpulseResponse::GetNyquistFrequency() const
{
return GetSampleRate() / 2.0f;
}
......@@ -7,7 +7,7 @@
#include <ITASampleFrame.h>
#include <ITAStringUtils.h>
ITAHDFTSpectra::ITAHDFTSpectra( const float fSampleRate, const int iNumChannels, const int iDFTSize, const bool bZeroInit/*=true*/ )
ITABase::CHDFTSpectra::CHDFTSpectra( const float fSampleRate, const int iNumChannels, const int iDFTSize, const bool bZeroInit/*=true*/ )
{
if( iNumChannels < 1 )
ITA_EXCEPT1( INVALID_PARAMETER, "At least one DFT channel must be used" );
......@@ -15,34 +15,34 @@ ITAHDFTSpectra::ITAHDFTSpectra( const float fSampleRate, const int iNumChannels,
ITA_EXCEPT1( INVALID_PARAMETER, "Invalid DFT size" );
for( int i = 0; i < iNumChannels; i++ )
m_vpSpectra.push_back( new ITAHDFTSpectrum( fSampleRate, iDFTSize, bZeroInit ) );
m_vpSpectra.push_back( new CHDFTSpectrum( fSampleRate, iDFTSize, bZeroInit ) );
}
ITAHDFTSpectra::ITAHDFTSpectra( const std::vector< ITAHDFTSpectrum* >& vpSpectrumVec )
ITABase::CHDFTSpectra::CHDFTSpectra( const std::vector< ITABase::CHDFTSpectrum* >& vpSpectrumVec )
{
if( vpSpectrumVec.size() == 0 )
ITA_EXCEPT1( INVALID_PARAMETER, "At least one DFT channel must be used" );
for( size_t i = 0; i < vpSpectrumVec.size(); i++ )
{
const ITAHDFTSpectrum* pSpectrum( vpSpectrumVec[ i ] );
const ITABase::CHDFTSpectrum* pSpectrum( vpSpectrumVec[ i ] );
if( pSpectrum->GetDFTSize() <= 0 )
ITA_EXCEPT1( INVALID_PARAMETER, "Invalid DFT size in spectrum number " + IntToString( int( i ) ) );
if( pSpectrum->GetSampleRate() <= 0 )
ITA_EXCEPT1( INVALID_PARAMETER, "Invalid sampling rate in spectrum number " + IntToString( int( i ) ) );
m_vpSpectra.push_back( new ITAHDFTSpectrum( pSpectrum ) ); // copy
m_vpSpectra.push_back( new ITABase::CHDFTSpectrum( pSpectrum ) ); // copy
}
}
ITAHDFTSpectra::~ITAHDFTSpectra()
ITABase::CHDFTSpectra::~CHDFTSpectra()
{
for( size_t i = 0; i < m_vpSpectra.size(); i++ )
delete m_vpSpectra[ i ];
}
float ITAHDFTSpectra::GetMaxEnergy( int* piIdx ) const
float ITABase::CHDFTSpectra::GetMaxEnergy( int* piIdx ) const
{
float fEnergyTemp;
float fEnergyMax = -1.0f;
......@@ -59,7 +59,7 @@ float ITAHDFTSpectra::GetMaxEnergy( int* piIdx ) const
return fEnergyMax;
}
void ITAHDFTSpectra::CopyFrom( const ITAHDFTSpectra *otherSpectra )
void ITABase::CHDFTSpectra::CopyFrom( const ITABase::CHDFTSpectra *otherSpectra )
{
int iNumChannels = otherSpectra->GetNumChannels();
......@@ -68,130 +68,131 @@ void ITAHDFTSpectra::CopyFrom( const ITAHDFTSpectra *otherSpectra )
for( int i = 0; i < iNumChannels; i++ )
{
//ITAHDFTSpectrum* tempSpectrum = new ITAHDFTSpectrum(double(otherSpectra->GetSampleRate()),int(otherSpectra->GetDFTSize()));
ITAHDFTSpectrum* tempSpectrum = new ITAHDFTSpectrum( ( *otherSpectra )[ i ] );
ITABase::CHDFTSpectrum* tempSpectrum = new ITABase::CHDFTSpectrum( ( *otherSpectra )[ i ] );
//tempSpectrum->copyFrom((*otherSpectra)[i]);
m_vpSpectra.push_back( tempSpectrum );
}
}
void ITAHDFTSpectra::SetUnity()
void ITABase::CHDFTSpectra::SetUnity()
{