Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
VACore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
VACore
Commits
bb7f2ad7
Commit
bb7f2ad7
authored
Jan 11, 2019
by
lmoesch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pre final
parent
f2aaa7dc
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
311 additions
and
167 deletions
+311
-167
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralCluster.cpp
...ealTime/Utils/BinauralClusterEngine/VABinauralCluster.cpp
+35
-50
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralCluster.h
.../RealTime/Utils/BinauralClusterEngine/VABinauralCluster.h
+2
-2
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClustering.cpp
...Time/Utils/BinauralClusterEngine/VABinauralClustering.cpp
+43
-6
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClustering.h
...alTime/Utils/BinauralClusterEngine/VABinauralClustering.h
+9
-2
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClusteringState.cpp
...Utils/BinauralClusterEngine/VABinauralClusteringState.cpp
+8
-4
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClusteringState.h
...e/Utils/BinauralClusterEngine/VABinauralClusteringState.h
+4
-1
src/Rendering/Binaural/RealTime/Utils/BinauralSoundSource/VABinauralSoundSource.cpp
...lTime/Utils/BinauralSoundSource/VABinauralSoundSource.cpp
+2
-2
src/Rendering/Binaural/RealTime/Utils/BinauralTimeOfArrivalEstimator/VABinauralTOAEstimator.cpp
...BinauralTimeOfArrivalEstimator/VABinauralTOAEstimator.cpp
+24
-1
src/Rendering/Binaural/RealTime/Utils/BinauralTimeOfArrivalEstimator/VABinauralTOAEstimator.h
...s/BinauralTimeOfArrivalEstimator/VABinauralTOAEstimator.h
+5
-0
src/Rendering/Binaural/RealTime/VABinauralRealTimeRenderer.cpp
...endering/Binaural/RealTime/VABinauralRealTimeRenderer.cpp
+47
-35
tests/VABinauralRealTimeRendererTest.cpp
tests/VABinauralRealTimeRendererTest.cpp
+132
-64
No files found.
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralCluster.cpp
View file @
bb7f2ad7
#define NOMINMAX
#include <stdlib.h>
#include <math.h>
#include "VABinauralCluster.h"
...
...
@@ -20,42 +21,21 @@ VABinauralCluster::VABinauralCluster()
{
_output
=
new
ITASampleFrame
(
2
,
VAConfig
::
blockLength
,
true
);
_tempHRIR
=
new
ITASampleFrame
(
2
,
VAConfig
::
hrirLength
,
true
);
// initialize left channel convolver for each cluster
_FIRConvolverChL
=
new
ITAUPConvolution
(
VAConfig
::
blockLength
,
VAConfig
::
hrirLength
);
_FIRConvolverChL
->
SetFilterExchangeFadingFunction
(
ITABase
::
FadingFunction
::
COSINE_SQUARE
);
_FIRConvolverChL
->
SetFilterCrossfadeLength
((
std
::
min
)(
VAConfig
::
blockLength
,
32
));
_FIRConvolverChL
->
SetGain
(
1.0
f
,
true
);
ITAUPFilter
*
HRIRFilterChL
=
_FIRConvolverChL
->
RequestFilter
();
HRIRFilterChL
->
identity
();
_FIRConvolverChL
->
ExchangeFilter
(
HRIRFilterChL
);
// initialize right channel convolver for each cluster
_FIRConvolverChR
=
new
ITAUPConvolution
(
VAConfig
::
blockLength
,
VAConfig
::
hrirLength
);
_FIRConvolverChR
->
SetFilterExchangeFadingFunction
(
ITABase
::
FadingFunction
::
COSINE_SQUARE
);
_FIRConvolverChR
->
SetFilterCrossfadeLength
((
std
::
min
)(
VAConfig
::
blockLength
,
32
));
_FIRConvolverChR
->
SetGain
(
1.0
f
,
true
);
ITAUPFilter
*
HRIRFilterChR
=
_FIRConvolverChR
->
RequestFilter
();
HRIRFilterChR
->
identity
();
_FIRConvolverChR
->
ExchangeFilter
(
HRIRFilterChR
);
}
VABinauralCluster
::~
VABinauralCluster
()
{}
void
VABinauralCluster
::
init
(
int
sourceID
,
VABinauralSoundSource
*
source
,
VABinauralListener
*
listener
)
VABinauralCluster
::
init
(
int
sourceID
,
VABinauralSoundSource
*
source
,
VABinauralListener
*
listener
,
ITAUPConvolution
*
firL
,
ITAUPConvolution
*
firR
)
{
_listener
=
listener
;
_listenerPos
=
listener
->
predPos
;
_clusterSourcePos
=
_clusterSourcePos
+
source
->
predPos
;
_clusterSourceToListenerPos
=
_clusterSourcePos
-
_listenerPos
;
_clusterSourcePos
=
source
->
predPos
-
listener
->
predPos
;
_clusterSourcePos
.
Norm
();
_FIRConvolverChL
=
firL
;
_FIRConvolverChR
=
firR
;
int
outputLength
=
listener
->
output
->
GetLength
();
if
(
_output
->
length
()
!=
outputLength
)
_output
->
init
(
2
,
outputLength
,
true
);
...
...
@@ -79,9 +59,7 @@ void
VABinauralCluster
::
init
(
VABinauralCluster
*
cluster
)
{
_listener
=
cluster
->
_listener
;
_listenerPos
=
_listener
->
predPos
;
_clusterSourcePos
=
cluster
->
_clusterSourcePos
;
_clusterSourceToListenerPos
=
_clusterSourcePos
-
_listenerPos
;
int
outputLength
=
_listener
->
output
->
GetLength
();
...
...
@@ -90,16 +68,7 @@ VABinauralCluster::init(VABinauralCluster* cluster)
_tmpChL
.
Init
(
_listener
->
output
->
GetLength
(),
true
);
_tmpChR
.
Init
(
_listener
->
output
->
GetLength
(),
true
);
maxError
=
cluster
->
maxError
;
std
::
map
<
int
,
VABinauralSoundSource
*>::
const_iterator
it
;
for
(
it
=
cluster
->
_sources
.
begin
();
it
!=
cluster
->
_sources
.
end
();
++
it
)
{
_sources
.
insert
(
std
::
pair
<
int
,
VABinauralSoundSource
*>
(
it
->
first
,
it
->
second
));
it
->
second
->
AddReference
();
}
numSources
=
cluster
->
numSources
;
numSources
=
0
;
}
ITASampleFrame
*
...
...
@@ -110,10 +79,13 @@ VABinauralCluster::getOutput()
// get cluster HRTF TOA
VARelationMetrics
clusterSourceMetrics
;
clusterSourceMetrics
.
calc
(
_listener
->
predPos
,
_listener
->
predView
,
_listener
->
predUp
,
_clusterSourcePos
);
clusterSourceMetrics
.
calc
(
_listener
->
predPos
,
_listener
->
predView
,
_listener
->
predUp
,
_listener
->
predPos
+
_clusterSourcePos
);
// double toaHRTFChL = _listener->toaEstimator->getTOALeft(clusterSourceMetrics.phi, clusterSourceMetrics.theta);
// double toaHRTFChR = _listener->toaEstimator->getTOARight(clusterSourceMetrics.phi, clusterSourceMetrics.theta);
double
toaHRTFChL
=
_listener
->
toaEstimator
->
getTOA
Left
(
clusterSourceMetrics
.
phi
,
clusterSourceMetrics
.
theta
);
double
toaHRTFChR
=
_listener
->
toaEstimator
->
getTOA
Right
(
clusterSourceMetrics
.
phi
,
clusterSourceMetrics
.
theta
);
double
toaHRTFChL
=
_listener
->
toaEstimator
->
getTOA
(
VAVec3
(
-
1
,
0
,
0
),
_clusterSourcePos
);
double
toaHRTFChR
=
_listener
->
toaEstimator
->
getTOA
(
VAVec3
(
1
,
0
,
0
),
_clusterSourcePos
);
// set VDL Values
std
::
map
<
int
,
VABinauralSoundSource
*>::
const_iterator
it
;
...
...
@@ -126,13 +98,19 @@ VABinauralCluster::getOutput()
sourceMetrics
.
calc
(
_listener
->
predPos
,
_listener
->
predView
,
_listener
->
predUp
,
source
->
predPos
);
double
toaDistance
=
sourceMetrics
.
dist
/
343
;
// TODO: Medium Propagation....
double
toaSourceChL
=
_listener
->
toaEstimator
->
getTOALeft
(
sourceMetrics
.
phi
,
sourceMetrics
.
theta
);
double
toSourceaChR
=
_listener
->
toaEstimator
->
getTOARight
(
sourceMetrics
.
phi
,
sourceMetrics
.
theta
);
//double toaSourceChL = _listener->toaEstimator->getTOALeft(sourceMetrics.phi, sourceMetrics.theta);
//double toSourceaChR = _listener->toaEstimator->getTOARight(sourceMetrics.phi, sourceMetrics.theta);
double
toaSourceChL
=
_listener
->
toaEstimator
->
getTOA
(
VAVec3
(
-
1
,
0
,
0
),
source
->
predPos
-
_listener
->
predPos
);
double
toaSourceChR
=
_listener
->
toaEstimator
->
getTOA
(
VAVec3
(
1
,
0
,
0
),
source
->
predPos
-
_listener
->
predPos
);
float
gain
=
float
(
1
/
sourceMetrics
.
dist
*
source
->
state
->
GetVolume
(
VAConfig
::
amplitudeCalibration
));
float
gain
=
float
(
(
1
/
sourceMetrics
.
dist
)
*
source
->
state
->
GetVolume
(
VAConfig
::
amplitudeCalibration
));
source
->
vdlChL
->
SetDelayTime
(
toaDistance
+
toaSourceChL
-
toaHRTFChL
);
source
->
vdlChR
->
SetDelayTime
(
toaDistance
+
toSourceaChR
-
toaHRTFChR
);
// source->vdlChL->SetDelayTime(std::max(0., toaDistance + toaSourceChL - toaHRTFChL));
// source->vdlChR->SetDelayTime(std::max(0., toaDistance + toaSourceChR - toaHRTFChR));
source
->
vdlChL
->
SetDelayTime
(
toaDistance
);
source
->
vdlChR
->
SetDelayTime
(
toaDistance
);
source
->
vdlChL
->
Process
(
input
,
&
(
_tmpChL
));
source
->
vdlChR
->
Process
(
input
,
&
(
_tmpChR
));
...
...
@@ -150,17 +128,25 @@ VABinauralCluster::getOutput()
ITAUPFilter
*
HRIRFilterChL
=
_FIRConvolverChL
->
GetFilterPool
()
->
RequestFilter
();
ITAUPFilter
*
HRIRFilterChR
=
_FIRConvolverChR
->
GetFilterPool
()
->
RequestFilter
();
HRIRFilterChL
->
Zeros
();
HRIRFilterChR
->
Zeros
();
if
(
HRIR
){
int
index
=
-
1
;
int
filterLength
=
0
;
filterLength
=
HRIR
->
GetProperties
()
->
iFilterLength
;
_tempHRIR
->
init
(
2
,
filterLength
,
true
);
if
(
_tempHRIR
->
length
()
!=
filterLength
)
{
_tempHRIR
->
init
(
2
,
filterLength
,
false
);
}
float
phi
=
clusterSourceMetrics
.
phi
*
180
/
ITAConstants
::
PI_F
;
float
theta
=
clusterSourceMetrics
.
theta
*
180
/
ITAConstants
::
PI_F
;
HRIR
->
GetHRIR
(
_tempHRIR
,
clusterSourceMetrics
.
phi
*
180
/
ITAConstants
::
PI_F
,
clusterSourceMetrics
.
theta
*
180
/
ITAConstants
::
PI_F
,
clusterSourceMetrics
.
dist
);
HRIRFilterChL
->
Load
((
*
_tempHRIR
)[
0
].
data
(),
filterLength
);
...
...
@@ -181,7 +167,7 @@ VABinauralCluster::getOutput()
double
VABinauralCluster
::
getDistError
(
VABinauralSoundSource
*
source
)
{
VAVec3
sourceToListenerPos
=
source
->
predPos
-
_listenerPos
;
VAVec3
sourceToListenerPos
=
source
->
predPos
-
_listener
->
pred
Pos
;
VAVec3
dist
;
sourceToListenerPos
.
Norm
();
...
...
@@ -202,7 +188,6 @@ VABinauralCluster::addSource(int sourceID, VABinauralSoundSource* source)
_clusterSourcePos
=
_clusterSourcePos
+
(
sourceToListenerPos
-
_clusterSourcePos
)
/
(
numSources
+
1
);
_clusterSourcePos
.
Norm
();
_clusterSourceToListenerPos
=
_clusterSourcePos
-
_listenerPos
;
maxError
=
std
::
max
(
err
,
maxError
);
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralCluster.h
View file @
bb7f2ad7
...
...
@@ -23,7 +23,7 @@ public:
~
VABinauralCluster
();
void
init
(
int
sourceID
,
VABinauralSoundSource
*
source
,
VABinauralListener
*
listener
);
init
(
int
sourceID
,
VABinauralSoundSource
*
source
,
VABinauralListener
*
listener
,
ITAUPConvolution
*
firL
,
ITAUPConvolution
*
firR
);
void
init
(
VABinauralCluster
*
cluster
);
...
...
@@ -57,7 +57,7 @@ private:
ITASampleFrame
*
_tempHRIR
;
VABinauralListener
*
_listener
;
ITAUPConvolution
*
_FIRConvolverChL
;
ITAUPConvolution
*
_FIRConvolverChR
;
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClustering.cpp
View file @
bb7f2ad7
...
...
@@ -2,7 +2,7 @@
#include <limits>
#include <algorithm>
#include <memory>
#include <math.h>
// VA
...
...
@@ -12,6 +12,7 @@
#include <ITAUPFilter.h>
// Utils
#include "../Config/VAConfig.h"
#include "./VABinauralClustering.h"
#include "./VABinauralClusterPoolFactory.h"
...
...
@@ -41,11 +42,44 @@ VABinauralClustering::init(int listenerID, VABinauralListener* listener, int num
_listenerID
=
listenerID
;
_listener
=
listener
;
_numClusters
=
numClusters
;
_threshold
=
1
.
/
numClusters
;
_threshold
=
4
.
/
numClusters
;
_output
=
new
ITASampleFrame
(
2
,
listener
->
output
->
GetLength
(),
true
);
_curState
.
reset
(
new
VABinauralClusteringState
(
_numClusters
,
_listener
,
clusterPool
));
for
(
int
i
=
0
;
i
<
numClusters
;
++
i
)
{
// initialize left channel convolver for each cluster
ITAUPConvolution
*
_FIRConvolverChL
=
new
ITAUPConvolution
(
VAConfig
::
blockLength
,
VAConfig
::
hrirLength
);
_FIRConvolverChL
->
SetFilterExchangeFadingFunction
(
ITABase
::
FadingFunction
::
COSINE_SQUARE
);
_FIRConvolverChL
->
SetFilterCrossfadeLength
((
std
::
min
)(
VAConfig
::
blockLength
,
32
));
_FIRConvolverChL
->
SetGain
(
1.0
f
,
true
);
ITAUPFilter
*
HRIRFilterChL
=
_FIRConvolverChL
->
RequestFilter
();
HRIRFilterChL
->
identity
();
_FIRConvolverChL
->
ExchangeFilter
(
HRIRFilterChL
);
_FIRConvolverChL
->
ReleaseFilter
(
HRIRFilterChL
);
FIRConvolversL
.
insert
(
std
::
pair
<
int
,
ITAUPConvolution
*
>
(
i
,
_FIRConvolverChL
));
// initialize right channel convolver for each cluster
ITAUPConvolution
*
_FIRConvolverChR
=
new
ITAUPConvolution
(
VAConfig
::
blockLength
,
VAConfig
::
hrirLength
);
_FIRConvolverChR
->
SetFilterExchangeFadingFunction
(
ITABase
::
FadingFunction
::
COSINE_SQUARE
);
_FIRConvolverChR
->
SetFilterCrossfadeLength
((
std
::
min
)(
VAConfig
::
blockLength
,
32
));
_FIRConvolverChR
->
SetGain
(
1.0
f
,
true
);
ITAUPFilter
*
HRIRFilterChR
=
_FIRConvolverChR
->
RequestFilter
();
HRIRFilterChR
->
identity
();
_FIRConvolverChR
->
ExchangeFilter
(
HRIRFilterChR
);
_FIRConvolverChR
->
ReleaseFilter
(
HRIRFilterChR
);
FIRConvolversR
.
insert
(
std
::
pair
<
int
,
ITAUPConvolution
*
>
(
i
,
_FIRConvolverChR
));
}
_curState
.
reset
(
new
VABinauralClusteringState
(
_numClusters
,
_listener
,
clusterPool
,
&
FIRConvolversL
,
&
FIRConvolversR
));
_prevState
=
_curState
;
}
ITASampleFrame
*
...
...
@@ -54,7 +88,7 @@ VABinauralClustering::getOutput()
_output
->
zero
();
// swap out clustering state
if
(
_nextState
!=
nullptr
){
_curState
.
reset
(
_nextState
.
release
())
;
_curState
=
_nextState
;
};
std
::
map
<
int
,
VABinauralCluster
*>::
const_iterator
clusterIt
;
...
...
@@ -76,8 +110,10 @@ VABinauralClustering::update()
// if (_nextState == nullptr)
// {
VABinauralClusteringState
*
state
=
new
VABinauralClusteringState
(
_numClusters
,
_listener
,
clusterPool
);
//new VABinauralClusteringState(*_curState);
//VABinauralClusteringState* state = new VABinauralClusteringState(_numClusters, _listener, clusterPool, FIRConvolversL, FIRConvolversR); //new VABinauralClusteringState(*_curState);
//std::shared_ptr<VABinauralClusteringState> state = std::make_shared<VABinauralClusteringState>(*_prevState);
std
::
shared_ptr
<
VABinauralClusteringState
>
state
=
std
::
make_shared
<
VABinauralClusteringState
>
(
_numClusters
,
_listener
,
clusterPool
,
&
FIRConvolversL
,
&
FIRConvolversR
);
// remove removed sources
std
::
set
<
int
>::
const_iterator
it
;
...
...
@@ -118,7 +154,8 @@ VABinauralClustering::update()
//_unassignedSources.clear();
_nextState
.
reset
(
state
);
_nextState
=
state
;
_prevState
=
_nextState
;
// }
}
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClustering.h
View file @
bb7f2ad7
...
...
@@ -7,6 +7,9 @@
#include <VA.h>
#include <VAPoolObject.h>
// Ita includes
#include <ITAUPConvolution.h>
// Utils
#include "VABinauralCluster.h"
#include "VABinauralClusteringState.h"
...
...
@@ -40,6 +43,9 @@ public:
void
removeSource
(
int
sourceID
);
std
::
map
<
int
,
ITAUPConvolution
*
>
FIRConvolversL
;
std
::
map
<
int
,
ITAUPConvolution
*
>
FIRConvolversR
;
private:
int
_listenerID
;
...
...
@@ -51,8 +57,9 @@ private:
std
::
set
<
int
>
_delSourceIDs
;
std
::
unique_ptr
<
VABinauralClusteringState
>
_curState
;
std
::
unique_ptr
<
VABinauralClusteringState
>
_nextState
;
std
::
shared_ptr
<
VABinauralClusteringState
>
_curState
;
std
::
shared_ptr
<
VABinauralClusteringState
>
_prevState
;
std
::
shared_ptr
<
VABinauralClusteringState
>
_nextState
;
std
::
map
<
int
,
VABinauralSoundSource
*
>
_unassignedSources
;
std
::
map
<
int
,
VABinauralSoundSource
*
>
_assignedSources
;
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClusteringState.cpp
View file @
bb7f2ad7
...
...
@@ -10,10 +10,12 @@
#include "./VABinauralClusterPoolFactory.h"
VABinauralClusteringState
::
VABinauralClusteringState
(
int
numClusters
,
VABinauralListener
*
listener
,
IVAObjectPool
*
clusterPool
)
:
VABinauralClusteringState
::
VABinauralClusteringState
(
int
numClusters
,
VABinauralListener
*
listener
,
IVAObjectPool
*
clusterPool
,
std
::
map
<
int
,
ITAUPConvolution
*
>
*
FIRConvolversL
,
std
::
map
<
int
,
ITAUPConvolution
*
>
*
FIRConvolversR
)
:
numClusters
(
numClusters
),
listener
(
listener
),
_clusterPool
(
clusterPool
)
_clusterPool
(
clusterPool
),
_FIRConvolversL
(
FIRConvolversL
),
_FIRConvolversR
(
FIRConvolversR
)
{
for
(
int
i
=
numClusters
-
1
;
i
>=
0
;
--
i
)
...
...
@@ -27,7 +29,9 @@ VABinauralClusteringState::VABinauralClusteringState(const VABinauralClusteringS
listener
(
state
.
listener
),
sourceClusterReference
(
state
.
sourceClusterReference
),
freeClusterIDs
(
state
.
freeClusterIDs
),
_clusterPool
(
state
.
_clusterPool
)
_clusterPool
(
state
.
_clusterPool
),
_FIRConvolversL
(
state
.
_FIRConvolversL
),
_FIRConvolversR
(
state
.
_FIRConvolversR
)
{
std
::
map
<
int
,
VABinauralCluster
*
>::
const_iterator
it
;
...
...
@@ -104,7 +108,7 @@ VABinauralClusteringState::createCluster(int sourceID, VABinauralSoundSource* s
int
clusterID
=
freeClusterIDs
.
front
();
VABinauralCluster
*
cluster
=
dynamic_cast
<
VABinauralCluster
*
>
(
_clusterPool
->
RequestObject
());
// Reference = 1
cluster
->
init
(
sourceID
,
source
,
listener
);
cluster
->
init
(
sourceID
,
source
,
listener
,
_FIRConvolversL
->
find
(
clusterID
)
->
second
,
_FIRConvolversR
->
find
(
clusterID
)
->
second
);
clusters
.
insert
(
std
::
pair
<
int
,
VABinauralCluster
*
>
(
clusterID
,
cluster
));
freeClusterIDs
.
pop
();
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClusteringState.h
View file @
bb7f2ad7
...
...
@@ -24,9 +24,12 @@ public:
std
::
map
<
int
,
int
>
sourceClusterReference
;
std
::
map
<
int
,
VABinauralCluster
*
>
clusters
;
std
::
map
<
int
,
ITAUPConvolution
*
>
*
_FIRConvolversL
;
std
::
map
<
int
,
ITAUPConvolution
*
>
*
_FIRConvolversR
;
VABinauralListener
*
listener
;
VABinauralClusteringState
(
int
numClusters
,
VABinauralListener
*
listener
,
IVAObjectPool
*
clusterPool
);
VABinauralClusteringState
(
int
numClusters
,
VABinauralListener
*
listener
,
IVAObjectPool
*
clusterPool
,
std
::
map
<
int
,
ITAUPConvolution
*
>
*
FIRConvolversL
,
std
::
map
<
int
,
ITAUPConvolution
*
>
*
FIRConvolversR
);
VABinauralClusteringState
(
const
VABinauralClusteringState
&
state
);
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralSoundSource/VABinauralSoundSource.cpp
View file @
bb7f2ad7
...
...
@@ -4,8 +4,8 @@
VABinauralSoundSource
::
VABinauralSoundSource
(
const
config_t
&
conf
)
:
conf
(
conf
)
{
vdlChL
=
new
CITAVariableDelayLine
(
conf
.
sampleRate
,
conf
.
blockLength
,
3.
*
conf
.
sampleRate
,
CITAVariableDelayLine
::
SWITCH
);
vdlChR
=
new
CITAVariableDelayLine
(
conf
.
sampleRate
,
conf
.
blockLength
,
3.
*
conf
.
sampleRate
,
CITAVariableDelayLine
::
SWITCH
);
vdlChL
=
new
CITAVariableDelayLine
(
conf
.
sampleRate
,
conf
.
blockLength
,
3.
*
conf
.
sampleRate
,
CITAVariableDelayLine
::
CUBIC_SPLINE_INTERPOLATION
);
vdlChR
=
new
CITAVariableDelayLine
(
conf
.
sampleRate
,
conf
.
blockLength
,
3.
*
conf
.
sampleRate
,
CITAVariableDelayLine
::
CUBIC_SPLINE_INTERPOLATION
);
}
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralTimeOfArrivalEstimator/VABinauralTOAEstimator.cpp
View file @
bb7f2ad7
#define _USE_MATH_DEFINES
#define SPEEDOFSOUND 343
#define HEADRADIUS 0.0
6
#define HEADRADIUS 0.0
9
#define DELAY (HEADRADIUS / SPEEDOFSOUND)
#include <VA.h>
#include "VABinauralTOAEstimator.h"
#include <math.h>
...
...
@@ -18,6 +20,27 @@ VABinauralTOAEstimator::~VABinauralTOAEstimator()
{
}
double
VABinauralTOAEstimator
::
getTOA
(
VAVec3
&
ear
,
VAVec3
&
source
)
{
VAVec3
_ear
=
VAVec3
(
ear
);
VAVec3
_source
=
VAVec3
(
source
);
_ear
.
Norm
();
_source
.
Norm
();
double
alpha
=
std
::
acos
(
_ear
.
Dot
(
_source
));
if
(
alpha
<=
M_PI
)
{
return
DELAY
*
(
1
-
cos
(
alpha
));
}
else
{
return
DELAY
*
(
1
+
alpha
-
M_PI
/
2
);
}
}
double
VABinauralTOAEstimator
::
getTOALeft
(
double
phi
,
double
theta
)
{
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralTimeOfArrivalEstimator/VABinauralTOAEstimator.h
View file @
bb7f2ad7
#ifndef IW_VACORE_BINAURALTIMEOFARRIVALESTIMATOR
#define IW_VACORE_BINAURALTIMEOFARRIVALESTIMATOR
#include <VA.h>
class
VABinauralTOAEstimator
{
public:
...
...
@@ -10,6 +12,9 @@ public:
double
getTOALeft
(
double
phi
,
double
theta
);
double
getTOA
(
VAVec3
&
ear
,
VAVec3
&
source
);
double
getTOARight
(
double
phi
,
double
theta
);
};
...
...
src/Rendering/Binaural/RealTime/VABinauralRealTimeRenderer.cpp
View file @
bb7f2ad7
...
...
@@ -148,15 +148,15 @@ VABinauralRealTimeRenderer::ProcessStream(const ITAStreamInfo* streamInfo)
{
//BENCHMARK
//auto start = std::chrono::high_resolution_clock::now();
LARGE_INTEGER
frequency
;
// ticks per second
LARGE_INTEGER
t1
,
t2
;
// ticks
double
elapsedTime
;
//
LARGE_INTEGER frequency; // ticks per second
//
LARGE_INTEGER t1, t2; // ticks
//
double elapsedTime;
// get ticks per second
QueryPerformanceFrequency
(
&
frequency
);
//
QueryPerformanceFrequency(&frequency);
// start timer
QueryPerformanceCounter
(
&
t1
);
//
QueryPerformanceCounter(&t1);
/////
ITASampleFrame
*
output
;
...
...
@@ -169,7 +169,7 @@ VABinauralRealTimeRenderer::ProcessStream(const ITAStreamInfo* streamInfo)
const
CVAAudiostreamState
*
streamState
=
dynamic_cast
<
const
CVAAudiostreamState
*
>
(
streamInfo
);
double
time
=
streamState
->
dSysTime
;
updateTrajectories
(
time
);
//
updateTrajectories(time);
// -- create output for every listener
for
(
auto
const
&
clusteringIt
:
_clusterEngine
->
_clusterings
)
...
...
@@ -184,14 +184,14 @@ VABinauralRealTimeRenderer::ProcessStream(const ITAStreamInfo* streamInfo)
//BENCHMARK
// stop timer
QueryPerformanceCounter
(
&
t2
);
//
QueryPerformanceCounter(&t2);
// compute and print the elapsed time in millisec
elapsedTime
=
(
t2
.
QuadPart
-
t1
.
QuadPart
)
*
1000.0
/
frequency
.
QuadPart
;
//
elapsedTime = (t2.QuadPart - t1.QuadPart) * 1000.0 / frequency.QuadPart;
std
::
ofstream
outfile
(
"X:/Sciebo/master-thesis/data/benchmarks/Stream_128.txt"
,
std
::
fstream
::
app
);
outfile
<<
elapsedTime
<<
std
::
endl
;
outfile
.
close
();
//
std::ofstream outfile("X:/Sciebo/master-thesis/data/benchmarks/Stream_128.txt", std::fstream::app);
//
outfile << elapsedTime << std::endl;
//
outfile.close();
////
IncrementWritePointer
();
...
...
@@ -215,15 +215,15 @@ VABinauralRealTimeRenderer::UpdateScene(CVASceneState* newSceneState)
_newSceneState
->
Diff
(
_curSceneState
,
&
diff
);
//BENCHMARK
LARGE_INTEGER
frequency
;
// ticks per second
LARGE_INTEGER
t1
,
t2
;
// ticks
double
elapsedTime
;
//
LARGE_INTEGER frequency; // ticks per second
//
LARGE_INTEGER t1, t2; // ticks
//
double elapsedTime;
// get ticks per second
QueryPerformanceFrequency
(
&
frequency
);
//
QueryPerformanceFrequency(&frequency);
// start timer
QueryPerformanceCounter
(
&
t1
);
//
QueryPerformanceCounter(&t1);
// update listeners
updateListeners
(
&
diff
);
...
...
@@ -235,14 +235,14 @@ VABinauralRealTimeRenderer::UpdateScene(CVASceneState* newSceneState)
//BENCHMARK
// stop timer
QueryPerformanceCounter
(
&
t2
);
//
QueryPerformanceCounter(&t2);
// compute and print the elapsed time in millisec
elapsedTime
=
(
t2
.
QuadPart
-
t1
.
QuadPart
)
*
1000.0
/
frequency
.
QuadPart
;
//
elapsedTime = (t2.QuadPart - t1.QuadPart) * 1000.0 / frequency.QuadPart;
std
::
ofstream
outfile
(
"X:/Sciebo/master-thesis/data/benchmarks/UpdateScene_128.txt"
,
std
::
fstream
::
app
);
outfile
<<
elapsedTime
<<
std
::
endl
;
outfile
.
close
();
//
std::ofstream outfile("X:/Sciebo/master-thesis/data/benchmarks/UpdateScene_128.txt", std::fstream::app);
//
outfile << elapsedTime << std::endl;
//
outfile.close();
// Alte Szene freigeben (dereferenzieren)
if
(
_curSceneState
)
_curSceneState
->
RemoveReference
();
...
...
@@ -302,20 +302,18 @@ VABinauralRealTimeRenderer::updateSources( CVASceneStateDiff* diff )
{
source
->
motionModel
->
InputMotionKey
(
motionNew
);
// Dirty Hack
if
(
!
source
->
hasValidTrajectory
)
{
VAVec3
pos
=
motionNew
->
GetPosition
();
VAVec3
pos
=
motionNew
->
GetPosition
();
if
(
pos
!=
VAVec3
(
0
,
0
,
0
))
{
VAVec3
view
=
motionNew
->
GetView
();
VAVec3
up
=
motionNew
->
GetUp
();
source
->
predPos
=
pos
;
source
->
predView
=
view
;
source
->
predUp
=
up
;
source
->
hasValidTrajectory
=
true
;
}
if
(
pos
!=
VAVec3
(
0
,
0
,
0
))
{
VAVec3
view
=
motionNew
->
GetView
();
VAVec3
up
=
motionNew
->
GetUp
();
source
->
predPos
=
pos
;
source
->
predView
=
view
;
source
->
predUp
=
up
;
source
->
hasValidTrajectory
=
true
;
}
}
}
...
...
@@ -355,6 +353,20 @@ VABinauralRealTimeRenderer::updateListeners( CVASceneStateDiff* diff )
if
(
motionNew
&&
(
motionNew
!=
motionCur
))
{
listener
->
motionModel
->
InputMotionKey
(
motionNew
);
// Dirty Hack
VAVec3
pos
=
motionNew
->
GetPosition
();
if
(
pos
!=
VAVec3
(
0
,
0
,
0
))
{
VAVec3
view
=
motionNew
->
GetView
();
VAVec3
up
=
motionNew
->
GetUp
();
listener
->
predPos
=
pos
;
listener
->
predView
=
view
;
listener
->
predUp
=
up
;
listener
->
hasValidTrajectory
=
true
;
}
}
if
(
listenerNew
!=
nullptr
)
...
...
@@ -421,7 +433,7 @@ VABinauralRealTimeRenderer::createListener(int listenerID, const CVAReceiverStat
_listeners
.
insert
(
std
::
pair
<
int
,
VABinauralListener
*
>
(
listenerID
,
listener
));
// add listener to clustering
VABinauralClusterEngine
::
clusterConfig_t
config
=
{
/*numClusters=*/
12
8
};