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
5888ad2a
Commit
5888ad2a
authored
Jun 13, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Refactoring sample rate and speed of sound, now both float
parent
c358907e
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/ITANCTC.h
View file @
5888ad2a
...
...
@@ -117,8 +117,8 @@ public:
int
N
;
//!< Number of loudspeakers
int
iCTCFilterLength
;
//!< CTC filter taps, i.e. 4096
double
d
SampleRate
;
//!< Sampling rate
float
d
SpeedOfSound
;
//!< Speed of sound, m/s
float
f
SampleRate
;
//!< Sampling rate
float
f
SpeedOfSound
;
//!< Speed of sound, m/s
int
iOptimization
;
//!< Optimization algorithm (future work, see features/room_compensation)
float
fCrossTalkCancellationFactor
;
//!< Factor for cross-talk cancellation (none = 0.0, full = 1.0)
float
fWaveIncidenceAngleCompensationFactor
;
//!< Factor for cross-talk cancellation (none = 0.0, full = 1.0)
...
...
src/ITANCTC.cpp
View file @
5888ad2a
...
...
@@ -38,15 +38,15 @@ ITANCTC::ITANCTC( const Config& oNCTCConfig )
for
(
int
n
=
0
;
n
<
GetN
();
n
++
)
{
m_vdWeights
.
push_back
(
1.0
f
);
m_vpHRTFs
.
push_back
(
new
ITAHDFTSpectra
(
m_oConfig
.
d
SampleRate
,
2
,
iDFTSize
,
true
)
);
m_vfDelayTime
.
push_back
(
float
(
m_oConfig
.
iCTCFilterLength
/
m_oConfig
.
d
SampleRate
/
2.0
f
)
);
m_vpHRTFs
.
push_back
(
new
ITAHDFTSpectra
(
m_oConfig
.
f
SampleRate
,
2
,
iDFTSize
,
true
)
);
m_vfDelayTime
.
push_back
(
float
(
m_oConfig
.
iCTCFilterLength
)
/
m_oConfig
.
f
SampleRate
/
2.0
f
);
}
for
(
int
i
=
0
;
i
<
2
;
i
++
)
m_vpHelper2x2
.
push_back
(
new
ITAHDFTSpectra
(
m_oConfig
.
d
SampleRate
,
2
,
iDFTSize
,
true
)
);
m_vpHelper2x2
.
push_back
(
new
ITAHDFTSpectra
(
m_oConfig
.
f
SampleRate
,
2
,
iDFTSize
,
true
)
);
t
=
new
ITAHDFTSpectrum
(
m_oConfig
.
d
SampleRate
,
iDFTSize
,
true
);
det
=
new
ITAHDFTSpectrum
(
m_oConfig
.
d
SampleRate
,
iDFTSize
,
true
);
t
=
new
ITAHDFTSpectrum
(
m_oConfig
.
f
SampleRate
,
iDFTSize
,
true
);
det
=
new
ITAHDFTSpectrum
(
m_oConfig
.
f
SampleRate
,
iDFTSize
,
true
);
int
l
=
m_oConfig
.
iCTCFilterLength
;
m_fft
.
plan
(
ITAFFT
::
FFT_R2C
,
l
,
m_sfCTC_temp
[
0
].
data
(),
(
*
m_vpHRTFs
[
0
]
)[
0
]
->
data
()
);
...
...
@@ -148,7 +148,7 @@ void ITANCTC::AddHRIR( const Pose& oDest, ITASampleFrame& sfDestHRIR, bool& bOut
// Determine offset of target IR subtracting also the minimum distance to all LS
int
iHRIRPreOffset
=
m_pHRIR
->
getMinEffectiveFilterOffset
();
int
iHRIRFilerTaps
=
m_pHRIR
->
getMaxEffectiveFilterLength
();
int
iLS2HeadDelaySamples
=
int
(
dDistanceMeters
/
m_oConfig
.
d
SpeedOfSound
*
m_oConfig
.
d
SampleRate
);
int
iLS2HeadDelaySamples
=
int
(
dDistanceMeters
/
m_oConfig
.
f
SpeedOfSound
*
m_oConfig
.
f
SampleRate
);
int
iOffset
=
(
std
::
max
)(
0
,
(
int
(
iLS2HeadDelaySamples
)
-
iHRIRPreOffset
-
iDistanceCompensationSamples
)
);
// remove starting zeros from HRIR
// Check against buffer overrun, prevent if necessary and clamp to sweet spot boundary (end of IR)
...
...
@@ -177,7 +177,7 @@ bool ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter )
return
false
;
float
fMinDistance
=
GetMinimumDistanceHead2LS
();
int
iMinDistanceCompensationSamples
=
int
(
fMinDistance
/
m_oConfig
.
d
SpeedOfSound
*
m_oConfig
.
d
SampleRate
);
int
iMinDistanceCompensationSamples
=
int
(
fMinDistance
/
m_oConfig
.
f
SpeedOfSound
*
m_oConfig
.
f
SampleRate
);
bool
bOutOfRange
=
false
;
for
(
int
n
=
0
;
n
<
GetN
();
n
++
)
...
...
@@ -325,7 +325,7 @@ bool ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter )
a
->
add
(
m_fBeta
);
d
->
add
(
m_fBeta
);
ITAHDFTSpectra
abcd
(
m_oConfig
.
d
SampleRate
,
4
,
m_oConfig
.
iCTCFilterLength
);
ITAHDFTSpectra
abcd
(
m_oConfig
.
f
SampleRate
,
4
,
m_oConfig
.
iCTCFilterLength
);
abcd
[
0
]
->
copyFrom
(
*
a
);
abcd
[
1
]
->
copyFrom
(
*
b
);
abcd
[
2
]
->
copyFrom
(
*
c
);
...
...
@@ -396,7 +396,7 @@ bool ITANCTC::CalculateFilter( std::vector< ITAHDFTSpectra* >& vpCTCFilter )
m_sfCTC_temp
.
div_scalar
(
float
(
m_sfCTC_temp
.
length
()
)
);
// Shift the CTC filter according to desired delay
int
iShiftSamples
=
int
(
m_oConfig
.
d
SampleRate
*
m_vfDelayTime
[
n
]
);
int
iShiftSamples
=
int
(
m_oConfig
.
f
SampleRate
*
m_vfDelayTime
[
n
]
);
if
(
m_vfDelayTime
[
n
]
<
0.0
f
)
iShiftSamples
=
m_sfCTC_temp
.
length
()
/
2
;
// if invalid, shift by half length
sfTargetData_shift
.
cyclic_write
(
m_sfCTC_temp
,
m_sfCTC_temp
.
length
(),
0
,
iShiftSamples
);
...
...
@@ -596,7 +596,7 @@ ITANCTC::Config::Config()
// Set some default values
N
=
0
;
iCTCFilterLength
=
4096
;
d
SpeedOfSound
=
344.0
f
;
f
SpeedOfSound
=
344.0
f
;
iOptimization
=
OPTIMIZATION_NONE
;
fCrossTalkCancellationFactor
=
1.0
f
;
fWaveIncidenceAngleCompensationFactor
=
1.0
f
;
...
...
tests/NCTC_CTCFilterTest.cpp
View file @
5888ad2a
...
...
@@ -18,7 +18,7 @@ int main( int, char** )
ITANCTC
::
Config
oNCTCConfig
;
oNCTCConfig
.
iCTCFilterLength
=
10000
;
//2048;
oNCTCConfig
.
d
SampleRate
=
44.1e3
;
oNCTCConfig
.
f
SampleRate
=
44.1e3
;
oNCTCConfig
.
fSpeedOfSound
=
344.0
f
;
//oNCTCConfig.iOptimization = ITANCTC::Config::OPTIMIZATION_NONE;
//oNCTCConfig.iOptimization = ITANCTC::Config::OPTIMIZATION_AIXCAVE_FULLY_CLOSED;
...
...
@@ -98,7 +98,7 @@ int main( int, char** )
std
::
vector
<
ITAHDFTSpectra
*
>
vpCTCFilter
;
for
(
int
n
=
0
;
n
<
ctc
.
GetN
();
n
++
)
vpCTCFilter
.
push_back
(
new
ITAHDFTSpectra
(
oNCTCConfig
.
d
SampleRate
,
2
,
oNCTCConfig
.
iCTCFilterLength
+
1
,
true
)
);
vpCTCFilter
.
push_back
(
new
ITAHDFTSpectra
(
oNCTCConfig
.
f
SampleRate
,
2
,
oNCTCConfig
.
iCTCFilterLength
+
1
,
true
)
);
try
{
...
...
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