From 0ea5ec247938d7f93500097636ec14125d59726f Mon Sep 17 00:00:00 2001 From: manu Date: Mon, 10 Dec 2007 14:35:39 +0000 Subject: [PATCH] Rename and fix getdelay.m to get_latency.m git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@130 5fc3e0e6-29bc-4d03-b52b-c088cb822bde --- tests/get_latency.m | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/get_latency.m diff --git a/tests/get_latency.m b/tests/get_latency.m new file mode 100644 index 0000000..e5d893e --- /dev/null +++ b/tests/get_latency.m @@ -0,0 +1,32 @@ +function [mfv,ecart] = get_latency(device, n) +% this function allows measuring the latency of the playrecord process +% where : +% 'device' is the integer number of the audio card address from the ASIO +% driver point of view (0 or 1, 2 etc...) +% 'n' is the number of generation/acquisition operations +% mfv: most found delay +% ecart: standard deviation on delay + + if nargin < 1, n = 10; end + + %signal generation + f_min=20; + f_max=20000; + lt=5; + t=0:1/44100:lt; + sig=0.9*chirp(t,f_min,lt,f_max,'logarithmic'); + len_sig = length(sig); + + %playrecord signal + for it = 1:n + pause(0.1); + inputbuffer = pa_wavplayrecord(sig',device,[44100],0,[1],[1],device,['asio']); + Co=xcorr(inputbuffer',sig'); + [Y(it),I(it)] = max(Co); + delai(it)=I(it)-len_sig; + + end + + mfv=mode(delai); + ecart=std(delai); + -- 2.39.5