Mercurial > hg > ishara
annotate sequences/@seq/unbuffer.m @ 38:9d24b616bb06
Added function algebra.
author | samer |
---|---|
date | Tue, 29 Jan 2013 15:59:01 +0000 |
parents | 79038cbcce00 |
children |
rev | line source |
---|---|
samer@3 | 1 % unbuffer - Opposite of buffer using overlap and add (for sequences) |
samer@3 | 2 % |
samer@3 | 3 % unbuffer :: |
samer@3 | 4 % seq([[N]]) ~'sequence of overlapping frames', |
samer@3 | 5 % M:natural ~'hop size' |
samer@3 | 6 % -> seq([[1,M]])~'sequence of de-overlapped frames'. |
samer@3 | 7 % |
samer@3 | 8 % NB. what about windowing function? |
samer@3 | 9 |
samer@3 | 10 function Y=unbuffer(X,hop) |
samer@25 | 11 N=max(size(X)); |
samer@25 | 12 ol=N-hop; |
samer@25 | 13 if ol<=hop |
samer@25 | 14 I=1:hop; J=1:ol; K=hop+1:N; |
samer@25 | 15 Y=mapaccum(@olap1,zeros(ol,1),X); |
samer@3 | 16 else |
samer@25 | 17 I=1:hop; J=hop+1:ol; K=ol+1:N; |
samer@25 | 18 Y=mapaccum(@olap3,zeros(ol,1),X); |
samer@3 | 19 end |
samer@25 | 20 % Y=zipaccum(@olap2,[],windowdata(repeat(hop)),X); |
samer@3 | 21 |
samer@3 | 22 function [y,s1]=olap1(x,s) |
samer@3 | 23 y=x(I)'; |
samer@3 | 24 y(J)=y(J)+s'; |
samer@3 | 25 s1=x(K); |
samer@3 | 26 end |
samer@3 | 27 |
samer@3 | 28 function [y,s1]=olap3(x,s) |
samer@3 | 29 y=(s(I)+x(I))'; |
samer@3 | 30 s1=[s(J)+x(J);x(K)]; |
samer@3 | 31 end |
samer@3 | 32 end |
samer@3 | 33 |