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
5b9b409c
Commit
5b9b409c
authored
Jul 11, 2019
by
Dipl.-Ing. Jonas Stienen
Browse files
Fixing problem in IIR implementation by reverting to an older version
parent
bf9695d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/ITAThirdOctaveFilterbankIIR.h
View file @
5b9b409c
...
...
@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-201
8
* RWTH Aachen University, Germany, 2015-201
7
*
* ----------------------------------------------------------------
* ____ __________ _______
...
...
@@ -21,40 +21,43 @@
#include <ITADSPDefinitions.h>
#include <ITAThirdOctaveFilterbank.h>
#include <ITAThirdOctaveMagnitudeSpectrum.h>
#include <ITABiquad.h>
#include <ITASampleBuffer.h>
#include <vector>
#include <tbb/concurrent_queue.h>
//! T
hird octave magnitude filtering using
Biquads (IIR
f
ilter)
//! T
erzfilterbank mittels
Biquads (IIR
F
ilter)
/**
* Diese Klasse realisiert eine Terzfilterbank (#CVAThirdOctaveFilterbank) mit der Methode der kaskadierten
* Biquads (#CVABiquad) für Verstärkungsfaktoren eines Terzbank-Betragsspektrums (#CVAThirdOctaveMagnitudes).
*
*/
class
ITA_DSP_API
CITAThirdOctaveFilterbankIIR
:
public
CITAThirdOctaveFilterbank
{
public:
//!
C
onstru
c
tor
//!
K
onstru
k
tor
mit Samplerate und Blocklänge
/**
*
@
param
[in]
dSample
R
ate Samplingrate
*
@
param
[in]
iBlock
L
ength Block
length
*
\
param dSample
r
ate Samplingrate
*
\
param iBlock
l
ength Block
länge
*/
CITAThirdOctaveFilterbankIIR
(
const
double
dSampleRate
,
const
int
iBlockLength
);
virtual
inline
~
CITAThirdOctaveFilterbankIIR
()
{};
//! Destruktor
virtual
~
CITAThirdOctaveFilterbankIIR
();
//! Filterlatenz in Samples zurückgeben
int
GetLatency
()
const
;
//!
Set magnitudes (in decibel) of filter bank
//!
Verstärkungen (Gains) setzen
/**
*
@
param
[in] oMagnitudes Filter magnitudes (dB)
*
@
param
[in]
bSmoothChangeover
If
true,
switching is smoothed
*
\
param
oGains Verstärkungsfaktoren
*
\
param bSmoothChangeover
Wenn
true,
dann überblenden (default), sonst sofort internen Gain umschalten
*/
void
SetMagnitudes
(
const
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
&
oMagnitudes
,
const
bool
bSmoothChangeover
=
true
);
void
SetGains
(
const
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
&
oGains
,
const
bool
bSmoothChangeover
=
true
);
void
SetMagnitudes
(
const
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
&
oGains
,
const
bool
bSmoothChangeover
=
true
);
//! Clear all internal accumulators
//! Alle internen Zustände zurücksetzen (Akkumulatoren der Biquads)
void
Clear
();
//! Verarbeite Samples (Filtern)
...
...
@@ -66,10 +69,10 @@ public:
private:
//! Interne Datenklasse für das Verarbeiten eines neuen Gain Datensatzes
class
Magnitude
Update
class
Gain
Update
{
public:
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
o
Mag
s
;
//!
New magnitudes
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
o
Gain
s
;
//!
< Gain-Daten
int
iBlendSamples
;
//!< Anzahl Samples zum Überblenden
};
...
...
@@ -77,11 +80,11 @@ private:
int
m_iBlockLength
;
//!< Blocklänge
int
m_nBandsInternal
;
//!< Anzahl der internen Bänder
int
m_nBiquadsPerBand
;
//!< Anzahl von Biqads pro Band
std
::
vector
<
CITABiquad
>
m_vBiquads
;
//!< Biquads,
access
: [Band][BiquadNummer]
tbb
::
strict_ppl
::
concurrent_queue
<
CITAThirdOctaveFilterbankIIR
::
MagnitudeUpdate
>
m_vMagnitudesQueue
;
//!< Liste von neuen Verstärkungsfaktoren
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
m_o
Magnitude
sInternal
;
//!< Interne Verstärkungsfaktoren
ITASampleBuffer
m_
s
fTempFilterBuf
;
//!<
Intermediate b
uffer f
o
r
f
ilter
ITASampleBuffer
m_pfTempOutputBuf
;
//!<
Intermediate b
uffer f
o
r
output assembly
std
::
vector
<
CITABiquad
>
m_vBiquads
;
//!< Biquads,
Zugriff
: [Band][BiquadNummer]
tbb
::
strict_ppl
::
concurrent_queue
<
GainUpdate
>
m_qGains
;
//!< Liste von neuen Verstärkungsfaktoren
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
m_o
Gain
sInternal
;
//!< Interne Verstärkungsfaktoren
float
*
m_
p
fTempFilterBuf
;
//!<
Zwischenp
uffer f
ü
r
F
ilter
float
*
m_pfTempOutputBuf
;
//!<
Zwischenp
uffer f
ü
r
Ausgabe
};
#endif // IW_ITA_THIRD_OCTAVE_FILTERBANK_IIR
src/ITADSPThirdOctaveFilterbankIIRCoefficients.h
deleted
100644 → 0
View file @
bf9695d2
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
/* This file has been generated by the ita_dsp_design_filsters.m Matlab script */
#ifndef IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS
#define IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS
#include <vector>
namespace
ITADSPThirdOctaveFilterbankIIR
{
const
int
ITA_BIQUAD_FILTER_NUM_BANDS
=
30
;
const
int
ITA_BIQUAD_FILTER_NUM_BIQUADS_PER_BAND
=
5
;
// num sections
const
double
dSamplingFrequency
=
44100.00
;
// Hz
const
int
iOrdner
=
10
;
const
int
iNumFrequencies
=
31
;
const
std
::
vector
<
float
>
vfFrequencies
=
{
20.0
f
,
// Hz
25.0
f
,
// Hz
31.5
f
,
// Hz
40.0
f
,
// Hz
50.0
f
,
// Hz
62.5
f
,
// Hz
80.0
f
,
// Hz
100.0
f
,
// Hz
125.0
f
,
// Hz
155.0
f
,
// Hz
200.0
f
,
// Hz
250.0
f
,
// Hz
315.0
f
,
// Hz
400.0
f
,
// Hz
500.0
f
,
// Hz
630.0
f
,
// Hz
800.0
f
,
// Hz
1000.0
f
,
// Hz
1250.0
f
,
// Hz
1600.0
f
,
// Hz
2000.0
f
,
// Hz
2500.0
f
,
// Hz
3150.0
f
,
// Hz
4000.0
f
,
// Hz
5000.0
f
,
// Hz
6350.0
f
,
// Hz
8000.0
f
,
// Hz
10000.0
f
,
// Hz
12500.0
f
,
// Hz
16000.0
f
,
// Hz
20000.0
f
,
// Hz
};
// 3-dim vector access: FrequencyBand ; Biquad ; Param = { ScaleValue [1], sosMatrix [2-6] }
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
float
>
>
>
vvvfSOSMatrixCoefficients
=
{
{
// Band 20.0 Hz sos matrix
{
0.000002
f
,
1.000000
f
,
2.000000
f
,
1.000000
f
,
1.000000
f
,
-
1.999101
f
,
0.999109
f
,
},
{
0.000002
f
,
1.000000
f
,
2.000000
f
,
1.000000
f
,
1.000000
f
,
-
1.997408
f
,
0.997416
f
,
},
{
0.000002
f
,
1.000000
f
,
2.000000
f
,
1.000000
f
,
1.000000
f
,
-
1.995970
f
,
0.995978
f
,
},
{
0.000002
f
,
1.000000
f
,
2.000000
f
,
1.000000
f
,
1.000000
f
,
-
1.994927
f
,
0.994935
f
,
},
{
0.000002
f
,
1.000000
f
,
2.000000
f
,
1.000000
f
,
1.000000
f
,
-
1.994379
f
,
0.994387
f
,
},
},
{
// Band 25.0 Hz sos matrix
{
0.000819
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.999366
f
,
0.999386
f
,
},
{
0.000819
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.999594
f
,
0.999602
f
,
},
{
0.000819
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998479
f
,
0.998496
f
,
},
{
0.000819
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998845
f
,
0.998855
f
,
},
{
0.000819
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998350
f
,
0.998363
f
,
},
},
{
// Band 31.5 Hz sos matrix
{
0.001068
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.999162
f
,
0.999194
f
,
},
{
0.001068
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.999472
f
,
0.999485
f
,
},
{
0.001068
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998003
f
,
0.998030
f
,
},
{
0.001068
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998500
f
,
0.998515
f
,
},
{
0.001067
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.997845
f
,
0.997865
f
,
},
},
{
// Band 40.0 Hz sos matrix
{
0.001317
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998960
f
,
0.999009
f
,
},
{
0.001317
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.999342
f
,
0.999362
f
,
},
{
0.001316
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.997534
f
,
0.997576
f
,
},
{
0.001316
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998140
f
,
0.998164
f
,
},
{
0.001316
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.997336
f
,
0.997368
f
,
},
},
{
// Band 50.0 Hz sos matrix
{
0.001602
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998725
f
,
0.998802
f
,
},
{
0.001602
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.999184
f
,
0.999217
f
,
},
{
0.001601
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.996999
f
,
0.997065
f
,
},
{
0.001601
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.997716
f
,
0.997755
f
,
},
{
0.001600
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.996749
f
,
0.996799
f
,
},
},
{
// Band 62.5 Hz sos matrix
{
0.002136
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998262
f
,
0.998389
f
,
},
{
0.002136
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998919
f
,
0.998971
f
,
},
{
0.002133
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.995956
f
,
0.996064
f
,
},
{
0.002133
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.996971
f
,
0.997033
f
,
},
{
0.002133
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.995654
f
,
0.995735
f
,
},
},
{
// Band 80.0 Hz sos matrix
{
0.002669
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.997788
f
,
0.997987
f
,
},
{
0.002669
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998633
f
,
0.998714
f
,
},
{
0.002666
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.994914
f
,
0.995082
f
,
},
{
0.002666
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.996197
f
,
0.996292
f
,
},
{
0.002664
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.994545
f
,
0.994671
f
,
},
},
{
// Band 100.0 Hz sos matrix
{
0.003203
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.997296
f
,
0.997606
f
,
},
{
0.003203
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.998303
f
,
0.998435
f
,
},
{
0.003197
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.993874
f
,
0.994139
f
,
},
{
0.003197
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.995359
f
,
0.995514
f
,
},
{
0.003195
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.993407
f
,
0.993609
f
,
},
},
{
// Band 125.0 Hz sos matrix
{
0.003913
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.996607
f
,
0.997084
f
,
},
{
0.003913
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.997872
f
,
0.998079
f
,
},
{
0.003906
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.992449
f
,
0.992857
f
,
},
{
0.003906
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.994263
f
,
0.994505
f
,
},
{
0.003903
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.991881
f
,
0.992194
f
,
},
},
{
// Band 155.0 Hz sos matrix
{
0.005334
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.995185
f
,
0.995978
f
,
},
{
0.005334
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.997106
f
,
0.997430
f
,
},
{
0.005320
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.989518
f
,
0.990188
f
,
},
{
0.005320
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.992217
f
,
0.992598
f
,
},
{
0.005315
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.988866
f
,
0.989371
f
,
},
},
{
// Band 200.0 Hz sos matrix
{
0.006753
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.993655
f
,
0.994893
f
,
},
{
0.006753
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.996263
f
,
0.996760
f
,
},
{
0.006731
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.986519
f
,
0.987561
f
,
},
{
0.006731
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.990073
f
,
0.990660
f
,
},
{
0.006722
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.985774
f
,
0.986556
f
,
},
},
{
// Band 250.0 Hz sos matrix
{
0.008172
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.991910
f
,
0.993876
f
,
},
{
0.008172
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.995197
f
,
0.996025
f
,
},
{
0.008139
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.983391
f
,
0.985059
f
,
},
{
0.008139
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.987640
f
,
0.988608
f
,
},
{
0.008126
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.982480
f
,
0.983748
f
,
},
},
{
// Band 315.0 Hz sos matrix
{
0.010650
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.988808
f
,
0.991973
f
,
},
{
0.010650
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.993572
f
,
0.994865
f
,
},
{
0.010594
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.977807
f
,
0.980474
f
,
},
{
0.010594
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.983731
f
,
0.985249
f
,
},
{
0.010573
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.976846
f
,
0.978854
f
,
},
},
{
// Band 400.0 Hz sos matrix
{
0.013125
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.985198
f
,
0.990140
f
,
},
{
0.013125
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.991590
f
,
0.993641
f
,
},
{
0.013040
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.971855
f
,
0.976025
f
,
},
{
0.013040
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.979387
f
,
0.981786
f
,
},
{
0.013008
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.970828
f
,
0.973983
f
,
},
},
{
// Band 500.0 Hz sos matrix
{
0.016302
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.979956
f
,
0.987794
f
,
},
{
0.016302
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.988761
f
,
0.992063
f
,
},
{
0.016171
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.963724
f
,
0.970344
f
,
},
{
0.016171
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.973493
f
,
0.977341
f
,
},
{
0.016122
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.962725
f
,
0.967756
f
,
},
},
{
// Band 630.0 Hz sos matrix
{
0.021230
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.971419
f
,
0.984019
f
,
},
{
0.021230
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.984596
f
,
0.989753
f
,
},
{
0.021010
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.950775
f
,
0.961335
f
,
},
{
0.021010
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.964679
f
,
0.970705
f
,
},
{
0.020927
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.950200
f
,
0.958145
f
,
},
},
{
// Band 800.0 Hz sos matrix
{
0.026143
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.960746
f
,
0.980393
f
,
},
{
0.026143
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.979143
f
,
0.987315
f
,
},
{
0.025811
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.936168
f
,
0.952635
f
,
},
{
0.025811
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.954380
f
,
0.963883
f
,
},
{
0.025687
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.936176
f
,
0.948626
f
,
},
},
{
// Band 1000.0 Hz sos matrix
{
0.031739
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.945730
f
,
0.976358
f
,
},
{
0.031739
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.971302
f
,
0.984446
f
,
},
{
0.031252
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.917207
f
,
0.942941
f
,
},
{
0.031252
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.940822
f
,
0.955989
f
,
},
{
0.031072
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.918215
f
,
0.937857
f
,
},
},
{
// Band 1250.0 Hz sos matrix
{
0.042177
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.918513
f
,
0.968362
f
,
},
{
0.042177
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.959086
f
,
0.979580
f
,
},
{
0.041326
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.882866
f
,
0.924209
f
,
},
{
0.041326
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.918462
f
,
0.942185
f
,
},
{
0.041015
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.886889
f
,
0.917971
f
,
},
},
{
// Band 1600.0 Hz sos matrix
{
0.052544
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.883270
f
,
0.960674
f
,
},
{
0.052544
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.942602
f
,
0.974511
f
,
},
{
0.051238
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.842334
f
,
0.906218
f
,
},
{
0.051238
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.891421
f
,
0.928185
f
,
},
{
0.050764
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.850457
f
,
0.898471
f
,
},
},
{
// Band 2000.0 Hz sos matrix
{
0.062841
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.833339
f
,
0.953510
f
,
},
{
0.062841
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.917025
f
,
0.969022
f
,
},
{
0.060993
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.789784
f
,
0.889300
f
,
},
{
0.060993
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.854477
f
,
0.913628
f
,
},
{
0.060329
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.803454
f
,
0.879342
f
,
},
},
{
// Band 2500.0 Hz sos matrix
{
0.079844
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.752679
f
,
0.941055
f
,
},
{
0.079844
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.879925
f
,
0.960653
f
,
},
{
0.076914
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.706218
f
,
0.860665
f
,
},
{
0.076914
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.799621
f
,
0.890988
f
,
},
{
0.075877
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.731055
f
,
0.848245
f
,
},
},
{
// Band 3150.0 Hz sos matrix
{
0.103322
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.626000
f
,
0.923923
f
,
},
{
0.103322
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.824196
f
,
0.949195
f
,
},
{
0.098535
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.581184
f
,
0.821887
f
,
},
{
0.098535
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.719613
f
,
0.860324
f
,
},
{
0.096874
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.625316
f
,
0.806252
f
,
},
},
{
// Band 4000.0 Hz sos matrix
{
0.126418
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.453124
f
,
0.908199
f
,
},
{
0.126418
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.741078
f
,
0.936993
f
,
},
{
0.119424
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.420470
f
,
0.786153
f
,
},
{
0.119424
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.611560
f
,
0.829135
f
,
},
{
0.117043
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.489466
f
,
0.765913
f
,
},
},
{
// Band 5000.0 Hz sos matrix
{
0.158763
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.179163
f
,
0.886868
f
,
},
{
0.158763
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.609822
f
,
0.919682
f
,
},
{
0.148101
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.447005
f
,
0.785879
f
,
},
{
0.148101
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.174879
f
,
0.737998
f
,
},
{
0.144561
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.284482
f
,
0.710877
f
,
},
},
{
// Band 6350.0 Hz sos matrix
{
0.199686
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.796288
f
,
0.861586
f
,
},
{
0.199686
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.425777
f
,
0.897063
f
,
},
{
0.183536
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.224617
f
,
0.731209
f
,
},
{
0.183536
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.843451
f
,
0.680681
f
,
},
{
0.178326
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.010579
f
,
0.643348
f
,
},
},
{
// Band 8000.0 Hz sos matrix
{
0.239376
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.290944
f
,
0.842143
f
,
},
{
0.239376
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
1.141474
f
,
0.871316
f
,
},
{
0.217132
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.909951
f
,
0.673736
f
,
},
{
0.217132
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.413487
f
,
0.633071
f
,
},
{
0.210136
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.645680
f
,
0.579727
f
,
},
},
{
// Band 10000.0 Hz sos matrix
{
0.289489
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
0.355865
f
,
0.823971
f
,
},
{
0.289489
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.745157
f
,
0.834995
f
,
},
{
0.258678
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.492985
f
,
0.597368
f
,
},
{
0.258678
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
0.135349
f
,
0.582248
f
,
},
{
0.249262
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.174336
f
,
0.501476
f
,
},
},
{
// Band 12500.0 Hz sos matrix
{
0.373293
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
1.161744
f
,
0.813023
f
,
},
{
0.373293
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
-
0.226640
f
,
0.764884
f
,
},
{
0.326657
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
0.834287
f
,
0.526520
f
,
},
{
0.326657
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
0.024728
f
,
0.459508
f
,
},
{
0.312956
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
0.419294
f
,
0.374088
f
,
},
},
{
// Band 16000.0 Hz sos matrix
{
0.451712
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
0.372812
f
,
0.651489
f
,
},
{
0.451712
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
1.798158
f
,
0.880660
f
,
},
{
0.389515
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
1.547760
f
,
0.646690
f
,
},
{
0.389515
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
0.470276
f
,
0.263182
f
,
},
{
0.371736
f
,
1.000000
f
,
0.000000
f
,
-
1.000000
f
,
1.000000
f
,
0.989237
f
,
0.256529
f
,
},
},
{
// Band 20000.0 Hz sos matrix
{
0.020263
f
,
1.000000
f
,
-
2.000000
f
,
1.000000
f
,
1.000000
f
,
1.832743
f
,
0.913795
f
,
},
{
0.018728
f
,
1.000000
f
,
-
2.000000
f
,
1.000000
f
,
1.000000
f
,
1.693870
f
,
0.768781
f
,
},
{
0.017594
f
,
1.000000
f
,
-
2.000000
f
,
1.000000
f
,
1.000000
f
,
1.591300
f
,
0.661675
f
,
},
{
0.016852
f
,
1.000000
f
,
-
2.000000
f
,
1.000000
f
,
1.000000
f
,
1.524242
f
,
0.591651
f
,
},
{
0.016487
f
,
1.000000
f
,
-
2.000000
f
,
1.000000
f
,
1.000000
f
,
1.491205
f
,
0.557153
f
,
},
},
};
}
// namespace
#endif // IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS
src/ITAThirdOctaveFilterbankIIR.cpp
View file @
5b9b409c
#include <ITAThirdOctaveFilterbankIIR.h>
//#include "ITAThirdOctaveFilterbankCoefficients.h"
#include "ITADSPThirdOctaveFilterbankIIRCoefficients.h"
#include "ITAThirdOctaveFilterbankCoefficients.h"
#include <ITAFastMath.h>
#include <ITAStopWatch.h>
#include <ITAException.h>
#include <ITANumericUtils.h>
#include <cassert>
CITAThirdOctaveFilterbankIIR
::
CITAThirdOctaveFilterbankIIR
(
const
double
dSampleRate
,
const
int
iBlockLength
)
:
m_dSampleRate
(
dSampleRate
)
,
m_iBlockLength
(
iBlockLength
)
,
m_nBandsInternal
(
ITADSPThirdOctaveFilterbankIIR
::
ITA_BIQUAD_FILTER_NUM_BANDS
)
,
m_nBiquadsPerBand
(
ITADSPThirdOctaveFilterbankIIR
::
ITA_BIQUAD_FILTER_NUM_BIQUADS_PER_BAND
)
:
m_dSampleRate
(
dSampleRate
),
m_iBlockLength
(
iBlockLength
),
m_nBandsInternal
(
FB_NUM_BANDS
),
m_nBiquadsPerBand
(
FB_NUM_BIQUADS_PER_BAND
),
m_pfTempFilterBuf
(
nullptr
),
m_pfTempOutputBuf
(
nullptr
)
{
if
(
dSampleRate
!=
ITADSPThirdOctaveFilterbankIIR
::
dSamplingFrequency
)
if
(
dSampleRate
!=
FB_SAMPLINGRATE
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Filterbank does not support this samplingrate"
);
if
(
m_nBandsInternal
+
1
!=
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
::
GetNumBands
()
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Filterbank does not match third octave band number"
);
// Initialize biquads
int
nBiquads
=
m_nBandsInternal
*
m_nBiquadsPerBand
;
int
nBiquads
=
m_nBandsInternal
*
m_nBiquadsPerBand
;
m_vBiquads
.
resize
(
nBiquads
);
for
(
int
i
=
0
;
i
<
m_nBandsInternal
;
i
++
)
{
const
std
::
vector
<
std
::
vector
<
float
>
>&
vvfBandBiquads
(
ITADSPThirdOctaveFilterbankIIR
::
vvvfSOSMatrixCoefficients
[
i
]
);
for
(
int
j
=
0
;
j
<
vvfBandBiquads
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
m_nBiquadsPerBand
;
j
++
)
{
const
std
::
vector
<
float
>&
vfBiquad
(
vvfBandBiquads
[
j
]
);
CITABiquad
&
oBiquad
(
m_vBiquads
[
i
*
m_nBiquadsPerBand
+
j
]
);
oBiquad
.
oParams
.
g
=
vfBiquad
[
0
];
//oBiquad.oParams.a0 = vfBiquad[ 1 ];
oBiquad
.
oParams
.
a1
=
vfBiquad
[
2
];
oBiquad
.
oParams
.
a2
=
vfBiquad
[
3
];
oBiquad
.
oParams
.
b0
=
vfBiquad
[
4
];
oBiquad
.
oParams
.
b1
=
vfBiquad
[
5
];
oBiquad
.
oParams
.
b2
=
vfBiquad
[
6
];
m_vBiquads
[
i
*
m_nBiquadsPerBand
+
j
].
oParams
.
SetParameters
(
FB_BIQUAD_PARAMS
[
i
][
j
]
);
}
}
m_sfTempFilterBuf
.
Init
(
m_iBlockLength
,
true
);
m_pfTempOutputBuf
.
Init
(
m_iBlockLength
,
true
);
m_pfTempFilterBuf
=
fm_falloc
(
m_iBlockLength
,
true
);
m_pfTempOutputBuf
=
fm_falloc
(
m_iBlockLength
,
true
);
}
CITAThirdOctaveFilterbankIIR
::~
CITAThirdOctaveFilterbankIIR
()
{
fm_free
(
m_pfTempFilterBuf
);
fm_free
(
m_pfTempOutputBuf
);
}
int
CITAThirdOctaveFilterbankIIR
::
GetLatency
()
const
{
return
0
;
return
0
;
// [stienen] sicher?
}
void
CITAThirdOctaveFilterbankIIR
::
Set
Magnitude
s
(
const
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
&
o
Magnitudes
,
const
bool
bSmoothChangeover
)
void
CITAThirdOctaveFilterbankIIR
::
Set
Gain
s
(
const
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
&
o
Gains
,
bool
bSmoothChangeover
)
{
CITAThirdOctaveFilterbankIIR
::
Magnitude
Update
oUpdate
;
oUpdate
.
o
Mag
s
=
o
Magnitude
s
;
Gain
Update
oUpdate
;
oUpdate
.
o
Gain
s
=
o
Gain
s
;
oUpdate
.
iBlendSamples
=
(
bSmoothChangeover
?
1
:
0
);
m_vMagnitudesQueue
.
push
(
oUpdate
);
m_qGains
.
push
(
oUpdate
);
}
void
CITAThirdOctaveFilterbankIIR
::
SetMagnitudes
(
const
ITABase
::
CThirdOctaveGainMagnitudeSpectrum
&
oGains
,
const
bool
bSmoothChangeover
/*= true */
)
{
SetGains
(
oGains
);
}
void
CITAThirdOctaveFilterbankIIR
::
Clear
()
{
for
(
size_
t
i
=
0
;
i
<
m_vBiquads
.
size
();
i
++
)
m_vBiquads
[
i
].
ClearAccumulators
();
for
(
in
t
i
=
0
;
i
<
(
int
)
m_vBiquads
.
size
();
i
++
)
m_vBiquads
[
i
].
ClearAccumulators
();
}
void
CITAThirdOctaveFilterbankIIR
::
Process
(
const
float
*
pfInputSamples
,
float
*
pfOutputSamples
)
...
...
@@ -73,33 +72,39 @@ void CITAThirdOctaveFilterbankIIR::Process( const float* pfInputSamples, float*
// Fr Schleifen unten
assert
(
m_nBiquadsPerBand
>=
2
);
// TODO: Fehler lsen. Warum kommt aus den hohen Bndern nix? Scheinen nicht stabil zu sein?!
const
int
iMaxBand
=
m_nBandsInternal
-
1
;
const
int
iLastBandIndex
=
m_nBiquadsPerBand
-
1
;
//const int iMaxBand = 10;
const
int
k
=
m_nBiquadsPerBand
-
1
;
// Index des letzten Biquads pro Band