comparison signals/@siglzcat/construct.m @ 1:289445d368a7

import.
author samer
date Wed, 19 Dec 2012 22:46:05 +0000
parents
children
comparison
equal deleted inserted replaced
0:672052bd81f8 1:289445d368a7
1 function s=construct(sig)
2 fs=rate(sig.head);
3 ch=channels(sig.head);
4 sc=construct(sig.head);
5 sx=sig.tail;
6
7 s.start = @start;
8 s.stop = @stop;
9 s.dispose = @dispose;
10 s.reader = @reader;
11
12 function start, sc.start(); end
13 function stop, sc.stop(); end
14 function dispose, sc.dispose(); end
15 function r=reader(n)
16 rc=sc.reader(n);
17 r = @next;
18 function [x,rem]=next
19 [x,rem]=rc();
20 while rem>0 && ~isempty(sx) % current signal exhausted, try next
21 sc.dispose();
22 [sig2,sx]=sx();
23
24 fs=unify_rates(fs,rate(sig2));
25 if isinf(fs), error('sigcat:Signal sampling rate mismatch'); end
26 ch=unify_channels(ch,channels(sig2));
27 if isinf(ch), error('sigcat:Signal channels count mismatch'); end
28 sc=construct(sig2);
29
30 [x(:,end-rem+1:end),rem]=sigreadn(sc,rem);
31 rc=sc.reader(n);
32 end
33 end
34 end
35 end