Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
VACore
Commits
2ab5d6f6
Commit
2ab5d6f6
authored
Sep 03, 2018
by
Lucas Moesch
Browse files
WIP
parent
80371cda
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralCluster.cpp
View file @
2ab5d6f6
...
...
@@ -18,11 +18,13 @@ VABinauralCluster::~VABinauralCluster()
}
void
VABinauralCluster
::
init
(
VABinauralSoundSource
*
source
)
VABinauralCluster
::
init
(
int
sourceID
,
VABinauralSoundSource
*
source
)
{
_clusterSourcePos
=
_clusterSourcePos
+
source
->
predPos
;
maxError
=
getDistError
(
source
);
_sources
.
insert
(
std
::
pair
<
int
,
VABinauralSoundSource
*>
(
sourceID
,
source
));
++
_numSources
;
}
...
...
@@ -35,13 +37,15 @@ VABinauralCluster::getDistError(VABinauralSoundSource* source)
}
void
VABinauralCluster
::
addSource
(
VABinauralSoundSource
*
source
)
VABinauralCluster
::
addSource
(
int
sourceID
,
VABinauralSoundSource
*
source
)
{
double
err
=
getDistError
(
source
);
_clusterSourcePos
=
(
source
->
predPos
+
_clusterSourcePos
*
_numSources
)
/
(
_numSources
+
1
);
maxError
=
std
::
max
(
err
,
maxError
);
_sources
.
insert
(
std
::
pair
<
int
,
VABinauralSoundSource
*>
(
sourceID
,
source
));
++
_numSources
;
}
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralCluster.h
View file @
2ab5d6f6
...
...
@@ -20,13 +20,13 @@ public:
~
VABinauralCluster
();
void
init
(
VABinauralSoundSource
*
source
);
init
(
int
sourceID
,
VABinauralSoundSource
*
source
);
double
getDistError
(
VABinauralSoundSource
*
source
);
void
addSource
(
VABinauralSoundSource
*
source
);
addSource
(
int
sourceID
,
VABinauralSoundSource
*
source
);
void
addSource
(
VABinauralSoundSource
*
source
,
double
error
);
...
...
@@ -39,6 +39,7 @@ public:
private:
int
_numSources
;
std
::
map
<
int
,
VABinauralSoundSource
*
>
_sources
;
VAVec3
_clusterSourcePos
;
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClustering.cpp
View file @
2ab5d6f6
...
...
@@ -35,10 +35,17 @@ VABinauralClustering::init(int listenerID, VABinauralListener* listener, int num
_threshold
=
cos
(
180.
/
numClusters
)
*
cos
(
180.
/
numClusters
);
}
VABinauralClustering
::
binauralOutput_t
VABinauralClustering
::
getOutput
()
{
_curState
.
reset
(
_nextState
.
release
());
}
void
VABinauralClustering
::
update
()
{
VABinauralClusteringState
*
state
=
new
VABinauralClusteringState
(
*
_clustering
);
VABinauralClusteringState
*
state
=
new
VABinauralClusteringState
(
*
_curState
);
//VABinauralClusteringState* del = _newState;
// update unassigned sources
std
::
map
<
int
,
VABinauralSoundSource
*
>::
iterator
it
;
...
...
@@ -56,6 +63,8 @@ VABinauralClustering::update()
_unassignedSources
.
clear
();
_nextState
.
reset
(
state
);
// TODO: update fixed clustertrajectories
}
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClustering.h
View file @
2ab5d6f6
...
...
@@ -16,6 +16,11 @@
class
VABinauralClustering
:
public
CVAPoolObject
{
public:
struct
binauralOutput_t
{
ITASampleBuffer
outputChL
;
ITASampleBuffer
outputChR
;
};
~
VABinauralClustering
();
VABinauralClustering
();
...
...
@@ -23,6 +28,9 @@ public:
void
init
(
int
listenerID
,
VABinauralListener
*
listener
,
int
numClusters
);
binauralOutput_t
getOutput
();
void
update
();
...
...
@@ -35,7 +43,9 @@ private:
int
_numClusters
;
double
_threshold
;
VABinauralClusteringState
*
_clustering
;
std
::
unique_ptr
<
VABinauralClusteringState
>
_curState
;
std
::
unique_ptr
<
VABinauralClusteringState
>
_nextState
;
VABinauralListener
*
_listener
;
IVAObjectPool
*
_clusterPool
;
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClusteringState.cpp
View file @
2ab5d6f6
...
...
@@ -62,7 +62,7 @@ VABinauralClusteringState::addSource(int sourceID, VABinauralSoundSource* source
if
((
minerr
>
threshold
)
&&
(
numFreeClusters
>
0
))
{
std
::
pair
<
int
,
VABinauralCluster
*>
p
;
p
=
createCluster
(
source
);
p
=
createCluster
(
sourceID
,
source
);
nearestClusterID
=
p
.
first
;
nearestCluster
=
p
.
second
;
...
...
@@ -73,12 +73,12 @@ VABinauralClusteringState::addSource(int sourceID, VABinauralSoundSource* source
}
std
::
pair
<
int
,
VABinauralCluster
*>
VABinauralClusteringState
::
createCluster
(
VABinauralSoundSource
*
source
)
VABinauralClusteringState
::
createCluster
(
int
sourceID
,
VABinauralSoundSource
*
source
)
{
int
clusterID
=
freeClusterIDs
.
back
();
VABinauralCluster
*
cluster
=
dynamic_cast
<
VABinauralCluster
*
>
(
_clusterPool
->
RequestObject
());
// Reference = 1
cluster
->
init
(
source
);
cluster
->
init
(
sourceID
,
source
);
clusters
.
insert
(
std
::
pair
<
int
,
VABinauralCluster
*
>
(
clusterID
,
cluster
));
freeClusterIDs
.
pop
();
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClusteringState.h
View file @
2ab5d6f6
...
...
@@ -30,7 +30,7 @@ public:
addSource
(
int
sourceID
,
VABinauralSoundSource
*
source
,
double
threshold
,
int
numBlockedClusters
);
std
::
pair
<
int
,
VABinauralCluster
*>
createCluster
(
VABinauralSoundSource
*
source
);
createCluster
(
int
sourceID
,
VABinauralSoundSource
*
source
);
double
getMaxError
();
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralSoundSource/VABinauralSoundSource.cpp
View file @
2ab5d6f6
#include "VABinauralSoundSource.h"
VABinauralSoundSource
::
VABinauralSoundSource
(
const
config_t
&
conf
)
:
_conf
(
conf
)
{}
VABinauralSoundSource
::
VABinauralSoundSource
(
const
config_t
&
conf
)
:
_conf
(
conf
)
{
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
);
}
VABinauralSoundSource
::~
VABinauralSoundSource
()
...
...
@@ -13,15 +16,15 @@ VABinauralSoundSource::~VABinauralSoundSource()
void
VABinauralSoundSource
::
PreRequest
()
{
CVABasicMotionModel
::
Config
listener
MotionConf
;
CVABasicMotionModel
::
Config
source
MotionConf
;
listener
MotionConf
.
bLogEstimatedOutputEnabled
=
_conf
.
motionModelLogEstimated
;
listener
MotionConf
.
bLogInputEnabled
=
_conf
.
motionModelLogInput
;
listener
MotionConf
.
dWindowDelay
=
_conf
.
motionModelWindowDelay
;
listener
MotionConf
.
dWindowSize
=
_conf
.
motionModelWindowSize
;
listener
MotionConf
.
iNumHistoryKeys
=
_conf
.
motionModelNumHistoryKeys
;
source
MotionConf
.
bLogEstimatedOutputEnabled
=
_conf
.
motionModelLogEstimated
;
source
MotionConf
.
bLogInputEnabled
=
_conf
.
motionModelLogInput
;
source
MotionConf
.
dWindowDelay
=
_conf
.
motionModelWindowDelay
;
source
MotionConf
.
dWindowSize
=
_conf
.
motionModelWindowSize
;
source
MotionConf
.
iNumHistoryKeys
=
_conf
.
motionModelNumHistoryKeys
;
motionModel
=
new
CVASharedMotionModel
(
new
CVABasicMotionModel
(
listener
MotionConf
),
true
);
motionModel
=
new
CVASharedMotionModel
(
new
CVABasicMotionModel
(
source
MotionConf
),
true
);
data
=
nullptr
;
}
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralSoundSource/VABinauralSoundSource.h
View file @
2ab5d6f6
...
...
@@ -9,6 +9,9 @@
#include "../../../../../Motion/VASharedMotionModel.h"
#include "../../../../../Scene/VAScene.h"
// ITA includes
#include <ITAVariableDelayLine.h>
class
VABinauralSoundSource
:
public
CVAPoolObject
{
public:
...
...
@@ -20,10 +23,15 @@ public:
double
motionModelWindowDelay
;
int
motionModelNumHistoryKeys
;
double
sampleRate
;
int
blockLength
;
};
CVASoundSourceDesc
*
data
;
CVASharedMotionModel
*
motionModel
;
CITAVariableDelayLine
*
vdlChL
;
CITAVariableDelayLine
*
vdlChR
;
VAVec3
predPos
;
VAVec3
prefView
;
...
...
src/Rendering/Binaural/RealTime/VABinauralRealTimeRenderer.cpp
View file @
2ab5d6f6
...
...
@@ -11,6 +11,8 @@
// ITA includes
#include <ITAException.h>
#include <ITAFastMath.h>
#include <ITAStreamInfo.h>
#include <ITAVariableDelayLine.h>
// Utils
...
...
@@ -92,12 +94,28 @@ VABinauralRealTimeRenderer::init( const CVAStruct& oArgs )
if
((
_defaultSourceConf
.
motionModelWindowSize
<=
0
)
||
(
_defaultSourceConf
.
motionModelWindowDelay
<
0
))
VA_EXCEPT2
(
INVALID_PARAMETER
,
"Basic motion model window parameters parse error (zero or negative?)"
);
_defaultSourceConf
.
blockLength
=
GetBlocklength
();
_defaultSourceConf
.
sampleRate
=
GetSampleRate
();
}
void
VABinauralRealTimeRenderer
::
processStream
(
const
ITAStreamInfo
*
streamInfo
)
{
float
*
outputChL
=
GetWritePointer
(
0
);
float
*
outputChR
=
GetWritePointer
(
1
);
fm_zero
(
outputChL
,
GetBlocklength
());
fm_zero
(
outputChR
,
GetBlocklength
());
const
CVAAudiostreamState
*
streamState
=
dynamic_cast
<
const
CVAAudiostreamState
*
>
(
streamInfo
);
double
dListenerTime
=
streamState
->
dSysTime
;
IncrementWritePointer
();
return
;
}
void
...
...
@@ -122,12 +140,12 @@ VABinauralRealTimeRenderer::updateScene(CVASceneState* newSceneState)
updateSources
(
&
diff
);
}
/*
ITADatasource
*
VABinauralRealTimeRenderer
::
GetOutputDatasource
()
{
return
this
;
}
*/
void
VABinauralRealTimeRenderer
::
updateSources
(
CVASceneStateDiff
*
diff
)
...
...
src/Rendering/Binaural/RealTime/VABinauralRealTimeRenderer.h
View file @
2ab5d6f6
...
...
@@ -13,7 +13,7 @@
#include "./Utils/BinauralSoundSource/VABinauralSoundSource.h"
#include "./Utils/BinauralListener/VABinauralListener.h"
class
VABinauralRealTimeRenderer
:
public
IVAAudioRenderer
,
public
CVAObject
class
VABinauralRealTimeRenderer
:
public
IVAAudioRenderer
,
public
CVAObject
,
public
ITADatasourceRealization
{
public:
VABinauralRealTimeRenderer
(
const
CVAAudioRendererInitParams
&
);
...
...
@@ -52,6 +52,8 @@ private:
VABinauralListener
::
config_t
_defaultListenerConf
;
//!< Default listener config for factory object creation
VABinauralSoundSource
::
config_t
_defaultSourceConf
;
CVABFFUpdateMessage
*
_updateMessage
;
int
_defaultVDLSwitchingAlgorithm
;
int
_hrirFilterLength
;
double
_additionalStaticDelaySeconds
;
...
...
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