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
3d680c09
Commit
3d680c09
authored
Jun 18, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring FIR and HDFT classes
parent
07a04e35
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
15 deletions
+24
-15
include/ITAFiniteImpulseResponse.h
include/ITAFiniteImpulseResponse.h
+6
-6
include/ITAHDFTSpectrum.h
include/ITAHDFTSpectrum.h
+4
-0
src/ITAFiniteImpulseResponse.cpp
src/ITAFiniteImpulseResponse.cpp
+8
-8
src/ITAHDFTSpectrum.cpp
src/ITAHDFTSpectrum.cpp
+6
-1
No files found.
include/ITAFiniteImpulseResponse.h
View file @
3d680c09
...
...
@@ -43,7 +43,7 @@ public:
/**
* \param iLength Length (size) of buffer in samples
*/
explicit
CITAFiniteImpulseResponse
(
const
int
iLength
,
const
double
d
SampleRate
,
const
bool
bZeroInit
=
true
);
explicit
CITAFiniteImpulseResponse
(
const
int
iLength
,
const
float
f
SampleRate
,
const
bool
bZeroInit
=
true
);
//! Copy constructor as pointer
/**
...
...
@@ -60,27 +60,27 @@ public:
virtual
inline
~
CITAFiniteImpulseResponse
()
{};
//! Sampling frequency of FIR filter (double of Nyquist frequency)
double
GetSampleRate
()
const
;
float
GetSampleRate
()
const
;
//! Nyquist frequency of FIR filter (half of sample rate)
double
GetNyquistFrequency
()
const
;
float
GetNyquistFrequency
()
const
;
//! Initialize
/**
* (Re-)Initialize a sample buffer
*
* @param[in] iLength Number of new samples
* @param[in]
d
SampleRate Sampling rate of FIR filter (double of Nyquist frequency)
* @param[in]
f
SampleRate Sampling rate of FIR filter (double of Nyquist frequency)
* @param[in] bZeroInit Init with zeros
*/
void
Init
(
const
int
iLength
,
const
double
d
SampleRate
,
const
bool
bZeroInit
=
true
);
void
Init
(
const
int
iLength
,
const
float
f
SampleRate
,
const
bool
bZeroInit
=
true
);
private:
//! Disable this Init method from sample buffer
void
Init
(
int
,
bool
);
double
m_d
SampleRate
;
//!< Sampling rate
float
m_f
SampleRate
;
//!< Sampling rate
};
#endif // INCLUDE_WATCHER_ITA_FINITE_IMPULSE_RESPONSE
include/ITAHDFTSpectrum.h
View file @
3d680c09
...
...
@@ -21,6 +21,7 @@
#include <ITABaseDefinitions.h>
#include <ccomplex>
#include <string>
#include <vector>
...
...
@@ -109,6 +110,9 @@ public:
void
setCoeffsRI
(
float
fReal
,
float
fImag
=
0
);
void
setCoeffsRI
(
int
iOffset
,
int
iCount
,
float
fReal
,
float
fImag
=
0
);
//! Set coefficient by index
void
SetCoeff
(
const
int
iIndex
,
std
::
complex
<
float
>&
cfCoeff
);
void
setCoeffMP
(
int
iIndex
,
float
fMagnitude
,
float
fPhase
);
void
setCoeffsMP
(
float
fMagnitude
,
float
fPhase
);
void
setCoeffsMP
(
int
iOffset
,
int
iCount
,
float
fMagnitude
,
float
fPhase
);
...
...
src/ITAFiniteImpulseResponse.cpp
View file @
3d680c09
#include <ITAFiniteImpulseResponse.h>
CITAFiniteImpulseResponse
::
CITAFiniteImpulseResponse
()
:
m_
d
SampleRate
(
0
)
:
m_
f
SampleRate
(
0
)
{
}
CITAFiniteImpulseResponse
::
CITAFiniteImpulseResponse
(
const
int
iLength
,
const
double
d
SampleRate
,
const
bool
bZeroInit
/*= true */
)
CITAFiniteImpulseResponse
::
CITAFiniteImpulseResponse
(
const
int
iLength
,
const
float
f
SampleRate
,
const
bool
bZeroInit
/*= true */
)
:
ITASampleBuffer
(
iLength
,
bZeroInit
)
,
m_
dSampleRate
(
d
SampleRate
)
,
m_
fSampleRate
(
f
SampleRate
)
{
}
...
...
@@ -23,18 +23,18 @@ CITAFiniteImpulseResponse::CITAFiniteImpulseResponse( const CITAFiniteImpulseRes
ITASampleBuffer
::
write
(
sbSource
,
sbSource
.
GetLength
()
);
}
void
CITAFiniteImpulseResponse
::
Init
(
const
int
iLength
,
const
double
d
SampleRate
,
const
bool
bZeroInit
/*= true */
)
void
CITAFiniteImpulseResponse
::
Init
(
const
int
iLength
,
const
float
f
SampleRate
,
const
bool
bZeroInit
/*= true */
)
{
m_
dSampleRate
=
d
SampleRate
;
m_
fSampleRate
=
f
SampleRate
;
ITASampleBuffer
::
Init
(
iLength
,
bZeroInit
);
}
double
CITAFiniteImpulseResponse
::
GetSampleRate
()
const
float
CITAFiniteImpulseResponse
::
GetSampleRate
()
const
{
return
m_
d
SampleRate
;
return
m_
f
SampleRate
;
}
double
CITAFiniteImpulseResponse
::
GetNyquistFrequency
()
const
float
CITAFiniteImpulseResponse
::
GetNyquistFrequency
()
const
{
return
GetSampleRate
()
/
2.0
f
;
}
src/ITAHDFTSpectrum.cpp
View file @
3d680c09
...
...
@@ -58,7 +58,7 @@ void ITAHDFTSpectrum::Init( const int iDFTSize, const bool bZeroinit )
m_iDFTSize
=
iDFTSize
;
m_iSize
=
(
int
)
floor
(
(
float
)
m_iDFTSize
/
2.0
)
+
1
;
// +2 wegen 4-Byte Ausrichtung
// +2 wegen 4-Byte Ausrichtung
@jst todo
if
(
m_iSize
>
0
)
m_vfData
.
resize
(
m_iSize
*
2
+
2
);
...
...
@@ -471,3 +471,8 @@ void ITAHDFTSpectrum::copy( const ITAHDFTSpectrum* pSource )
for
(
int
i
=
0
;
i
<
2
*
m_iSize
;
i
++
)
m_vfData
[
i
]
=
pSource
->
GetData
()[
i
];
}
void
ITAHDFTSpectrum
::
SetCoeff
(
const
int
iIndex
,
std
::
complex
<
float
>&
cfCoeff
)
{
setCoeffRI
(
iIndex
,
cfCoeff
.
real
(),
cfCoeff
.
imag
()
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment