Adding amplitude spectrum

parent ab335b4c
......@@ -49,6 +49,7 @@ include_directories( "include" )
# files
set( ITABaseHeader
"include/ITAASCIITable.h"
"include/ITAAmplitudeSpectrum.h"
"include/ITABaseDefinitions.h"
"include/ITABlockMath.h"
"include/ITABufferedAudioFileWriter.h"
......@@ -87,6 +88,7 @@ set( ITABaseHeader
)
set( ITABaseSources
"src/ITAASCIITable.cpp"
"src/ITAAmplitudeSpectrum.cpp"
"src/ITABlockMath.cpp"
"src/ITABufferedAudioFileWriter.cpp"
"src/ITAClock.cpp"
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_AMPLITUDE_SPECTRUM
#define INCLUDE_WATCHER_ITA_AMPLITUDE_SPECTRUM
#include <ITABaseDefinitions.h>
#include <ITASpectrum.h>
//! Amplitude spectrum of arbitrary size and base frequencies
/**
* Class for amplitude spectra, that is intended to be used with linear values (gains).
*
* Will raise CITAException on errors.
*
* @sa CITAMAgnitudeSpectrum, CITAPhaseSpectrum, CITAHDFTSpectrum
*
*/
class ITA_BASE_API CITAAmplitudeSpectrum : public CITASpectrum
{
public:
CITAAmplitudeSpectrum( const int nNumBands );
virtual inline ~CITAAmplitudeSpectrum() {};
std::vector< float > GetAmplitudesCopy() const;
const std::vector< float >& GetAmplitudes() const;
void SetAmplitudes( const std::vector< float >& vfAmplitudes );
void SetAmplitude( const int iFrequencyBandIndex, const float fAmplitudeValue );
void SetIdentity();
void SetZero();
bool IsIdentity() const;
bool IsZero() const;
bool CompareEqualValues( const CITAAmplitudeSpectrum& oOtherSpectrum, const float fThreshold = 10.0e-10 ) const;
};
#endif // INCLUDE_WATCHER_ITA_AMPLITUDE_SPECTRUM
#include <ITAAmplitudeSpectrum.h>
#include <ITAConstants.h>
#include <numeric>
CITAAmplitudeSpectrum::CITAAmplitudeSpectrum( const int nNumBands )
: CITASpectrum( nNumBands )
{
SetValueUnit( "factor" );
}
std::vector< float > CITAAmplitudeSpectrum::GetAmplitudesCopy() const
{
return CITASpectrum::GetValuesCopy();
}
const std::vector< float >& CITAAmplitudeSpectrum::GetAmplitudes() const
{
return CITASpectrum::GetValues();
}
void CITAAmplitudeSpectrum::SetAmplitudes( const std::vector< float >& vfAmplitudes )
{
CITASpectrum::SetValues( vfAmplitudes );
}
void CITAAmplitudeSpectrum::SetAmplitude( const int iFrequencyBandIndex, const float fAmplitudeValue )
{
CITASpectrum::SetValue( iFrequencyBandIndex, fAmplitudeValue );
}
void CITAAmplitudeSpectrum::SetIdentity()
{
std::fill( m_vfValues.begin(), m_vfValues.end(), 1.0f );
}
void CITAAmplitudeSpectrum::SetZero()
{
std::fill( m_vfValues.begin(), m_vfValues.end(), 0.0f );
}
bool CITAAmplitudeSpectrum::IsIdentity() const
{
for( size_t n = 0; n < m_vfValues.size(); n++ )
{
if( m_vfValues[ n ] != 1.0f )
return false;
}
return true;
}
bool CITAAmplitudeSpectrum::IsZero() const
{
for( size_t n = 0; n < m_vfValues.size(); n++ )
{
if( m_vfValues[ n ] != 0.0f )
return false;
}
return true;
}
......@@ -60,4 +60,3 @@ bool CITAMagnitudeSpectrum::IsZero() const
return true;
}
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