Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
ITABase
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITABase
Commits
29c5bb02
Commit
29c5bb02
authored
Jun 14, 2018
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introducing ITABaser namespace, starting with data classes
parent
6dc041dc
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
642 additions
and
602 deletions
+642
-602
include/ITAConstants.h
include/ITAConstants.h
+8
-1
include/ITAFiniteImpulseResponse.h
include/ITAFiniteImpulseResponse.h
+49
-44
include/ITAHDFTSpectra.h
include/ITAHDFTSpectra.h
+64
-59
include/ITAHDFTSpectrum.h
include/ITAHDFTSpectrum.h
+191
-186
include/ITAMagnitudeSpectrum.h
include/ITAMagnitudeSpectrum.h
+75
-70
include/ITAThirdOctaveMagnitudeSpectrum.h
include/ITAThirdOctaveMagnitudeSpectrum.h
+109
-109
include/ITAWholeOctaveMagnitudeSpectrum.h
include/ITAWholeOctaveMagnitudeSpectrum.h
+25
-19
src/ITAFiniteImpulseResponse.cpp
src/ITAFiniteImpulseResponse.cpp
+9
-7
src/ITAHDFTSpectra.cpp
src/ITAHDFTSpectra.cpp
+35
-34
src/ITAHDFTSpectrum.cpp
src/ITAHDFTSpectrum.cpp
+56
-54
src/ITAMagnitudeSpectrum.cpp
src/ITAMagnitudeSpectrum.cpp
+21
-19
No files found.
include/ITAConstants.h
View file @
29c5bb02
...
...
@@ -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.5
f
,
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.5
f
,
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.5
f
,
63
,
125
,
250
,
500
,
1000
,
2000
,
4000
,
8000
,
16000
};
static
std
::
vector
<
double
>
OCTAVE_CENTER_FREQUENCIES_ISO_D
=
{
31.5
f
,
63
,
125
,
250
,
500
,
1000
,
2000
,
4000
,
8000
,
16000
};
};
#endif // INCLUDE_WATCHER_ITA_CONSTANTS
include/ITAFiniteImpulseResponse.h
View file @
29c5bb02
...
...
@@ -25,62 +25,67 @@
#include <string>
//! 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
namespace
ITABase
{
public:
//! Create empty FIR filter
/**
* Requires initialization to be used, otherwise methods will throw ITAException.
*/
CITAFiniteImpulseResponse
();
//!
Create FIR filter of certain size with given sampling frequency
//!
Single channel finite impulse response class / FIR filter
/**
* \param iLength Length (size) of buffer in samples
* ITASampleBuffer with a sampling rate = finite impulse response.
* For multi channel FIR filter, @sa ITAMultichannelFiniteImpulseResponse
*/
explicit
CITAFiniteImpulseResponse
(
const
int
iLength
,
const
float
fSampleRate
,
const
bool
bZeroInit
=
true
);
class
ITA_BASE_API
CFiniteImpulseResponse
:
public
ITASampleBuffer
{
public:
//! Create empty FIR filter
/**
* Requires initialization to be used, otherwise methods will throw ITAException.
*/
CFiniteImpulseResponse
();
//! Copy constructor as pointer
/**
* \param pSource Pointer to source buffer
*/
CITAFiniteImpulseResponse
(
const
CITAFiniteImpulseResponse
*
pSourc
e
);
//! Create FIR filter of certain size with given sampling frequency
/**
* \param iLength Length (size) of buffer in samples
*/
explicit
CFiniteImpulseResponse
(
const
int
iLength
,
const
float
fSampleRate
,
const
bool
bZeroInit
=
tru
e
);
//! Copy constructor as reference
/**
* \param pbSource Reference
to source buffer
*/
CITAFiniteImpulseResponse
(
const
CITAFiniteImpulseResponse
&
sb
Source
);
//! Copy constructor as pointer
/**
* \param pSource Pointer
to source buffer
*/
CFiniteImpulseResponse
(
const
CFiniteImpulseResponse
*
p
Source
);
virtual
inline
~
CITAFiniteImpulseResponse
()
{};
//! Copy constructor as reference
/**
* \param pbSource Reference to source buffer
*/
CFiniteImpulseResponse
(
const
CFiniteImpulseResponse
&
sbSource
);
//! Sampling frequency of FIR filter (double of Nyquist frequency)
float
GetSampleRate
()
const
;
virtual
inline
~
CFiniteImpulseResponse
()
{};
//! Nyquist frequency of FIR filter (half of sample rate)
float
GetNyquistFrequency
()
const
;
//! Sampling frequency of FIR filter (double of Nyquist frequency)
float
GetSampleRate
()
const
;
//! Nyquist frequency of FIR filter (half of sample rate)
float
GetNyquistFrequency
()
const
;
//! Initialize
/**
* (Re-)Initialize a sample buffer
*
* @param[in] iLength Number of new samples
* @param[in] fSampleRate Sampling rate of FIR filter (double of Nyquist frequency)
* @param[in] bZeroInit Init with zeros
*/
void
Init
(
const
int
iLength
,
const
float
fSampleRate
,
const
bool
bZeroInit
=
true
);
//! Initialize
/**
* (Re-)Initialize a sample buffer
*
* @param[in] iLength Number of new samples
* @param[in] fSampleRate Sampling rate of FIR filter (double of Nyquist frequency)
* @param[in] bZeroInit Init with zeros
*/
void
Init
(
const
int
iLength
,
const
float
fSampleRate
,
const
bool
bZeroInit
=
true
);
private:
//! Disable this Init method from sample buffer
void
Init
(
int
,
bool
);
private:
//! Disable this Init method from sample buffer
void
Init
(
int
,
bool
);
float
m_fSampleRate
;
//!< Sampling rate
};
float
m_fSampleRate
;
//!< Sampling rate
};
}
#endif // INCLUDE_WATCHER_ITA_FINITE_IMPULSE_RESPONSE
include/ITAHDFTSpectra.h
View file @
29c5bb02
...
...
@@ -26,84 +26,89 @@
// 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
namespace
ITABase
{
public:
//! Constructor that initializes the
ITAHDFTSpectra
(
const
float
fSampleRate
,
const
int
iNumChannels
,
const
int
iDFTSize
,
const
bool
bZeroInit
=
true
);
class
CHDFTSpectrum
;
//! Constructor that uses a non-empty HDFTSpectrum vector
ITAHDFTSpectra
(
const
std
::
vector
<
ITAHDFTSpectrum
*
>&
vpSpectrumVec
);
//! Standard destructor
~
ITAHDFTSpectra
();
//! Return number of channels
//! Multi-channel half-sided discrete fourier spectra
/**
* \return Number of spectra / dimension of filter
*
* 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.
*
*/
int
GetNumChannels
()
const
;
class
ITA_BASE_API
CHDFTSpectra
{
public:
//! Return DFT size
/**
* \return Number of coeffs + 1 for DC value
*/
int
GetDFTSize
()
const
;
//! Constructor that initializes the
CHDFTSpectra
(
const
float
fSampleRate
,
const
int
iNumChannels
,
const
int
iDFTSize
,
const
bool
bZeroInit
=
true
);
//! Constructor that uses a non-empty HDFTSpectrum vector
CHDFTSpectra
(
const
std
::
vector
<
CHDFTSpectrum
*
>&
vpSpectrumVec
);
//! Standard destructor
~
CHDFTSpectra
();
//! 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
;
//! Return sampling rat
e
double
GetSampleRate
()
const
;
//! Adds the given spectra channel-wis
e
void
add
(
const
CHDFTSpectra
*
)
;
//! Add
s the given spectra channel-wise
void
add
(
const
ITA
HDFTSpectra
*
);
//! Subtract
s the given spectra channel-wise
void
sub
(
const
C
HDFTSpectra
*
);
//! Subtract
s the given spectra channel-wise
void
sub
(
const
ITA
HDFTSpectra
*
);
//! Multiplie
s the given spectra channel-wise
void
mul
(
const
C
HDFTSpectra
*
);
//! Multiplies the given spectra
channel-wise
void
mul
(
const
ITA
HDFTSpectra
*
);
//! Multiplies the conjugate of the given spectra without data copy
channel-wise
void
mul_conj
(
const
C
HDFTSpectra
*
);
//! Multiplies the conjugate of the given spectra without data copy channel-wise
void
mul_conj
(
const
ITAHDFTSpectra
*
);
//! Multiplies a scalar
void
mul_scalar
(
double
);
//! Multiplies a scalar
void
mul_scalar
(
double
);
//! Divides the given spectra channel-wise
void
div
(
const
CHDFTSpectra
*
);
//! 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
SetUnity
();
//! Set unity (all coefficiants real one)
void
SetZero
();
//! Set unity (all coefficiants real one)
void
SetZero
(
);
//! Copy from another Spectra
void
CopyFrom
(
const
CHDFTSpectra
*
otherSpectra
);
//! Copy from another S
pectra
void
CopyFrom
(
const
ITAHDFTSpectra
*
otherSpectra
)
;
//! Returns maximum energy from all s
pectra
float
GetMaxEnergy
(
int
*
piChannelIndex
=
nullptr
)
const
;
//! Returns maximum energy from all spectra
float
GetMaxEnergy
(
int
*
piChannelIndex
=
nullptr
)
const
;
//! Subscript operator gives direct access to spectrum channel
const
CHDFTSpectrum
*
operator
[](
const
int
)
const
;
CHDFTSpectrum
*
operator
[](
const
int
);
//! Subscript operator gives direct access to spectrum channel
const
ITAHDFTSpectrum
*
operator
[](
const
int
)
const
;
ITAHDFTSpectrum
*
operator
[](
const
int
);
private:
//! Standard constructor
CHDFTSpectra
(
);
private:
//! Standard constructor
ITAHDFTSpectra
();
std
::
vector
<
CHDFTSpectrum
*
>
m_vpSpectra
;
//! DFT spectra
};
std
::
vector
<
ITAHDFTSpectrum
*
>
m_vpSpectra
;
//! DFT spectra
};
}
#endif // INCLUDE_WATCHER_ITA_HDFT_SPECTRA
include/ITAHDFTSpectrum.h
View file @
29c5bb02
...
...
@@ -25,200 +25,205 @@
#include <string>
#include <vector>
/**
* 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.
* Daher mssen von n komplexwertigen diskreten Fourierkoeffizienten eines
* vollstndigen DFT-Spektrums nur n/2+1 komplexwertigen Koeffizienten
* gespeichert werden.
*
* Grundstzlich werden die komplexwertigen Fourierkoeffizienten im
* interleaved Speicherlayout abgelegt, d.h. Re(0), Im(0), Re(1), Im(1), ...
*
* Die Klasse stellt Methoden fr die Arbeit mit solchen Spektren bereit.
*
*/
class
ITA_BASE_API
ITAHDFTSpectrum
namespace
ITABase
{
public:
//! Standard-Konstruktor
ITAHDFTSpectrum
();
//! Constructor
/**
* Erzeugt ein Spektrum mit vorgegebener Gre und optional zu Null gesetztem Puffer
*
* \param fSampleRate Sampling rate
* \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
);
//! Kopierkonstruktor (Zeiger)
/**
* Erzeugt einen unabhngiges Spektrum als Kopie des gegebenen Spektrums.
* Das neue Spektrum hat die selbe Lnge und enthlt die gleichen Werte
* wie das Quellspektrum.
* 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.
* Daher mssen von n komplexwertigen diskreten Fourierkoeffizienten eines
* vollstndigen DFT-Spektrums nur n/2+1 komplexwertigen Koeffizienten
* gespeichert werden.
*
* \param pSource Zeiger auf das Quellspektrum
*/
explicit
ITAHDFTSpectrum
(
const
ITAHDFTSpectrum
*
pSource
);
//! Kopierkonstruktor (Referenz)
/**
* Erzeugt einen unabhngiges Spektrum als Kopie des gegebenen Spektrums.
* Das neue Spektrum hat die selbe Lnge und enthlt die gleichen Werte
* wie das Quellspektrum.
* Grundstzlich werden die komplexwertigen Fourierkoeffizienten im
* interleaved Speicherlayout abgelegt, d.h. Re(0), Im(0), Re(1), Im(1), ...
*
* Die Klasse stellt Methoden fr die Arbeit mit solchen Spektren bereit.
*
* \param oSource Zeiger auf das Quellspektrum
*/
explicit
ITAHDFTSpectrum
(
const
ITAHDFTSpectrum
&
oSource
);
//! Destruktor
virtual
~
ITAHDFTSpectrum
();
// Initialisieren
/**
* init(0) gibt belegten Speicher frei
* vorherige Werte werden grundstzlich verworfen!
*/
void
Init
(
const
int
iDFTSize
,
const
bool
bZeroinit
=
true
);
// Gre des Spektrums (Anzahl Koeffizienten insgesamt) zurckgeben
// Hinweis: Symmetrische Koeffizienten werden hier nicht mitgezhlt.
int
GetSize
()
const
;
// Lnge des korrespondieren Zeitsignals zurckgeben (Gre der DFT)
int
GetDFTSize
()
const
;
// Abtastrate des korrespondieren Zeitsignals zurckgeben
float
GetSampleRate
()
const
;
// Abtastrate des korrespondieren Zeitsignals setzen
void
SetSampleRate
(
const
float
fSampleRate
);
// Frequenzauflsung des Spektrums [Hz] zurckgeben
float
GetFrequencyResolution
()
const
;
// Datenzeiger abrufen
float
*
GetData
()
const
;
// DFT Koeffizient(en) setzen (Real-/Imaginrteil bzw. Betrag/Phase)
void
SetCoeffRI
(
const
int
iIndex
,
const
float
fReal
,
const
float
fImag
=
0
);
void
SetCoeffsRI
(
const
float
fReal
,
const
float
fImag
=
0
);
void
SetCoeffsRI
(
const
int
iOffset
,
const
int
iCount
,
const
float
fReal
,
const
float
fImag
=
0
);
//! Set coefficient by index
void
SetCoeff
(
const
int
iIndex
,
std
::
complex
<
float
>&
cfCoeff
);
void
SetCoeffMP
(
const
int
iIndex
,
const
float
fMagnitude
,
const
float
fPhase
);
void
SetCoeffsMP
(
const
float
fMagnitude
,
const
float
fPhase
);
void
SetCoeffsMP
(
const
int
iOffset
,
const
int
iCount
,
const
float
fMagnitude
,
const
float
fPhase
);
//! Betragswert setzen, vorhandene Phasen erhalten
void
SetMagnitudePreservePhase
(
const
int
iIndex
,
const
float
fMagnitude
);
void
SetMagnitudesPreservePhases
(
const
float
fMagnitude
);
void
SetMagnitudesPreservePhases
(
const
int
iOffset
,
const
int
iCount
,
const
float
fMagnitude
);
//! Phase setzen, vorhandene Betrge erhalten
void
SetPhasePreserveMagnitude
(
const
int
iIndex
,
const
float
fPhase
);
void
SetPhasesPreserveMagnitudes
(
const
float
fPhase
);
void
SetPhasesPreserveMagnitudes
(
const
int
iOffset
,
const
int
iCount
,
const
float
fPhase
);
// Konstante addieren
void
Add
(
const
float
fReal
,
const
float
fImag
=
0
);
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
Mul
(
const
float
fFactor
);
void
Mul
(
const
ITAHDFTSpectrum
*
);
//! Multiplies the conjugate of the given spectrum without data copy
void
MulConj
(
const
ITAHDFTSpectrum
*
);
//! Devide spectrum
void
Div
(
const
ITAHDFTSpectrum
&
s
);
void
Div
(
const
ITAHDFTSpectrum
*
);
//! Betragsspektrum berechnen und in gegebenes Array speichern
// Zeiger drfen Null sein
void
CalcMagnitudes
(
float
*
pfMagnitudes
)
const
;
//! Calculates magnitude from real and imaginary part for a given frequency bin
float
CalcMagnitude
(
const
int
iIndex
)
const
;
//! Phasenspektrum berechnen und in gegebenes Array speichern
// Zeiger drfen Null sein
void
CalcPhases
(
float
*
pfPhasess
);
//! Betragsgrten Koeffizienten ermitteln
float
FindMax
()
const
;
float
FindMax
(
int
&
iMaxIndex
)
const
;
//! Negieren (Multiplikation mit -1 bzw. Phasendrehungum 180)
void
Negate
();
//! Konjugiert das Spectrum
void
Conjugate
();
//! Set unity DFT coeffs (re == 1, im == 0)
void
SetUnity
();
//! Set unity DFT coeffs (re == 1, im == 0)
void
SetZero
();
//! Komplexen bzw. rellen natrlichen Logarithmus berechnen
/**
* Reller log entspricht dem Betrag des komplexen log.
* Intern wird std::logf verwendet, so dass Betrag 0 den Wert -HUGE_VAL und der relle
* Logarithmus fr negative Werte den Wert NAN zurckgibt
*/
void
Log
(
const
bool
bComplex
=
true
);
//! Komplexe bzw. reelle Exponentialfunktion berechnen
/**
* Intern wird std::exp verwendet, so dass groe Betrge +-HUGE_VAL zurckgeben
*/
void
Exp
(
const
bool
bComplex
=
true
);
//! Alle Filterkoeffizienten eines anderen Spektrums in dieses kopieren
void
CopyFrom
(
const
ITAHDFTSpectrum
&
s
);
void
Copy
(
const
ITAHDFTSpectrum
*
);
//! Einen Teil der Filterkoeffizienten eines anderen Spektrums in dieses kopieren
void
CopyFrom
(
const
ITAHDFTSpectrum
&
s
,
const
int
iOffset
,
const
int
iCount
);
//! Zuweisungsoperator
/**
* Dieser Operator weist dem Spektrum eines anderen Spektrums zu.
* Hierzu wird zunchst die Gre des Spektrums angepasst.
* Anschlieend werden alle Koeffizienten kopiert.
*/
ITAHDFTSpectrum
&
operator
=
(
const
ITAHDFTSpectrum
&
rhs
);
//! Zeichenkette mit den Werten zurckgeben
std
::
string
ToString
();
//! Calculates the energy of the spectrum
/**
* Returns the energy of a HDFTSpectrum as a float
*/
float
GetEnergy
()
const
;
class
ITA_BASE_API
CHDFTSpectrum
{
public:
//! Standard-Konstruktor
CHDFTSpectrum
();
//! Constructor
/**
* Erzeugt ein Spektrum mit vorgegebener Gre und optional zu Null gesetztem Puffer
*
* \param fSampleRate Sampling rate
* \param iDFTSize DFT-Spektrum-Gre
* \param bZeroInit Setzt den Speicher bei wahr auf Null
*/
explicit
CHDFTSpectrum
(
const
float
fSampleRate
,
const
int
iDFTSize
,
const
bool
bZeroInit
);
//! Kopierkonstruktor (Zeiger)
/**
* Erzeugt einen unabhngiges Spektrum als Kopie des gegebenen Spektrums.
* Das neue Spektrum hat die selbe Lnge und enthlt die gleichen Werte
* wie das Quellspektrum.
*
* \param pSource Zeiger auf das Quellspektrum
*/
explicit
CHDFTSpectrum
(
const
CHDFTSpectrum
*
pSource
);
//! Kopierkonstruktor (Referenz)
/**
* Erzeugt einen unabhngiges Spektrum als Kopie des gegebenen Spektrums.
* Das neue Spektrum hat die selbe Lnge und enthlt die gleichen Werte
* wie das Quellspektrum.
*
* \param oSource Zeiger auf das Quellspektrum
*/
explicit
CHDFTSpectrum
(
const
CHDFTSpectrum
&
oSource
);
//! Destruktor
virtual
~
CHDFTSpectrum
();
// Initialisieren
/**
* init(0) gibt belegten Speicher frei
* vorherige Werte werden grundstzlich verworfen!
*/
void
Init
(
const
int
iDFTSize
,
const
bool
bZeroinit
=
true
);
// Gre des Spektrums (Anzahl Koeffizienten insgesamt) zurckgeben
// Hinweis: Symmetrische Koeffizienten werden hier nicht mitgezhlt.
int
GetSize
()
const
;
// Lnge des korrespondieren Zeitsignals zurckgeben (Gre der DFT)
int
GetDFTSize
()
const
;
// Abtastrate des korrespondieren Zeitsignals zurckgeben
float
GetSampleRate
()
const
;
// Abtastrate des korrespondieren Zeitsignals setzen
void
SetSampleRate
(
const
float
fSampleRate
);
// Frequenzauflsung des Spektrums [Hz] zurckgeben
float
GetFrequencyResolution
()
const
;
// Datenzeiger abrufen
float
*
GetData
()
const
;
// DFT Koeffizient(en) setzen (Real-/Imaginrteil bzw. Betrag/Phase)
void
SetCoeffRI
(
const
int
iIndex
,
const
float
fReal
,
const
float
fImag
=
0
);
void
SetCoeffsRI
(
const
float
fReal
,
const
float
fImag
=
0
);
void
SetCoeffsRI
(
const
int
iOffset
,
const
int
iCount
,
const
float
fReal
,
const
float
fImag
=
0
);
//! Set coefficient by index
void
SetCoeff
(
const
int
iIndex
,
std
::
complex
<
float
>&
cfCoeff
);
void
SetCoeffMP
(
const
int
iIndex
,
const
float
fMagnitude
,
const
float
fPhase
);
void
SetCoeffsMP
(
const
float
fMagnitude
,
const
float
fPhase
);
void
SetCoeffsMP
(
const
int
iOffset
,
const
int
iCount
,
const
float
fMagnitude
,
const
float
fPhase
);
//! Betragswert setzen, vorhandene Phasen erhalten
void
SetMagnitudePreservePhase
(
const
int
iIndex
,
const
float
fMagnitude
);
void
SetMagnitudesPreservePhases
(
const
float
fMagnitude
);
void
SetMagnitudesPreservePhases
(
const
int
iOffset
,
const
int
iCount
,
const
float
fMagnitude
);
//! Phase setzen, vorhandene Betrge erhalten
void
SetPhasePreserveMagnitude
(
const
int
iIndex
,
const
float
fPhase
);
void
SetPhasesPreserveMagnitudes
(
const
float
fPhase
);
void
SetPhasesPreserveMagnitudes
(
const
int
iOffset
,
const
int
iCount
,
const
float
fPhase
);
// Konstante addieren
void
Add
(
const
float
fReal
,
const
float
fImag
=
0
);
void
Sub
(
const
float
fReal
,
const
float
fImag
=
0
);
// Spektrum addieren
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
CHDFTSpectrum
*
);
//! Multiplies the conjugate of the given spectrum without data copy
void
MulConj
(
const
CHDFTSpectrum
*
);
//! Devide spectrum
void
Div
(
const
CHDFTSpectrum
&
s
);
void
Div
(
const
CHDFTSpectrum
*
);
//! Betragsspektrum berechnen und in gegebenes Array speichern
// Zeiger drfen Null sein
void
CalcMagnitudes
(
float
*
pfMagnitudes
)
const
;
//! Calculates magnitude from real and imaginary part for a given frequency bin
float
CalcMagnitude
(
const
int
iIndex
)
const
;
//! Phasenspektrum berechnen und in gegebenes Array speichern
// Zeiger drfen Null sein
void
CalcPhases
(
float
*
pfPhasess
);
//! Betragsgrten Koeffizienten ermitteln
float
FindMax
()
const
;
float
FindMax
(
int
&
iMaxIndex
)
const
;
//! Negieren (Multiplikation mit -1 bzw. Phasendrehungum 180)
void
Negate
();
//! Konjugiert das Spectrum
void
Conjugate
();
//! Set unity DFT coeffs (re == 1, im == 0)
void
SetUnity
();
//! Set unity DFT coeffs (re == 1, im == 0)
void
SetZero
();
//! Komplexen bzw. rellen natrlichen Logarithmus berechnen
/**
* Reller log entspricht dem Betrag des komplexen log.
* Intern wird std::logf verwendet, so dass Betrag 0 den Wert -HUGE_VAL und der relle
* Logarithmus fr negative Werte den Wert NAN zurckgibt
*/
void
Log
(
const
bool
bComplex
=
true
);
//! Komplexe bzw. reelle Exponentialfunktion berechnen
/**
* Intern wird std::exp verwendet, so dass groe Betrge +-HUGE_VAL zurckgeben
*/
void
Exp
(
const
bool
bComplex
=
true
);
private:
int
m_iSize
;
int
m_iDFTSize
;
float
m_fSampleRate
;
//! Alle Filterkoeffizienten eines anderen Spektrums in dieses kopieren