NetAudioLog.m 3.4 KB
Newer Older
1 2 3 4
%% Load
ITANetAudioTest_Client = readtable( 'ITANetAudioTest_Client.log', 'FileType', 'text', 'Delimiter', '\t');
ITANetAudioTest_Server = readtable( 'ITANetAudioTest_Server.log', 'FileType', 'text', 'Delimiter', '\t');
ITANetAudioTest_Client_AudioStream = readtable( 'ITANetAudioTest_Client_AudioStream.log', 'FileType', 'text', 'Delimiter', '\t');
5 6
ITANetAudioTest_Client_NetworkStream = readtable( 'ITANetAudioTest_Client_NetworkStream.log', 'FileType', 'text', 'Delimiter', '\t');

7

8
%% Settings
9 10 11
B = 265;
TL = B * 1;
RB = B * 5;
12 13


14
%% Analyse
15 16 17
all_times = [ ITANetAudioTest_Client.WorldTimeStamp; ITANetAudioTest_Server.WorldTimeStamp; ITANetAudioTest_Client_AudioStream.WorldTimeStamp; ITANetAudioTest_Client_NetworkStream.WorldTimeStamp ];
TS = min( all_times );
TE = max( all_times );
18 19

AudioStreamingUnderrunIndices = find( ITANetAudioTest_Client_AudioStream.FreeSamples == RB );
20 21 22
AudioStreamingOverrunIndices = find( ITANetAudioTest_Client_AudioStream.FreeSamples == 0 );

ClientTransmittedBufferInfoIndices = find( strcmpi( ITANetAudioTest_Client.TransmittedRingBufferFreeSamples,'true' ));
23

24 25 26 27 28
ServerNetCommTiming = diff( ITANetAudioTest_Server.WorldTimeStamp );
ClientNetCommTiming = diff( ITANetAudioTest_Client.WorldTimeStamp );
ClientAudioStreamTiming = diff( ITANetAudioTest_Client_AudioStream.WorldTimeStamp );
ClientNetStreamTiming = diff( ITANetAudioTest_Client_NetworkStream.WorldTimeStamp );

29
%% Plot
30
figure
31
subplot( 2, 1, 1 )
32

33 34 35
% Client
plot( ITANetAudioTest_Client.WorldTimeStamp - TS, RB - ITANetAudioTest_Client.FreeSamples,  'LineWidth', 1 )
hold on
36
plot( ITANetAudioTest_Client.WorldTimeStamp( ClientTransmittedBufferInfoIndices ) - TS, RB - ITANetAudioTest_Client.FreeSamples( ClientTransmittedBufferInfoIndices ), '^' )
37
hold on
38
plot( ITANetAudioTest_Client_NetworkStream.WorldTimeStamp - TS, RB - ITANetAudioTest_Client_NetworkStream.FreeSamples )
39

40 41
% Estimated by server
plot( ITANetAudioTest_Server.WorldTimeStamp - TS, RB - ITANetAudioTest_Server.EstimatedFreeSamples, 'LineWidth', 1 )
Anne's avatar
Anne committed
42
hold on
43

44 45 46 47 48 49 50
% Target latency
plot( [ 0 TE - TS ], repmat( TL, 1, 2 ), 'LineWidth', 4  )
hold on

% Ringbuffer capacity
plot( [ 0 TE - TS ], repmat( RB, 1, 2 ), 'LineWidth', 4  )
hold on
51

52 53 54 55 56 57 58 59
% Underruns (might be empty)
plot( ITANetAudioTest_Client_AudioStream.WorldTimeStamp( AudioStreamingUnderrunIndices ) - TS, RB - ITANetAudioTest_Client_AudioStream.FreeSamples( AudioStreamingUnderrunIndices ) , 'ro' )
hold on

% Overruns (might be empty)
plot( ITANetAudioTest_Client_AudioStream.WorldTimeStamp( AudioStreamingOverrunIndices ) - TS, RB - ITANetAudioTest_Client_AudioStream.FreeSamples( AudioStreamingOverrunIndices ) , 'm*' )
hold on

60
legend( { 'RealBufferStatus', 'BufferInfoTransmit', 'NetworkStreamBufferStatus', 'EstimatedBufferStatus', 'TargetLatency', 'RingBufferCapacity', 'Underruns', 'Overruns' } )
61 62
ylabel( 'NumSamples' )
xlabel( 'Time' )
63
ylim( [ -B/10 RB + B/10 ] );
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
hold off

% Timing
subplot( 2, 1, 2 )
plot( ITANetAudioTest_Client.WorldTimeStamp( 2:end ) - TS, ClientNetCommTiming )
hold on
plot( ITANetAudioTest_Client_AudioStream.WorldTimeStamp( 2:end ) - TS, ClientAudioStreamTiming )
hold on
plot( ITANetAudioTest_Client_NetworkStream.WorldTimeStamp( 2:end ) - TS, ClientNetStreamTiming )
hold on
plot( ITANetAudioTest_Server.WorldTimeStamp( 2:end ) - TS, ServerNetCommTiming )
hold on

title( 'Clock Timing' )
legend( { 'ClientNet', 'ClientAudioStream', 'ClientNetStream', 'ServerNet' } )
ylabel( 'Process timing' )
xlabel( 'Streaming time' )

hold off