ITAMagnitudeSpectrum.cpp 2.56 KB
Newer Older
1 2 3 4
#include <ITAMagnitudeSpectrum.h>
#include <ITAConstants.h>

#include <numeric>
5
#include <limits>
6

7

8
ITABase::CMagnitudeSpectrum::CMagnitudeSpectrum( const int nNumBands )
9 10 11 12
	: CITASpectrum( nNumBands )
{
}

13
std::vector< float > ITABase::CMagnitudeSpectrum::GetMagnitudesCopy() const
14 15 16 17
{
	return CITASpectrum::GetValuesCopy();
}

18
const std::vector< float >& ITABase::CMagnitudeSpectrum::GetMagnitudes() const
19 20 21 22
{
	return CITASpectrum::GetValues();
}

23
void ITABase::CMagnitudeSpectrum::SetMagnitudes( const std::vector< float >& vfMagnitudes )
24 25 26 27
{
	CITASpectrum::SetValues( vfMagnitudes );
}

28
void ITABase::CMagnitudeSpectrum::SetMagnitude( const int iFrequencyBandIndex, const float fMagnitudeValue )
29 30 31 32
{
	CITASpectrum::SetValue( iFrequencyBandIndex, fMagnitudeValue );
}

33 34
// ----- ----------- -------------------

35
ITABase::CDecibelMagnitudeSpectrum::CDecibelMagnitudeSpectrum( const int iNumBands )
36
	: CMagnitudeSpectrum( iNumBands )
37 38 39 40
{
	CITASpectrum::SetValueUnit( "dB" );
}

41
ITABase::CDecibelMagnitudeSpectrum::~CDecibelMagnitudeSpectrum()
42 43 44 45
{

}

46
void ITABase::CDecibelMagnitudeSpectrum::SetIdentity()
47
{
48 49
	for( size_t n = 0; n < m_vfValues.size(); n++ )
		m_vfValues[ n ] = 0;
50 51
}

52
void ITABase::CDecibelMagnitudeSpectrum::SetZero()
53
{
54 55
	for( size_t n = 0; n < m_vfValues.size(); n++ )
		m_vfValues[ n ] = -std::numeric_limits< float >::infinity();
56 57
}

58
bool ITABase::CDecibelMagnitudeSpectrum::IsIdentity() const
59 60 61 62 63 64 65 66 67 68
{
	for( size_t n = 0; n < m_vfValues.size(); n++ )
	{
		if( m_vfValues[ n ] != 0.0f )
			return false;
	}

	return true;
}

69
bool ITABase::CDecibelMagnitudeSpectrum::IsZero() const
70 71 72 73 74 75 76 77 78
{
	for( size_t n = 0; n < m_vfValues.size(); n++ )
	{
		if( m_vfValues[ n ] != -std::numeric_limits< float >::infinity() )
			return false;
	}

	return true;
}
79 80 81

// ----- ----------- -------------------

82
ITABase::CGainMagnitudeSpectrum::CGainMagnitudeSpectrum( const int iNumBands )
83
	: CMagnitudeSpectrum( iNumBands )
84 85 86 87
{
	CITASpectrum::SetValueUnit( "gain" );
}

88
ITABase::CGainMagnitudeSpectrum::~CGainMagnitudeSpectrum()
89 90 91 92
{

}

93
void ITABase::CGainMagnitudeSpectrum::SetIdentity()
94 95 96 97 98
{
	for( size_t n = 0; n < m_vfValues.size(); n++ )
		m_vfValues[ n ] = 1.0f;
}

99
void ITABase::CGainMagnitudeSpectrum::SetZero()
100 101 102 103 104
{
	for( size_t n = 0; n < m_vfValues.size(); n++ )
		m_vfValues[ n ] = 0.0f;
}

105
bool ITABase::CGainMagnitudeSpectrum::IsIdentity() const
106 107 108 109 110 111 112 113 114 115
{
	for( size_t n = 0; n < m_vfValues.size(); n++ )
	{
		if( m_vfValues[ n ] != 1.0f )
			return false;
	}

	return true;
}

116
bool ITABase::CGainMagnitudeSpectrum::IsZero() const
117 118 119 120 121 122 123 124 125
{
	for( size_t n = 0; n < m_vfValues.size(); n++ )
	{
		if( m_vfValues[ n ] != 0.0f )
			return false;
	}

	return true;
}