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
74a0c562
Commit
74a0c562
authored
Jun 13, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Removing return true/false for calculate filter, will now raise exceptions.
parent
5888ad2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/ITANCTC.h
View file @
74a0c562
...
...
@@ -293,11 +293,13 @@ public:
//! Calculate the CTC filters
/**
* Starts calculation
* \param vpSpectra vector of two-channel CTC filter spectra for each loudspeaker (call-by-ref), will update filter in vector if possible
* \return True, if calculation was possible
* Designs CTC filters
*
* @param[out] vpSpectra Target vector of two-channel CTC filter spectra for each loudspeaker (call-by-ref)
*
* @note Will raise ITAException on error
*/
bool
CalculateFilter
(
std
::
vector
<
ITAHDFTSpectra
*
>&
vpSpectra
);
void
CalculateFilter
(
std
::
vector
<
ITAHDFTSpectra
*
>&
vpSpectra
)
const
;
//! Calculate the Wiener-Hopf factorization
void
WienerHopfFactorization
(
ITAHDFTSpectrum
*
voSpecIn
,
ITAHDFTSpectrum
*
voSpecOutPlus
,
ITAHDFTSpectrum
*
voSpecOutMinus
);
...
...
@@ -316,22 +318,23 @@ private:
Pose
m_oHeadPose
;
//!< Current head Pose data
ITAFFT
m_fft
,
m_ifft
;
//!< Internal FFT and IFFT transformations
ITASampleFrame
m_sfCTC_temp
;
//!< Internal CTC helper
mutable
ITAFFT
m_fft
,
m_ifft
;
//!< Internal FFT and IFFT transformations
mutable
ITASampleFrame
m_sfCTC_temp
;
//!< Internal CTC helper
std
::
vector
<
double
>
m_vdWeights
;
//!< 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
int
GetLoudspeakerSide
(
int
);
int
GetLoudspeakerSide
(
int
)
const
;
//! Adds a HRIR into the target filter
/**
* @param oLoudspeakerPose Pose of loudspeaker (or virtual source)
* @param bOutOfRange Indicator if the HRIR data for the required position is out of range
* @param sfTargetIR Target impulse response, where the HRIR will be placed by mul-adding with given gain
*
* @return True, if samples from HRIR could be copied into target filter, false, if target filter is too short
*/
void
AddHRIR
(
const
Pose
&
oLoudspeakerPose
,
ITASampleFrame
&
sfTargetIR
,
bool
&
bOutOfRange
,
const
double
dGain
=
1.0
f
,
const
int
iDistanceCompensationSamples
=
0
)
const
;
...
...
src/ITANCTC.cpp
View file @
74a0c562
...
...
@@ -84,7 +84,7 @@ void ITANCTC::UpdateHeadPose( const Pose& oHead )
return
;
}
int
ITANCTC
::
GetLoudspeakerSide
(
int
iNumLoudspeaker
)
int
ITANCTC
::
GetLoudspeakerSide
(
int
iNumLoudspeaker
)
const
{
Pose
oDest
=
GetLoudspeakerPose
(
iNumLoudspeaker
);
...
...
@@ -112,7 +112,9 @@ void ITANCTC::AddHRIR( const Pose& oDest, ITASampleFrame& sfDestHRIR, bool& bOut
{
if
(
sfDestHRIR
.
channels
()
!=
2
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Two channel HRIR expected"
);
if
(
!
m_pHRIR
)
ITA_EXCEPT1
(
MODAL_EXCEPTION
,
"HRIR missing"
);
// Calculate sample delay of HRIR insertion position
VistaVector3D
v3Conn
=
oDest
.
vPos
-
m_oHeadPose
.
vPos
;
double
dDistanceMeters
=
double
(
v3Conn
.
GetLength
()
);
...
...
@@ -121,21 +123,6 @@ void ITANCTC::AddHRIR( const Pose& oDest, ITASampleFrame& sfDestHRIR, bool& bOut
// Note: Gain of HRIR dataset is normalized to 1 m according to convention
float
fDistanceGain
=
1
/
(
float
)
dDistanceMeters
;
// @todo jst: mit VistaQuaternion lsen
/*
VistaVector3D oFrom = vConn;
oFrom.Normalize();
VistaQuaternion qOri( Vista::ViewVector, oFrom );
VistaQuaternion qHead2LS = qOri * m_oHeadPose.qOrient;
float fX, fY, fZ;
qHead2LS.GetAngles( fX, fY, fZ );
VistaVector3D v3View = qHead2LS.GetViewDir();
float fPhi = 180.0f / PI_F * fY;
float fTheta = 180.0f / PI_F * fX;
*/
double
dPhiDeg
,
dThetaDeg
;
VistaVector3D
vDir
=
v3Conn
.
GetNormalized
();
...
...
@@ -171,10 +158,10 @@ const ITANCTC::Pose& ITANCTC::GetLoudspeakerPose( int iLoudspeakerID ) const
return
m_oConfig
.
voLoudspeaker
[
iLoudspeakerID
-
1
].
oPose
;
}
bool
ITANCTC
::
CalculateFilter
(
std
::
vector
<
ITAHDFTSpectra
*
>&
vpCTCFilter
)
void
ITANCTC
::
CalculateFilter
(
std
::
vector
<
ITAHDFTSpectra
*
>&
vpCTCFilter
)
const
{
if
(
!
m_pHRIR
)
return
false
;
ITA_EXCEPT1
(
MODAL_EXCEPTION
,
"CTC filters could not be created because HRIR is not set"
)
;
float
fMinDistance
=
GetMinimumDistanceHead2LS
();
int
iMinDistanceCompensationSamples
=
int
(
fMinDistance
/
m_oConfig
.
fSpeedOfSound
*
m_oConfig
.
fSampleRate
);
...
...
@@ -408,8 +395,6 @@ bool ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter )
ITAFFTUtils
::
Export
(
pCTCFilter
,
"CTCFilter_shift_"
+
IntToString
(
n
+
1
));
#endif // NCTC_EXPORT_FILTER_TO_HARDDRIVE
}
return
true
;
}
void
ITANCTC
::
SetHRIR
(
const
DAFFContentIR
*
pHRIR
)
...
...
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