Mercurial > hg > ishara
annotate arrows/@asignal/construct.m @ 0:672052bd81f8
Initial partial import.
author | samer |
---|---|
date | Wed, 19 Dec 2012 22:38:28 +0000 |
parents | |
children |
rev | line source |
---|---|
samer@0 | 1 function u=construct(s,sizes_in) |
samer@0 | 2 src=construct(s.source); |
samer@0 | 3 ch=channels(s.source); |
samer@0 | 4 |
samer@0 | 5 span=s.block; |
samer@0 | 6 jump=s.hop; |
samer@0 | 7 olap=span-jump; |
samer@0 | 8 rdr=src.reader(jump); |
samer@0 | 9 |
samer@0 | 10 if olap>0 |
samer@0 | 11 buf=[zeros(ch,jump),sigreadn(src,olap)]; % preload with overlap |
samer@0 | 12 OL1=1:olap; |
samer@0 | 13 OL=(jump+1):span; |
samer@0 | 14 HOP=(olap+1):span; |
samer@0 | 15 process=@proc; |
samer@0 | 16 fprintf(' Using signal reader with overlap=%d.\n',olap); |
samer@0 | 17 else |
samer@0 | 18 process=@proc0; |
samer@0 | 19 fprintf(' Using zero-overlap signal reader.\n'); |
samer@0 | 20 end |
samer@0 | 21 |
samer@0 | 22 u=mkunit(s); |
samer@0 | 23 u.starting = src.start; |
samer@0 | 24 u.stopping = src.stop; |
samer@0 | 25 u.dispose = src.dispose; |
samer@0 | 26 u.process = process; |
samer@0 | 27 u.sizes_out = {[ch,span]}; |
samer@0 | 28 |
samer@0 | 29 function out=proc0, |
samer@0 | 30 [out,rem]=rdr(); |
samer@0 | 31 if rem>0, error('ARROW:EOF','End of stream'); end |
samer@0 | 32 end |
samer@0 | 33 |
samer@0 | 34 function out=proc, |
samer@0 | 35 buf(:,OL1)=buf(:,OL); % copy overlap from end of buf to head |
samer@0 | 36 [buf(:,HOP),rem]=rdr(); |
samer@0 | 37 if rem>0, error('ARROW:EOF','End of stream'); end |
samer@0 | 38 %out=[buf,chunk]; |
samer@0 | 39 out=buf; |
samer@0 | 40 end |
samer@0 | 41 |
samer@0 | 42 % old version |
samer@0 | 43 function out=proc1, |
samer@0 | 44 [chunk,rem]=rdr(); |
samer@0 | 45 if rem>0, error('ARROW:EOF','End of stream'); end |
samer@0 | 46 out=[buf,chunk]; |
samer@0 | 47 buf=out(:,OL); |
samer@0 | 48 end |
samer@0 | 49 end |