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
8b5ab993
Commit
8b5ab993
authored
Nov 13, 2018
by
lmoesch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
c43e3fe1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
29 deletions
+156
-29
benchmarks/core/VACoreSourceManagementBenchmark.cpp
benchmarks/core/VACoreSourceManagementBenchmark.cpp
+73
-19
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralCluster.cpp
...ealTime/Utils/BinauralClusterEngine/VABinauralCluster.cpp
+27
-8
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClustering.cpp
...Time/Utils/BinauralClusterEngine/VABinauralClustering.cpp
+1
-1
src/Rendering/Binaural/RealTime/VABinauralRealTimeRenderer.cpp
...endering/Binaural/RealTime/VABinauralRealTimeRenderer.cpp
+55
-1
No files found.
benchmarks/core/VACoreSourceManagementBenchmark.cpp
View file @
8b5ab993
#define _USE_MATH_DEFINES
#include <VA.h>
#include <VACoreFactory.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <VistaBase/VistaTimeUtils.h>
#include <ITAStopWatch.h>
#include <stdlib.h>
using
namespace
std
;
CVAStruct
GetCoreConfig
()
...
...
@@ -14,16 +21,19 @@ CVAStruct GetCoreConfig()
CVAStruct
oConfig
;
CVAStruct
oSectionDebug
;
oSectionDebug
[
"loglevel"
]
=
5
;
oSectionDebug
[
"loglevel"
]
=
0
;
oConfig
[
"debug"
]
=
oSectionDebug
;
CVAStruct
oSectionDriver
;
oSectionDriver
[
"driver"
]
=
"Portaudio"
;
oSectionDriver
[
"driver"
]
=
"Virtual"
;
oSectionDriver
[
"buffersize"
]
=
64
;
oSectionDriver
[
"outputchannels"
]
=
2
;
oConfig
[
"audio driver"
]
=
oSectionDriver
;
CVAStruct
oDevice1
;
oDevice1
[
"type"
]
=
"
HP
"
;
oDevice1
[
"type"
]
=
"
Trigger
"
;
oDevice1
[
"channels"
]
=
"1,2"
;
oConfig
[
"OutputDevice:MyHP"
]
=
oDevice1
;
CVAStruct
oOutput1
;
...
...
@@ -44,35 +54,79 @@ CVAStruct GetCoreConfig()
return
oConfig
;
}
CVAStruct
time
;
CVAStruct
trigger
;
int
main
(
int
,
char
**
)
{
IVAInterface
*
pCore
=
NULL
;
try
{
pCore
=
VACore
::
CreateCoreInstance
(
GetCoreConfig
());
pCore
->
Initialize
();
int
iterations
=
10
;
int
_parallelSources
=
1000
;
pCore
=
VACore
::
CreateCoreInstance
(
GetCoreConfig
());
pCore
->
Initialize
();
double
clock
=
0
;
double
timestep
=
64
/
44100.
;
//auto d = pCore->CreateDire
int
receiverID
=
pCore
->
CreateSoundReceiver
(
"ITAListener"
);
int
directivityID
=
pCore
->
CreateDirectivityFromFile
(
"C:/dev/VA/VACore/data/ITA_Artificial_Head_5x5_44kHz_128.v17.ir.daff"
,
"HRTF"
);
pCore
->
SetSoundReceiverDirectivity
(
receiverID
,
directivityID
);
pCore
->
LockUpdate
();
std
::
vector
<
int
>
viSourceIDs
(
_parallelSources
);
for
(
int
k
=
0
;
k
<
_parallelSources
;
k
++
)
{
int
iIterations
=
100
;
int
iMaxNumParallelSources
=
200
;
for
(
int
i
=
1
;
i
<
iMaxNumParallelSources
;
i
++
)
viSourceIDs
[
k
]
=
pCore
->
CreateSoundSource
(
"BenchmarkSoundSource"
);
}
pCore
->
UnlockUpdate
();
for
(
int
j
=
0
;
j
<
iterations
;
j
++
)
{
ITAStopWatch
swIterations
;
for
(
int
j
=
0
;
j
<
iIterations
;
j
++
)
pCore
->
LockUpdate
()
;
for
(
int
k
=
0
;
k
<
(
_parallelSources
);
k
++
)
{
swIterations
.
start
();
std
::
vector
<
int
>
viSourceIDs
(
i
)
;
f
or
(
int
k
=
0
;
k
<
i
;
k
++
)
viSourceIDs
[
k
]
=
pCore
->
CreateSoundSource
(
"BenchmarkSoundSource"
);
//pCore->SetSoundSourcePosition(k, )
f
or
(
int
k
=
0
;
k
<
i
;
k
++
)
pCore
->
DeleteSoundSource
(
viSourceIDs
[
k
]
)
;
swIterations
.
stop
(
);
float
azimuth
=
((
rand
()
%
3600
)
/
1800.0
)
*
M_PI
;
f
loat
elevation
=
((
rand
()
%
1800
)
/
1800.0
)
*
M_PI
;
float
x
=
sin
(
elevation
)
*
cos
(
azimuth
)
*
5
;
f
loat
y
=
cos
(
elevation
)
*
5
;
float
z
=
sin
(
azimuth
)
*
sin
(
elevation
)
*
5
;
pCore
->
SetSoundSourcePosition
(
viSourceIDs
[
k
],
VAVec3
(
x
,
y
,
z
)
);
}
cout
<<
"Statistics for "
<<
i
<<
" parallel source: "
<<
swIterations
.
ToString
()
<<
endl
;
pCore
->
UnlockUpdate
();
_sleep
(
100
);
}
string
audio
=
pCore
->
CreateSignalSourceBufferFromFile
(
"X:/Sciebo/2018 MA Lucas Msch Auralization/input_files/Schluesselbund.wav"
);
pCore
->
SetSignalSourceBufferPlaybackAction
(
audio
,
2
);
pCore
->
SetSignalSourceBufferLooping
(
audio
,
true
);
for
(
int
k
=
0
;
k
<
_parallelSources
;
k
++
)
{
pCore
->
SetSoundSourceSignalSource
(
viSourceIDs
[
k
],
audio
);
}
_sleep
(
2000
);
for
(
int
j
=
0
;
j
<
iterations
;
j
++
)
{
clock
+=
timestep
;
time
[
"time"
]
=
clock
;
pCore
->
CallModule
(
"manualclock"
,
time
);
trigger
[
"trigger"
]
=
true
;
pCore
->
CallModule
(
"virtualaudiodevice"
,
trigger
);
}
delete
pCore
;
}
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralCluster.cpp
View file @
8b5ab993
...
...
@@ -60,9 +60,11 @@ VABinauralCluster::init(int sourceID, VABinauralSoundSource* source, VABinauralL
if
(
_output
->
length
()
!=
outputLength
)
_output
->
init
(
2
,
outputLength
,
true
);
_tmpChL
.
Init
(
listener
->
output
->
GetLength
(),
true
);
_tmpChR
.
Init
(
listener
->
output
->
GetLength
(),
true
);
if
(
_tmpChL
.
length
()
!=
outputLength
){
_tmpChL
.
Init
(
outputLength
,
true
);
_tmpChR
.
Init
(
outputLength
,
true
);
}
maxError
=
getDistError
(
source
);
_sources
.
insert
(
std
::
pair
<
int
,
VABinauralSoundSource
*>
(
sourceID
,
source
));
...
...
@@ -180,17 +182,26 @@ double
VABinauralCluster
::
getDistError
(
VABinauralSoundSource
*
source
)
{
VAVec3
sourceToListenerPos
=
source
->
predPos
-
_listenerPos
;
double
dotp
=
_clusterSourceToListenerPos
.
Dot
(
sourceToListenerPos
);
VAVec3
dist
;
sourceToListenerPos
.
Norm
();
dist
=
sourceToListenerPos
-
_clusterSourcePos
;
return
(
dotp
*
dotp
)
/
(
_clusterSourcePos
.
Dot
(
_clusterSourcePos
)
*
sourceToListenerPos
.
Dot
(
sourceToListenerPos
)
);
return
dist
.
Dot
(
dist
);
}
void
VABinauralCluster
::
addSource
(
int
sourceID
,
VABinauralSoundSource
*
source
)
{
VAVec3
sourceToListenerPos
=
source
->
predPos
-
_listenerPos
;
double
err
=
getDistError
(
source
);
_clusterSourcePos
=
(
source
->
predPos
+
_clusterSourcePos
*
numSources
)
/
(
numSources
+
1
);
sourceToListenerPos
.
Norm
();
_clusterSourcePos
=
_clusterSourcePos
+
(
sourceToListenerPos
-
_clusterSourcePos
)
/
(
numSources
+
1
);
_clusterSourcePos
.
Norm
();
_clusterSourceToListenerPos
=
_clusterSourcePos
-
_listenerPos
;
maxError
=
std
::
max
(
err
,
maxError
);
...
...
@@ -206,12 +217,20 @@ VABinauralCluster::addSource(int sourceID, VABinauralSoundSource* source)
void
VABinauralCluster
::
addSource
(
int
sourceID
,
VABinauralSoundSource
*
source
,
double
error
)
{
_clusterSourcePos
=
(
source
->
predPos
+
_clusterSourcePos
*
numSources
)
/
(
numSources
+
1
);
VAVec3
sourceToListenerPos
=
source
->
predPos
-
_listenerPos
;
double
err
=
getDistError
(
source
);
sourceToListenerPos
.
Norm
();
_clusterSourcePos
=
_clusterSourcePos
+
(
sourceToListenerPos
-
_clusterSourcePos
)
/
(
numSources
+
1
);
_clusterSourcePos
.
Norm
();
_clusterSourceToListenerPos
=
_clusterSourcePos
-
_listenerPos
;
maxError
=
std
::
max
(
err
or
,
maxError
);
maxError
=
std
::
max
(
err
,
maxError
);
_sources
.
insert
(
std
::
pair
<
int
,
VABinauralSoundSource
*>
(
sourceID
,
source
));
// --
source
->
AddReference
();
...
...
src/Rendering/Binaural/RealTime/Utils/BinauralClusterEngine/VABinauralClustering.cpp
View file @
8b5ab993
...
...
@@ -41,7 +41,7 @@ VABinauralClustering::init(int listenerID, VABinauralListener* listener, int num
_listenerID
=
listenerID
;
_listener
=
listener
;
_numClusters
=
numClusters
;
_threshold
=
cos
(
180.
/
numClusters
)
*
cos
(
180.
/
numClusters
)
;
_threshold
=
1.
/
numClusters
;
_output
=
new
ITASampleFrame
(
2
,
listener
->
output
->
GetLength
(),
true
);
...
...
src/Rendering/Binaural/RealTime/VABinauralRealTimeRenderer.cpp
View file @
8b5ab993
#include "VABinauralRealTimeRenderer.h"
#include <iostream>
#include <fstream>
#include <ctime>
#include <chrono>
#include <time.h>
// VA Includes
#include <VA.h>
#include <VAObjectPool.h>
...
...
@@ -140,6 +146,19 @@ void VABinauralRealTimeRenderer::UpdateGlobalAuralizationMode(int iGlobalAuraliz
void
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
;
// get ticks per second
QueryPerformanceFrequency
(
&
frequency
);
// start timer
QueryPerformanceCounter
(
&
t1
);
/////
ITASampleFrame
*
output
;
float
*
outputChL
=
GetWritePointer
(
0
);
float
*
outputChR
=
GetWritePointer
(
1
);
...
...
@@ -163,6 +182,17 @@ VABinauralRealTimeRenderer::ProcessStream(const ITAStreamInfo* streamInfo)
fm_copy
(
outputChR
,
(
*
output
)[
1
].
data
(),
m_uiBlocklength
);
}
//BENCHMARK
// stop timer
QueryPerformanceCounter
(
&
t2
);
// compute and print the elapsed time in millisec
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
();
////
IncrementWritePointer
();
return
;
...
...
@@ -176,6 +206,7 @@ VABinauralRealTimeRenderer::UpdateScene(CVASceneState* newSceneState)
_newSceneState
=
newSceneState
;
if
(
_newSceneState
==
_curSceneState
)
return
;
// get reference to new scene
_newSceneState
->
AddReference
();
...
...
@@ -183,6 +214,17 @@ VABinauralRealTimeRenderer::UpdateScene(CVASceneState* newSceneState)
CVASceneStateDiff
diff
;
_newSceneState
->
Diff
(
_curSceneState
,
&
diff
);
//BENCHMARK
LARGE_INTEGER
frequency
;
// ticks per second
LARGE_INTEGER
t1
,
t2
;
// ticks
double
elapsedTime
;
// get ticks per second
QueryPerformanceFrequency
(
&
frequency
);
// start timer
QueryPerformanceCounter
(
&
t1
);
// update listeners
updateListeners
(
&
diff
);
...
...
@@ -191,11 +233,23 @@ VABinauralRealTimeRenderer::UpdateScene(CVASceneState* newSceneState)
_clusterEngine
->
update
();
//BENCHMARK
// stop timer
QueryPerformanceCounter
(
&
t2
);
// compute and print the elapsed time in millisec
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
();
// Alte Szene freigeben (dereferenzieren)
if
(
_curSceneState
)
_curSceneState
->
RemoveReference
();
_curSceneState
=
_newSceneState
;
_newSceneState
=
nullptr
;
}
/*
...
...
@@ -367,7 +421,7 @@ VABinauralRealTimeRenderer::createListener(int listenerID, const CVAReceiverStat
_listeners
.
insert
(
std
::
pair
<
int
,
VABinauralListener
*
>
(
listenerID
,
listener
));
// add listener to clustering
VABinauralClusterEngine
::
clusterConfig_t
config
=
{
/*numClusters=*/
9
};
VABinauralClusterEngine
::
clusterConfig_t
config
=
{
/*numClusters=*/
128
};
_clusterEngine
->
addListener
(
listenerID
,
listener
,
config
);
}
...
...
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