From ee01b93d213d79180955868d56b469cf83f20f8d Mon Sep 17 00:00:00 2001 From: manu Date: Wed, 28 Nov 2007 15:31:29 +0000 Subject: [PATCH] plotdelay.m created add standard deviation on getdelay.m git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@124 5fc3e0e6-29bc-4d03-b52b-c088cb822bde --- tests/getdelay.m | 17 ++++++----------- tests/plotdelay.m | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 tests/plotdelay.m diff --git a/tests/getdelay.m b/tests/getdelay.m index 3e2617e..c950e64 100644 --- a/tests/getdelay.m +++ b/tests/getdelay.m @@ -1,6 +1,8 @@ -function [delai]=getdelay(n) -%this function allows measuring the lattency of the playrecord process for -%n generation/acquisition operations +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 @@ -22,12 +24,5 @@ for it = 1:n 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') - +ecart=std(delai); diff --git a/tests/plotdelay.m b/tests/plotdelay.m new file mode 100644 index 0000000..8f078a8 --- /dev/null +++ b/tests/plotdelay.m @@ -0,0 +1,34 @@ +function [mfv,ecart]=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); +ecart=std(delai); +mfvt =num2str(mfv); +sprintf('%s','the most frequent delay is ', mfvt,' samples.') + +Plot results +hist(delai) +title('delay distribution') +xlabel('delay') + + -- 2.39.5