annotate sequences/@seq/unbuffer.m @ 3:3f77126f7b5f
First major revision of sequence library, now using classdef form, STILL A BIT BROKEN!
author |
samer |
date |
Wed, 09 Jan 2013 22:22:21 +0000 |
parents |
|
children |
79038cbcce00 |
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@3
|
11 if isscalar(hop)
|
samer@3
|
12 N=max(size(X));
|
samer@3
|
13 ol=N-hop;
|
samer@3
|
14 if ol<=hop
|
samer@3
|
15 I=1:hop; J=1:ol; K=hop+1:N;
|
samer@3
|
16 Y=mapaccum(@olap1,X,zeros(ol,1));
|
samer@3
|
17 else
|
samer@3
|
18 I=1:hop; J=hop+1:ol; K=ol+1:N;
|
samer@3
|
19 Y=mapaccum(@olap3,X,zeros(ol,1));
|
samer@3
|
20 end
|
samer@3
|
21 else
|
samer@3
|
22 Y=zipaccum(@olap2,{windowdata(repeat(hop)),X},[]);
|
samer@3
|
23 end
|
samer@3
|
24
|
samer@3
|
25 function [y,s1]=olap1(x,s)
|
samer@3
|
26 y=x(I)';
|
samer@3
|
27 y(J)=y(J)+s';
|
samer@3
|
28 s1=x(K);
|
samer@3
|
29 end
|
samer@3
|
30
|
samer@3
|
31 function [y,s1]=olap3(x,s)
|
samer@3
|
32 y=(s(I)+x(I))';
|
samer@3
|
33 s1=[s(J)+x(J);x(K)];
|
samer@3
|
34 end
|
samer@3
|
35 end
|
samer@3
|
36
|