Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
ITACTC
Commits
04fd3a2b
Commit
04fd3a2b
authored
Jun 14, 2018
by
Dipl.-Ing. Jonas Stienen
Browse files
Introducing ITABaser namespace, starting with data classes
parent
f8aafff2
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/ITANCTC.h
View file @
04fd3a2b
...
...
@@ -278,7 +278,7 @@ public:
/**
* \important Not thread safe
*/
bool
GetHRTF
(
std
::
vector
<
ITAHDFTSpectra
*
>&
vpHRTF
)
const
;
bool
GetHRTF
(
std
::
vector
<
ITA
Base
::
C
HDFTSpectra
*
>&
vpHRTF
)
const
;
//! Returns the currently used head pose
/**
...
...
@@ -300,10 +300,10 @@ public:
*
* @note Will raise ITAException on error
*/
void
CalculateFilter
(
std
::
vector
<
ITAHDFTSpectra
*
>&
vpSpectra
)
const
;
void
CalculateFilter
(
std
::
vector
<
ITA
Base
::
C
HDFTSpectra
*
>&
vpSpectra
)
const
;
//! Calculate the Wiener-Hopf factorization
void
WienerHopfFactorization
(
const
ITAHDFTSpectrum
*
voSpecIn
,
ITAHDFTSpectrum
*
voSpecOutPlus
,
ITAHDFTSpectrum
*
voSpecOutMinus
);
void
WienerHopfFactorization
(
const
ITA
Base
::
C
HDFTSpectrum
*
voSpecIn
,
ITA
Base
::
C
HDFTSpectrum
*
voSpecOutPlus
,
ITA
Base
::
C
HDFTSpectrum
*
voSpecOutMinus
);
protected:
...
...
@@ -323,10 +323,10 @@ private:
mutable
ITASampleFrame
m_sfCTC_temp
;
//!< Internal CTC helper
std
::
vector
<
float
>
m_vfWeights
;
//!< Diagonal values for the weighting matrix (W or Z), only non-zero entries allowed
std
::
vector
<
ITAHDFTSpectra
*
>
m_vpHRTFs
;
//!< N-dim vector with two-channel HRTF sets for each LS direction
std
::
vector
<
ITAHDFTSpectra
*
>
m_vpHelper2x2
;
//!< Two-by-two helper matrix
ITAHDFTSpectrum
*
t
;
//!< Helper
ITAHDFTSpectrum
*
det
;
//!< Helper
std
::
vector
<
ITA
Base
::
C
HDFTSpectra
*
>
m_vpHRTFs
;
//!< N-dim vector with two-channel HRTF sets for each LS direction
std
::
vector
<
ITA
Base
::
C
HDFTSpectra
*
>
m_vpHelper2x2
;
//!< Two-by-two helper matrix
ITA
Base
::
C
HDFTSpectrum
*
t
;
//!< Helper
ITA
Base
::
C
HDFTSpectrum
*
det
;
//!< Helper
int
GetLoudspeakerSide
(
const
int
)
const
;
...
...
include/ITANCTCStreamFilter.h
View file @
04fd3a2b
...
...
@@ -24,6 +24,7 @@
#include
<vector>
#include
<ITADataSourceRealization.h>
#include
<ITAHDFTSpectra.h>
// Forward declarations
class
ITAUPConvolution
;
...
...
@@ -31,7 +32,6 @@ class ITAUPFilter;
class
ITAUPFilterPool
;
class
ITAUPTrigger
;
class
ITADatasource
;
class
ITAHDFTSpectra
;
//! ITACircularNCTCStreamFilter realizes the CTC filtering
/**
...
...
@@ -66,7 +66,7 @@ public:
ITADatasource
*
GetOutputDatasource
()
const
;
//! Exchange filters
void
ExchangeFilters
(
const
std
::
vector
<
ITAHDFTSpectra
*
>&
vpCTCFilter
);
void
ExchangeFilters
(
const
std
::
vector
<
ITA
Base
::
C
HDFTSpectra
*
>&
vpCTCFilter
);
//! Set gains of loudspeaker two-channel connvolvers (N-sized vector of floats)
void
SetGains
(
const
std
::
vector
<
float
>&
vfGains
,
bool
bSetImmediately
=
false
);
...
...
src/ITANCTC.cpp
View file @
04fd3a2b
...
...
@@ -14,6 +14,7 @@
#include
<ITAStringUtils.h>
#include
<ITAFFTUtils.h>
ITANCTC
::
ITANCTC
(
const
Config
&
oNCTCConfig
)
:
m_oConfig
(
oNCTCConfig
)
,
m_pHRIR
(
NULL
)
...
...
@@ -37,15 +38,15 @@ ITANCTC::ITANCTC( const Config& oNCTCConfig )
for
(
int
n
=
0
;
n
<
GetNumChannels
();
n
++
)
{
m_vfWeights
.
push_back
(
1.0
f
);
m_vpHRTFs
.
push_back
(
new
ITAHDFTSpectra
(
m_oConfig
.
fSampleRate
,
2
,
iDFTSize
,
true
)
);
m_vpHRTFs
.
push_back
(
new
ITA
Base
::
C
HDFTSpectra
(
m_oConfig
.
fSampleRate
,
2
,
iDFTSize
,
true
)
);
m_vfDelayTime
.
push_back
(
float
(
m_oConfig
.
iCTCFilterLength
)
/
m_oConfig
.
fSampleRate
/
2.0
f
);
}
for
(
int
i
=
0
;
i
<
2
;
i
++
)
m_vpHelper2x2
.
push_back
(
new
ITAHDFTSpectra
(
m_oConfig
.
fSampleRate
,
2
,
iDFTSize
,
true
)
);
m_vpHelper2x2
.
push_back
(
new
ITA
Base
::
C
HDFTSpectra
(
m_oConfig
.
fSampleRate
,
2
,
iDFTSize
,
true
)
);
t
=
new
ITAHDFTSpectrum
(
m_oConfig
.
fSampleRate
,
iDFTSize
,
true
);
det
=
new
ITAHDFTSpectrum
(
m_oConfig
.
fSampleRate
,
iDFTSize
,
true
);
t
=
new
ITA
Base
::
C
HDFTSpectrum
(
m_oConfig
.
fSampleRate
,
iDFTSize
,
true
);
det
=
new
ITA
Base
::
C
HDFTSpectrum
(
m_oConfig
.
fSampleRate
,
iDFTSize
,
true
);
m_fft
.
plan
(
ITAFFT
::
FFT_R2C
,
m_oConfig
.
iCTCFilterLength
,
m_sfCTC_temp
[
0
].
GetData
(),
(
*
m_vpHRTFs
[
0
]
)[
0
]
->
GetData
()
);
m_ifft
.
plan
(
ITAFFT
::
IFFT_C2R
,
m_oConfig
.
iCTCFilterLength
,
(
*
m_vpHRTFs
[
0
]
)[
0
]
->
GetData
(),
m_sfCTC_temp
[
0
].
GetData
()
);
...
...
@@ -155,7 +156,7 @@ const ITANCTC::Pose& ITANCTC::GetLoudspeakerPose( const int iLoudspeakerID ) con
return
m_oConfig
.
voLoudspeaker
[
iLoudspeakerID
-
1
].
oPose
;
}
void
ITANCTC
::
CalculateFilter
(
std
::
vector
<
ITAHDFTSpectra
*
>&
vpCTCFilter
)
const
void
ITANCTC
::
CalculateFilter
(
std
::
vector
<
ITA
Base
::
C
HDFTSpectra
*
>&
vpCTCFilter
)
const
{
if
(
!
m_pHRIR
)
ITA_EXCEPT1
(
MODAL_EXCEPTION
,
"CTC filters could not be created because HRIR is not set"
);
...
...
@@ -180,7 +181,7 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
if
(
bOutOfRange
)
ITA_EXCEPT_INVALID_PARAMETER
(
"CTC filters could not be created because HRIR direction is out of bounds and not covered by input HRIR"
);
ITAHDFTSpectra
*
pHRTF
(
m_vpHRTFs
[
n
]
);
ITA
Base
::
C
HDFTSpectra
*
pHRTF
(
m_vpHRTFs
[
n
]
);
// Convert HRIRs to HRTFs
m_fft
.
execute
(
m_sfCTC_temp
[
0
].
GetData
(),
(
*
pHRTF
)[
0
]
->
GetData
()
);
...
...
@@ -195,10 +196,10 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
* a c
* b d
*/
ITAHDFTSpectrum
*
a
=
(
*
m_vpHelper2x2
[
0
]
)[
0
];
ITAHDFTSpectrum
*
b
=
(
*
m_vpHelper2x2
[
0
]
)[
1
];
ITAHDFTSpectrum
*
c
=
(
*
m_vpHelper2x2
[
1
]
)[
0
];
ITAHDFTSpectrum
*
d
=
(
*
m_vpHelper2x2
[
1
]
)[
1
];
ITA
Base
::
C
HDFTSpectrum
*
a
=
(
*
m_vpHelper2x2
[
0
]
)[
0
];
ITA
Base
::
C
HDFTSpectrum
*
b
=
(
*
m_vpHelper2x2
[
0
]
)[
1
];
ITA
Base
::
C
HDFTSpectrum
*
c
=
(
*
m_vpHelper2x2
[
1
]
)[
0
];
ITA
Base
::
C
HDFTSpectrum
*
d
=
(
*
m_vpHelper2x2
[
1
]
)[
1
];
// Least-squares minimization: C = WH*(HWH*-\beta)^-1
// using H* as the hermitian (complex conjugated) transpose of H
...
...
@@ -213,7 +214,7 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
for
(
int
n
=
0
;
n
<
GetNumChannels
();
n
++
)
{
ITAHDFTSpectra
*
pHRTF
(
m_vpHRTFs
[
n
]
);
// two-channel
ITA
Base
::
C
HDFTSpectra
*
pHRTF
(
m_vpHRTFs
[
n
]
);
// two-channel
// --- WICK factor ---
...
...
@@ -309,7 +310,7 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
a
->
Add
(
m_fRegularizationFactor
);
d
->
Add
(
m_fRegularizationFactor
);
ITAHDFTSpectra
abcd
(
m_oConfig
.
fSampleRate
,
4
,
m_oConfig
.
iCTCFilterLength
);
ITA
Base
::
C
HDFTSpectra
abcd
(
m_oConfig
.
fSampleRate
,
4
,
m_oConfig
.
iCTCFilterLength
);
abcd
[
0
]
->
CopyFrom
(
*
a
);
abcd
[
1
]
->
CopyFrom
(
*
b
);
abcd
[
2
]
->
CopyFrom
(
*
c
);
...
...
@@ -344,8 +345,8 @@ void ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter ) con
for
(
int
n
=
0
;
n
<
GetNumChannels
();
n
++
)
{
ITAHDFTSpectra
*
pHRTF
(
m_vpHRTFs
[
n
]
);
// two-channel, already WICKed
ITAHDFTSpectra
*
pCTCFilter
(
vpCTCFilter
[
n
]
);
// two-channel
ITA
Base
::
C
HDFTSpectra
*
pHRTF
(
m_vpHRTFs
[
n
]
);
// two-channel, already WICKed
ITA
Base
::
C
HDFTSpectra
*
pCTCFilter
(
vpCTCFilter
[
n
]
);
// two-channel
const
float
&
fWeight
(
m_vfWeights
[
n
]
);
// diag element
t
->
Copy
(
a
);
...
...
@@ -500,7 +501,7 @@ int ITANCTC::GetOptimization() const
return
m_iOptimization
;
}
bool
ITANCTC
::
GetHRTF
(
std
::
vector
<
ITAHDFTSpectra
*
>&
vpHRTF
)
const
bool
ITANCTC
::
GetHRTF
(
std
::
vector
<
ITA
Base
::
C
HDFTSpectra
*
>&
vpHRTF
)
const
{
if
(
m_vpHRTFs
.
empty
()
)
return
false
;
...
...
src/ITANCTCStreamFilter.cpp
View file @
04fd3a2b
...
...
@@ -76,7 +76,7 @@ ITADatasource* ITANCTCStreamFilter::GetOutputDatasource() const
return
m_pdsOutput
;
}
void
ITANCTCStreamFilter
::
ExchangeFilters
(
const
std
::
vector
<
ITAHDFTSpectra
*
>&
vpCTCFilter
)
void
ITANCTCStreamFilter
::
ExchangeFilters
(
const
std
::
vector
<
ITA
Base
::
C
HDFTSpectra
*
>&
vpCTCFilter
)
{
// Helper (todo jst: use member variable for less alloc)
ITASampleBuffer
sbImpulseResponse
(
oConfig
.
iFilterLength
,
true
);
...
...
@@ -88,10 +88,10 @@ void ITANCTCStreamFilter::ExchangeFilters( const std::vector< ITAHDFTSpectra* >&
for
(
int
n
=
0
;
n
<
oConfig
.
N
;
n
++
)
{
const
ITAHDFTSpectra
*
oCTCFilter
(
vpCTCFilter
[
n
]
);
const
ITA
Base
::
C
HDFTSpectra
*
oCTCFilter
(
vpCTCFilter
[
n
]
);
const
ITAHDFTSpectrum
&
oCTCFilterL
(
*
(
*
oCTCFilter
)[
0
]
);
const
ITAHDFTSpectrum
&
oCTCFilterR
(
*
(
*
oCTCFilter
)[
1
]
);
const
ITA
Base
::
C
HDFTSpectrum
&
oCTCFilterL
(
*
(
*
oCTCFilter
)[
0
]
);
const
ITA
Base
::
C
HDFTSpectrum
&
oCTCFilterR
(
*
(
*
oCTCFilter
)[
1
]
);
int
iIdxLeft
=
2
*
n
+
0
;
int
iIdxRight
=
iIdxLeft
+
1
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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