]> git.parisson.com Git - cnaq.git/commitdiff
Complete plotdelay by get_delay
authoryomguy <yomguy@5fc3e0e6-29bc-4d03-b52b-c088cb822bde>
Wed, 12 Dec 2007 19:51:37 +0000 (19:51 +0000)
committeryomguy <yomguy@5fc3e0e6-29bc-4d03-b52b-c088cb822bde>
Wed, 12 Dec 2007 19:51:37 +0000 (19:51 +0000)
git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@135 5fc3e0e6-29bc-4d03-b52b-c088cb822bde

tests/plotdelay.m
tools/get_latency.m

index 56248a9b043afbd4f57420d5037bd5d876239626..883fe9c15b448846d6e6ac7518b5294533a177e5 100644 (file)
@@ -1,25 +1,10 @@
-function [mfv,ecart]=plotdelay(n)
+function [delay, mfv,ecart]=plotdelay(device, n)
 %this function allows measuring the lattency of the playrecord process for
 %n generation/acquisition operations
-if nargin < 1, n = 10; end
 
+%if nargin < 1, n = 10; end
 %signal generation
-f_min=100;
-f_max=20000;
-lt=2;  
-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
+[delay, mfv, ecart] = get_latency(device, n)
 
 % % mfv=mode(delai);
 % % ecart=std(delai);
@@ -27,8 +12,8 @@ end
 % sprintf('%s','the most frequent delay is ', mfvt,' samples.')
 
 %Plot results
-hist(delai)
-title('delay distribution')
-xlabel('delay')
+hist(delay);
+title('delay distribution');
+xlabel('delay (number of samples)');
 
 
index e5d893e428b614b569ff790be9035c7c832c0df1..1ee1d6733c8cf68fc06c2190933de92f4f95df3e 100644 (file)
@@ -1,4 +1,4 @@
-function [mfv,ecart] = get_latency(device, n)
+function [delay, 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
@@ -7,8 +7,7 @@ function [mfv,ecart] = get_latency(device, n)
 % mfv: most found delay
 % ecart: standard deviation on delay
 
-    if nargin < 1, n = 10; end
-
+    %if nargin < 1, n = 10; end
     %signal generation
     f_min=20;
     f_max=20000;
@@ -23,10 +22,10 @@ function [mfv,ecart] = get_latency(device, n)
         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;
+        delay(it)=I(it)-len_sig;
 
     end
-
-    mfv=mode(delai);
-    ecart=std(delai);
+    
+    mfv = mode(delay)
+    ecart = std(delay)