From: manu Date: Mon, 10 Dec 2007 14:36:43 +0000 (+0000) Subject: mv get_latency.m X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=cd1563d0f5435e894c5c2b1d1a343e9b2cd9a987;p=cnaq.git mv get_latency.m git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@131 5fc3e0e6-29bc-4d03-b52b-c088cb822bde --- diff --git a/tests/get_latency.m b/tests/get_latency.m deleted file mode 100644 index e5d893e..0000000 --- a/tests/get_latency.m +++ /dev/null @@ -1,32 +0,0 @@ -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); - diff --git a/tests/getdelay.asv b/tests/getdelay.asv deleted file mode 100644 index 3e2617e..0000000 --- a/tests/getdelay.asv +++ /dev/null @@ -1,33 +0,0 @@ -function [delai]=getdelay(n) -%this function allows measuring the lattency of the playrecord process for -%n generation/acquisition operations -if nargin < 1, n = 10; end - -%signal generation -f_min=100; -f_max=20000; -lt=5; -t=0:1/44100:lt; -sig=0.9*chirp(t,20,lt,20000,'logarithmic'); -len_sig = length(sig); - -%playrecord signal -for it = 1:n - pause(0.1) - inputbuffer = pa_wavplayrecord(sig',1,[44100],0,[1],[1],1,['asio']); - Co=xcorr(inputbuffer',sig'); - [Y(it),I(it)] = max(Co); - delai(it)=I(it)-len_sig; - -end - -mfv=mode(delai); -mfvt =num2str(mfv); -sprintf('%s','the most frequent delay is ', mfvt,' samples.') - -%Plot results -hist(delai) -title('delay distribution') -xlabel('delay') - - diff --git a/tests/getdelay.m b/tests/getdelay.m deleted file mode 100644 index a9f0cb2..0000000 --- a/tests/getdelay.m +++ /dev/null @@ -1,28 +0,0 @@ -function [mfv,ecart]=getdelay(n) -% this function allows measuring the lattency of the playrecord process for -% n generation/acquisition operations -% mfv: most found delay -% ecart: standard deviation on delay -if nargin < 1, n = 10; end - -%signal generation -f_min=100; -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',1,[44100],0,[1],[1],1,['asio']); - Co=xcorr(inputbuffer',sig'); - [Y(it),I(it)] = max(Co); - delai(it)=I(it)-len_sig; - -end - -mfv=mode(delai); -ecart=std(delai); - diff --git a/tools/get_latency.m b/tools/get_latency.m new file mode 100644 index 0000000..e5d893e --- /dev/null +++ b/tools/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); +