Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITADSP
Commits
b70951bb
Commit
b70951bb
authored
Jul 12, 2019
by
henryjandrew
Browse files
Merge branch 'ma_2019/andrew' of
https://git.rwth-aachen.de/ita/ITADSP
into ma_2019/andrew
parents
65646533
03d2aca4
Changes
2
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
b70951bb
...
...
@@ -51,7 +51,7 @@ set( ITADSPSources
"src/ITAThirdOctaveFilterbank.cpp"
"src/ITAThirdOctaveFilterbankIIR.cpp"
"src/ITAThirdOctaveFIRFilterGenerator.cpp"
"src/ITAThirdOctaveFilterbankCoefficients.h"
"src/ITAThirdOctaveFilterbank
IIR
Coefficients.h"
"src/ITAVariableDelayLine.cpp"
)
...
...
src/ITAThirdOctaveFIRFilterGenerator.cpp
View file @
b70951bb
...
...
@@ -80,78 +80,78 @@ void CITAThirdOctaveFIRFilterGenerator::SetDumpFilename( const std::string& sFil
m_sDumpFilename
=
sFilename
;
}
void
CITAThirdOctaveFIRFilterGenerator
::
GenerateFilter
(
const
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
&
oTOGainMagnitudes
,
float
*
pfFilterCoeffs
,
bool
bMinimumPhase
/*=false*/
)
void
CITAThirdOctaveFIRFilterGenerator
::
GenerateFilter
(
const
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
&
oTOGainMagnitudes
,
float
*
pfFilterCoeffs
,
bool
bMinimumPhase
/*=false*/
)
{
m_sw
.
start
();
if
(
oTOGainMagnitudes
.
IsZero
())
if
(
oTOGainMagnitudes
.
IsZero
()
)
{
for
(
int
i
=
0
;
i
<
m_iFilterLength
;
i
++
)
pfFilterCoeffs
[
i
]
=
0.0
f
;
for
(
int
i
=
0
;
i
<
m_iFilterLength
;
i
++
)
pfFilterCoeffs
[
i
]
=
0.0
f
;
return
;
}
if
(
oTOGainMagnitudes
.
IsIdentity
())
if
(
oTOGainMagnitudes
.
IsIdentity
()
)
{
for
(
int
i
=
0
;
i
<
m_iFilterLength
;
i
++
)
pfFilterCoeffs
[
i
]
=
0.0
f
;
pfFilterCoeffs
[
int
(
m_iFilterLength
/
2
)
]
=
1.0
f
;
for
(
int
i
=
0
;
i
<
m_iFilterLength
;
i
++
)
pfFilterCoeffs
[
i
]
=
0.0
f
;
pfFilterCoeffs
[
int
(
m_iFilterLength
/
2
)
]
=
1.0
f
;
return
;
}
// 1st step: Interpolate the magnitudes
m_pfInputData
[
0
]
=
1.0
f
;
for
(
int
i
=
0
;
i
<
CThirdOctaveGainMagnitudeSpectrum
::
GetNumBands
();
i
++
)
m_pfInputData
[
1
+
i
]
=
float
(
oTOGainMagnitudes
[
i
]
);
m_pfInputData
[
m_iInputFreqs
-
1
]
=
0.0
f
;
// @todo jst: check if this is good
m_pfInputData
[
0
]
=
1.0
f
;
for
(
int
i
=
0
;
i
<
CThirdOctaveGainMagnitudeSpectrum
::
GetNumBands
();
i
++
)
m_pfInputData
[
1
+
i
]
=
float
(
oTOGainMagnitudes
[
i
]
);
m_pfInputData
[
m_iInputFreqs
-
1
]
=
0.0
f
;
// @todo jst: check if this is good
// Initialize cubic spline interpolation
m_ypp
=
spline_cubic_set
(
m_iInputFreqs
,
m_ypp
=
spline_cubic_set
(
m_iInputFreqs
,
m_pfInputFreqs
,
m_pfInputData
,
1
,
// Left boundary condition => 1st derivative m=0
0
,
1
,
// Right boundary condition => 1st derivative m=0
0
);
0
);
float
fDummy
;
const
float
fScale
=
1
/
(
float
)
m_iFilterLength
;
const
float
fScale
=
1
/
(
float
)
m_iFilterLength
;
// No DC offset, ever!
m_pfBuf1
[
0
]
=
0
;
m_pfBuf1
[
1
]
=
0
;
m_pfBuf1
[
0
]
=
0
;
m_pfBuf1
[
1
]
=
0
;
if
(
bMinimumPhase
)
{
for
(
int
i
=
1
;
i
<
m_iDFTCoeffs
;
i
++
)
if
(
bMinimumPhase
)
{
for
(
int
i
=
1
;
i
<
m_iDFTCoeffs
;
i
++
)
{
float
x
=
spline_cubic_val
(
m_iInputFreqs
,
float
x
=
spline_cubic_val
(
m_iInputFreqs
,
m_pfInputFreqs
,
i
*
m_fDeltaF
,
m_pfInputData
,
m_ypp
,
&
fDummy
,
&
fDummy
);
&
fDummy
);
// Phase-shift by half the FFT-period
m_pfBuf1
[
2
*
i
]
=
pow
(
x
*
fScale
,
2
)
*
m_iFilterLength
;
//minimum phase
m_pfBuf1
[
2
*
i
+
1
]
=
0
;
m_pfBuf1
[
2
*
i
]
=
pow
(
x
*
fScale
,
2
)
*
m_iFilterLength
;
//minimum phase
m_pfBuf1
[
2
*
i
+
1
]
=
0
;
}
}
else
{
for
(
int
i
=
1
;
i
<
m_iDFTCoeffs
;
i
++
)
for
(
int
i
=
1
;
i
<
m_iDFTCoeffs
;
i
++
)
{
float
x
=
spline_cubic_val
(
m_iInputFreqs
,
float
x
=
spline_cubic_val
(
m_iInputFreqs
,
m_pfInputFreqs
,
i
*
m_fDeltaF
,
m_pfInputData
,
m_ypp
,
&
fDummy
,
&
fDummy
);
&
fDummy
);
// Phase-shift by half the FFT-period: Negate all odd DFT coefficients
m_pfBuf1
[
2
*
i
]
=
(
(
i
%
2
)
==
0
)
?
x
*
fScale
:
-
x
*
fScale
;
m_pfBuf1
[
2
*
i
+
1
]
=
0
;
m_pfBuf1
[
2
*
i
]
=
(
(
i
%
2
)
==
0
)
?
x
*
fScale
:
-
x
*
fScale
;
m_pfBuf1
[
2
*
i
+
1
]
=
0
;
}
}
...
...
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