Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Institute of Technical Acoustics (ITA)
ITADataSources
Commits
5b5caddc
Commit
5b5caddc
authored
Jan 30, 2017
by
Anne Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use asio + bugfix matlab
parent
9fe17537
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
39 deletions
+103
-39
tests/NetAudio/ITANetAudioStreamingClientTest.cpp
tests/NetAudio/ITANetAudioStreamingClientTest.cpp
+96
-33
tests/NetAudio/NetAudioLog.m
tests/NetAudio/NetAudioLog.m
+7
-6
No files found.
tests/NetAudio/ITANetAudioStreamingClientTest.cpp
View file @
5b5caddc
...
...
@@ -8,18 +8,26 @@
#include <ITAFileDatasource.h>
#include <ITAStreamProbe.h>
#include <ITAStreamPatchbay.h>
#include <ITAAsioInterface.h>
#include <VistaBase\VistaTimeUtils.h>
using
namespace
std
;
//static string g_sServerName = "137.226.61.163";
static
string
g_sServerName
=
"137.226.61.
163
"
;
static
string
g_sServerName
=
"137.226.61.
85
"
;
static
int
g_iServerPort
=
12480
;
static
double
g_dSampleRate
=
44100
;
static
int
g_iBufferSize
=
1024
;
static
int
g_iChannels
=
10
0
;
static
int
g_iBufferSize
=
32
;
static
int
g_iChannels
=
10
;
int
main
(
int
,
char
**
)
{
std
::
cout
<<
"BufferSize: "
<<
endl
;
cin
>>
g_iBufferSize
;
cout
<<
"ChannelAnzahl: "
<<
endl
;
cin
>>
g_iChannels
;
CITANetAudioStream
oNetAudioStream
(
g_iChannels
,
g_dSampleRate
,
g_iBufferSize
,
1
*
g_iBufferSize
);
ITAStreamPatchbay
oPatchbay
(
g_dSampleRate
,
g_iBufferSize
);
...
...
@@ -33,43 +41,98 @@ int main( int , char** )
ITAStreamProbe
oProbe
(
oPatchbay
.
GetOutputDatasource
(
iOutputID
),
"ITANetAudioTest.stream.wav"
);
ITAPortaudioInterface
ITAPA
(
g_dSampleRate
,
g_iBufferSize
);
ITAPA
.
Initialize
();
ITAPA
.
SetPlaybackDatasource
(
&
oProbe
);
ITAPA
.
Open
();
ITAPA
.
Start
();
ITAsioInitializeLibrary
();
try
{
cout
<<
"Will now connect to '"
<<
g_sServerName
<<
"' on port "
<<
g_iServerPort
<<
endl
;
if
(
ITAsioInitializeDriver
(
"ASIO MADIface USB"
)
!=
ASE_OK
)
{
ITAsioFinalizeLibrary
();
fprintf
(
stderr
,
"Fehler: ITAsioInit schlug fehl!
\n
"
);
return
255
;
}
long
lBuffersize
,
lDummy
;
if
(
ITAsioGetBufferSize
(
&
lDummy
,
&
lDummy
,
&
lBuffersize
,
&
lDummy
)
!=
ASE_OK
)
{
ITAsioFinalizeLibrary
();
fprintf
(
stderr
,
"Fehler: ITAsioGetBufferSize schlug fehl!
\n
"
);
return
255
;
}
if
(
ITAsioSetSampleRate
((
ASIOSampleRate
)
g_dSampleRate
)
!=
ASE_OK
)
{
ITAsioFinalizeLibrary
();
fprintf
(
stderr
,
"Fehler: ITAsioSetSamplerate schlug fehl!
\n
"
);
return
255
;
}
long
lNumInputChannels
,
lNumOutputChannels
;
ASIOError
ae
;
if
((
ae
=
ITAsioGetChannels
(
&
lNumInputChannels
,
&
lNumOutputChannels
))
!=
ASE_OK
)
{
cerr
<<
"Error in ITAsioGetChannels, ASIO error "
<<
ae
<<
" encountered"
<<
endl
;
ITAsioFinalizeLibrary
();
return
255
;
}
if
((
ae
=
ITAsioCreateBuffers
(
0
,
2
,
lBuffersize
))
!=
ASE_OK
)
{
cerr
<<
"Error in ITAsioCreateBuffers, ASIO error "
<<
ae
<<
" encountered"
<<
endl
;
ITAsioFinalizeLibrary
();
return
255
;
}
cout
<<
"Waiting 3 seconds (net audio stream not connected and returning zeros)"
<<
endl
;
ITA
PA
.
Sleep
(
2.0
f
);
ITA
sioSetPlaybackDatasource
(
&
oProbe
);
cout
<<
"Will now connect to '"
<<
g_sServerName
<<
"' on port "
<<
g_iServerPort
<<
endl
;
try
{
if
(
!
oNetAudioStream
.
Connect
(
g_sServerName
,
g_iServerPort
)
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Could not connect to server"
);
if
(
ITAsioStart
()
!=
ASE_OK
)
{
ITAsioFinalizeLibrary
();
fprintf
(
stderr
,
"Fehler: ITAsioStart schlug fehl!
\n
"
);
return
255
;
}
if
(
!
oNetAudioStream
.
Connect
(
g_sServerName
,
g_iServerPort
))
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Could not connect to server"
);
VistaTimeUtils
::
Sleep
(
2
*
1000
);
printf
(
"Wiedergabe gestartet ...
\n
"
);
VistaTimeUtils
::
Sleep
(
20
*
1000
);
if
(
ITAsioStop
()
!=
ASE_OK
)
{
ITAsioFinalizeLibrary
();
fprintf
(
stderr
,
"Fehler: ITAsioStop schlug fehl!
\n
"
);
return
255
;
}
printf
(
"Wiedergabe beendet!
\n
"
);
if
(
ITAsioDisposeBuffers
()
!=
ASE_OK
)
{
ITAsioFinalizeLibrary
();
fprintf
(
stderr
,
"Fehler: ITAsioDisposeBuffers schlug fehl!
\n
"
);
return
255
;
}
if
(
ITAsioFinalizeDriver
()
!=
ASE_OK
)
{
ITAsioFinalizeLibrary
();
fprintf
(
stderr
,
"Fehler: ITAsioExit schlug fehl!
\n
"
);
return
255
;
}
}
catch
(
ITAException
e
)
{
cout
<<
"Connection failed."
<<
endl
;
catch
(
ITAException
e
)
{
ITAsioFinalizeLibrary
();
cerr
<<
e
<<
endl
;
return
255
;
}
cout
<<
"Connected."
<<
endl
;
// Playback
float
fSeconds
=
900.0
f
;
// 15min
cout
<<
"Playback started, waiting "
<<
fSeconds
<<
" seconds"
<<
endl
;
ITAPA
.
Sleep
(
fSeconds
);
// blocking
cout
<<
"Done."
<<
endl
;
cout
<<
"Will now disconnect from '"
<<
g_sServerName
<<
"' and port "
<<
g_iServerPort
<<
endl
;
cout
<<
"Closing in 3 seconds (net audio stream not connected and returning zeros)"
<<
endl
;
ITAPA
.
Sleep
(
1.0
f
);
ITAPA
.
Stop
();
ITAPA
.
Close
();
ITAPA
.
Finalize
();
ITAsioFinalizeLibrary
();
return
0
;
}
tests/NetAudio/NetAudioLog.m
View file @
5b5caddc
%% Einlesen der Logs
close
all
;
clear
all
;
NetAudioLogNet
=
readtable
(
'NetAudioLogNet.txt'
);
NetAudioLogStream
=
readtable
(
'NetAudioLogStream.txt'
);
NetAudioLogClient
=
readtable
(
'NetAudioLogClient.txt'
);
NetAudioLogBaseData
=
readtable
(
'NetAudioLogBaseData.txt'
);
NetAudioLogNet
=
readtable
(
'NetAudioLogNet.txt'
,
'FileType'
,
'text'
,
'Delimiter'
,
'\t'
);
NetAudioLogStream
=
readtable
(
'NetAudioLogStream.txt'
,
'FileType'
,
'text'
,
'Delimiter'
,
'\t'
)
NetAudioLogClient
=
readtable
(
'NetAudioLogClient.txt'
,
'FileType'
,
'text'
,
'Delimiter'
,
'\t'
);
NetAudioLogBaseData
=
readtable
(
'NetAudioLogBaseData.txt'
,
'FileType'
,
'text'
,
'Delimiter'
,
'\t'
);
% Save Base Data
Channel
=
NetAudioLogBaseData
.
Channel
(
1
);
...
...
@@ -54,7 +54,7 @@ sollLatenzVec = zeros(size(LatenzRunnning(:,1)));
sollLatenzVec
=
sollLatenzVec
+
sollLatenz
;
subplot
(
2
,
2
,
1
:
4
)
plot
(
LatenzRunnning
(:,
1
),
LatenzRunnning
(:,
2
))
plot
(
LatenzRunnning
(:,
1
),
LatenzRunnning
(:,
2
)
,
'b.'
)
hold
on
plot
(
LatenzRunnning
(:,
1
),
medianRunningVec
,
'r'
)
plot
(
LatenzRunnning
(:,
1
),
sollLatenzVec
,
'g'
)
...
...
@@ -63,9 +63,10 @@ plot( TimeOverrun, zeros(size(TimeOverrun)) + medianRunning,'r*')
AnzahlUnderruns
=
size
(
TimeUnderrun
);
AnzahlUnderruns
=
AnzahlUnderruns
(
1
);
AnzahlUnderruns
=
num2str
(
AnzahlUnderruns
);
RelativeUnderruns
=
100
*
size
(
TimeUnderrun
)
/
size
(
TimeState
);
Durchsatz
=
[
num2str
((
32
*
SampleRate
*
Channel
)/
1000
)
' kbit/s'
]
title
([
'Latenz pro Block ('
num2str
(
BufferSize
)
' Samples) bei '
num2str
(
Channel
)
' Kanlen'
])
legend
(
'Latenz'
,
[
'Latenz ('
num2str
(
medianRunning
)
' ms)'
],
[
'SollLatenz ('
num2str
(
sollLatenz
)
' ms)'
],
[
'Underruns (Anz. '
AnzahlUnderruns
')'
],
'Overruns'
)
legend
(
'Latenz'
,
[
'Latenz ('
num2str
(
medianRunning
)
' ms)'
],
[
'SollLatenz ('
num2str
(
sollLatenz
)
' ms)'
],
[
'Underruns (Anz. '
AnzahlUnderruns
'
- '
num2str
(
RelativeUnderruns
)
'%
)'
],
'Overruns'
)
xlabel
(
'Zeit in s'
)
ylabel
(
'Latenz in ms'
)
legend
(
'show'
)
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