ITAHDFTSpectra.h 2.78 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * ----------------------------------------------------------------
 *
 *		ITA core libs
 *		(c) Copyright Institute of Technical Acoustics (ITA)
 *		RWTH Aachen University, Germany, 2015-2017
 *
 * ----------------------------------------------------------------
 *				    ____  __________  _______
 *				   //  / //__   ___/ //  _   |
 *				  //  /    //  /    //  /_|  |
 *				 //  /    //  /    //  ___   |
 *				//__/    //__/    //__/   |__|
 *
 * ----------------------------------------------------------------
 *
 */

#ifndef INCLUDE_WATCHER_ITA_HDFT_SPECTRA
#define INCLUDE_WATCHER_ITA_HDFT_SPECTRA

// ITA includes
#include <ITABaseDefinitions.h>
#include <ITAException.h>

// STL includes
#include <vector>

class ITAHDFTSpectrum;

//! 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.
  *
  * This class extends the \ITAHDFTSpectrum for multi-channel applications.
  *
  */
class ITA_BASE_API ITAHDFTSpectra
{
public:

	//! Constructor that initializes the
	ITAHDFTSpectra( const double dSampleRate, const int iNumChannels, const int iDFTSize, const bool bZeroInit=true );

	//! Constructor that uses a non-empty HDFTSpectrum vector
	ITAHDFTSpectra( const std::vector< ITAHDFTSpectrum* >& vpSpectrumVec );

	//! Standard destructor
	~ITAHDFTSpectra();

	//! Return number of channels
	/**
	  * \return Number of spectra / dimension of filter
	  */
	int GetNumChannels() const;

	//! Return DFT size
	/**
	  * \return Number of coeffs + 1 for DC value
	  */
	int GetDFTSize() const;

	//! Return sampling rate
	double GetSampleRate() const;

	//! Adds the given spectra channel-wise
	void add( const ITAHDFTSpectra* );

	//! Subtracts the given spectra channel-wise
	void sub( const ITAHDFTSpectra* );

	//! Multiplies the given spectra channel-wise
	void mul( const ITAHDFTSpectra* );

	//! Multiplies the conjugate of the given spectra without data copy channel-wise
	void mul_conj( const ITAHDFTSpectra* );

	//! Multiplies a scalar
	void mul_scalar( double );

	//! Divides the given spectra channel-wise
	void div( const ITAHDFTSpectra* );

	//! Set unity (all coefficiants real one)
	void SetUnity();

	//! Set unity (all coefficiants real one)
	void SetZero();

	//! Copy from another Spectra
	void CopyFrom(const ITAHDFTSpectra* otherSpectra);

Michael Kohnen's avatar
Michael Kohnen committed
95
96
97
	//! Returns maximum energy from all spectra
	float GetMaxEnergy( int* piChannelIndex = nullptr ) const;

98
99
100
101
102
103
104
105
106
107
108
109
	//! Subscript operator gives direct access to spectrum channel
	const ITAHDFTSpectrum* operator[]( const int ) const;
	ITAHDFTSpectrum* operator[]( const int );

private:
	//! Standard constructor
	ITAHDFTSpectra();

	std::vector< ITAHDFTSpectrum* > m_vpSpectra; //! DFT spectra
};

#endif // INCLUDE_WATCHER_ITA_HDFT_SPECTRA