]> git.parisson.com Git - cnaq.git/commitdiff
plotdelay.m created
authormanu <manu@5fc3e0e6-29bc-4d03-b52b-c088cb822bde>
Wed, 28 Nov 2007 15:31:29 +0000 (15:31 +0000)
committermanu <manu@5fc3e0e6-29bc-4d03-b52b-c088cb822bde>
Wed, 28 Nov 2007 15:31:29 +0000 (15:31 +0000)
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
tests/plotdelay.m [new file with mode: 0644]

index 3e2617ef4bc8e0d919e86a0e1e870ff16e8464ca..c950e6410625fce068c613fdbad5465b4b014476 100644 (file)
@@ -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 (file)
index 0000000..8f078a8
--- /dev/null
@@ -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')
+
+