Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
I
ITAPropagationModels
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITAPropagationModels
Commits
0511c59b
Commit
0511c59b
authored
Jan 14, 2019
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding automated filter length estimation in tests
parent
f3fbfef1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
10 deletions
+91
-10
CMakeLists.txt
CMakeLists.txt
+2
-0
include/ITAPropagationModels/Utils.h
include/ITAPropagationModels/Utils.h
+39
-0
src/ITAPropagationModels/Utils.cpp
src/ITAPropagationModels/Utils.cpp
+45
-0
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.cpp
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.cpp
+5
-10
No files found.
CMakeLists.txt
View file @
0511c59b
...
...
@@ -22,12 +22,14 @@ set( ITAPropagationModelsHeader
"include/ITAPropagationModels/Maekawa.h"
"include/ITAPropagationModels/Svensson.h"
"include/ITAPropagationModels/UTD.h"
"include/ITAPropagationModels/Utils.h"
)
set
(
ITAPropagationModelsSources
"src/ITAPropagationModels/FilterEngine.cpp"
"src/ITAPropagationModels/Maekawa.cpp"
"src/ITAPropagationModels/Svensson.cpp"
"src/ITAPropagationModels/UTD.cpp"
"src/ITAPropagationModels/Utils.cpp"
)
...
...
include/ITAPropagationModels/Utils.h
0 → 100644
View file @
0511c59b
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTILS
#define INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTILS
#include "Definitions.h"
#include <ITAConstants.h>
#include <ITAGeo/Base.h>
namespace
ITAPropagationModels
{
namespace
Utils
{
//! Estimates the required filter length on a best guess approach and by using path length and directivities / meterials into account
/**
* @note Set the minimum at least to the block length of your audio stream
*/
ITA_PROPAGATION_MODELS_API
float
EstimateFilterLengthSamples
(
const
ITAGeo
::
CPropagationPath
&
oPath
,
const
float
fSampleRate
,
const
float
fMinimumSamples
=
64
,
const
float
fSpeedOfSound
=
ITAConstants
::
DEFAULT_SPEED_OF_SOUND_F
);
}
}
#endif // INCLUDE_WATCHER_ITA_PROPAGATION_MODELS_UTILS
src/ITAPropagationModels/Utils.cpp
0 → 100644
View file @
0511c59b
#include <ITAPropagationModels/Utils.h>
#include <ITAGeo/Base.h>
#include <ITAGeo/Material/Utils.h>
#include <ITAGeo/Directivity/Utils.h>
#include <ITAConstants.h>
#include <ITAException.h>
#include <cassert>
float
ITAPropagationModels
::
Utils
::
EstimateFilterLengthSamples
(
const
ITAGeo
::
CPropagationPath
&
oPath
,
const
float
fSampleRate
,
const
float
fMinimumSamples
,
const
float
fSpeedOfSound
)
{
float
fEstimatedFilterLengthSamples
=
fSampleRate
*
(
float
)
oPath
.
GetLength
();
for
(
auto
a
:
oPath
)
{
switch
(
a
->
iAnchorType
)
{
case
ITAGeo
::
CPropagationAnchor
::
ACOUSTIC_EMITTER
:
{
auto
p
=
std
::
dynamic_pointer_cast
<
const
ITAGeo
::
CEmitter
>
(
a
);
if
(
p
->
pDirectivity
)
fEstimatedFilterLengthSamples
+=
ITAGeo
::
Directivity
::
Utils
::
EstimateFilterLengthSamples
(
p
->
pDirectivity
,
fSampleRate
,
fSpeedOfSound
);
}
case
ITAGeo
::
CPropagationAnchor
::
ACOUSTIC_SENSOR
:
{
auto
p
=
std
::
dynamic_pointer_cast
<
const
ITAGeo
::
CSensor
>
(
a
);
if
(
p
->
pDirectivity
)
fEstimatedFilterLengthSamples
+=
ITAGeo
::
Directivity
::
Utils
::
EstimateFilterLengthSamples
(
p
->
pDirectivity
,
fSampleRate
,
fSpeedOfSound
);
}
case
ITAGeo
::
CPropagationAnchor
::
SPECULAR_REFLECTION
:
{
auto
p
=
std
::
dynamic_pointer_cast
<
const
ITAGeo
::
CSpecularReflection
>
(
a
);
if
(
p
->
pAcousticMaterial
)
fEstimatedFilterLengthSamples
+=
ITAGeo
::
Material
::
Utils
::
EstimateFilterLengthSamples
(
p
->
pAcousticMaterial
,
fSampleRate
,
fSpeedOfSound
);
}
default:
{
if
(
fEstimatedFilterLengthSamples
<
fMinimumSamples
)
fEstimatedFilterLengthSamples
=
fMinimumSamples
;
}
}
}
return
fEstimatedFilterLengthSamples
;
}
tests/ReceiverDirectivityTest/ReceiverDirectivityTest.cpp
View file @
0511c59b
...
...
@@ -18,6 +18,7 @@
#include <ITAPropagationModels/FilterEngine.h>
#include <ITAPropagationModels/Utils.h>
#include <ITAGeo/Base.h>
#include <ITAGeo/Directivity/Base.h>
...
...
@@ -30,6 +31,8 @@ using namespace ITAConstants;
using
namespace
ITAGeo
;
using
namespace
ITAPropagationModels
;
const
float
fSampleRate
=
44.1e3
f
;
int
main
(
int
,
char
**
)
{
auto
pSenderLeft
=
make_shared
<
CEmitter
>
(
VistaVector3D
(
-
2.0
f
,
0.0
f
,
0.0
f
));
...
...
@@ -51,13 +54,8 @@ int main( int, char** )
CFilterEngine
oFilterEngine
;
// Set filter length according to the maximum path length
const
float
fSpeedOfSound
=
DEFAULT_SPEED_OF_SOUND_F
;
// Approximation of speed of sound at ~20C
const
float
fSampleRate
=
44.1e3
f
;
int
iFilterLengthSamples
=
(
int
)(
oPathFromLeft
.
GetLength
()
/
fSpeedOfSound
*
fSampleRate
);
iFilterLengthSamples
=
int
(
iFilterLengthSamples
+
4096
);
ITABase
::
CHDFTSpectra
oTransmissionFilterLeft
(
fSampleRate
,
pReceiver
->
GetNumChannels
(),
iFilterLengthSamples
);
int
iFilterLengthSamples
=
(
int
)
ceil
(
Utils
::
EstimateFilterLengthSamples
(
oPathFromLeft
,
fSampleRate
));
ITABase
::
CHDFTSpectra
oTransmissionFilterLeft
(
fSampleRate
,
pReceiver
->
GetNumChannels
(),
iFilterLengthSamples
);
bool
bDFTDegreeTooSmallFlag
;
oFilterEngine
.
Generate
(
oPathFromLeft
,
oTransmissionFilterLeft
,
&
bDFTDegreeTooSmallFlag
);
...
...
@@ -67,9 +65,6 @@ int main( int, char** )
ITAFFTUtils
::
Export
(
&
oTransmissionFilterLeft
,
"SourceFromLeft.wav"
);
// Exports in time domain as impulse response (IR)
iFilterLengthSamples
=
(
int
)(
oPathFromRight
.
GetLength
()
/
fSpeedOfSound
*
fSampleRate
);
iFilterLengthSamples
=
int
(
iFilterLengthSamples
+
4096
);
ITABase
::
CHDFTSpectra
oTransmissionFilterRight
(
fSampleRate
,
pReceiver
->
GetNumChannels
(),
iFilterLengthSamples
);
oFilterEngine
.
Generate
(
oPathFromRight
,
oTransmissionFilterRight
,
&
bDFTDegreeTooSmallFlag
);
...
...
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