Mercurial > hg > ishara
comparison dsp/synth/unbuffer_nu.m @ 34:c75bb62b90a9
Imported audio synthesis tools.
author | samer |
---|---|
date | Sun, 20 Jan 2013 19:05:05 +0000 |
parents | |
children | 9e7be347b3a0 |
comparison
equal
deleted
inserted
replaced
33:5b7d90b6393a | 34:c75bb62b90a9 |
---|---|
1 % unbuffer_nu - Non-uniform hop overlap and add | |
2 % | |
3 % unbuffer_nu :: | |
4 % seq([[1,_]]) ~'sequence of overlapping frames', | |
5 % seq(natural) ~'sequence of hop sizes' | |
6 % -> seq([[1,_]]) ~'sequence of de-overlapped frames'. | |
7 | |
8 function Y=unbuffer_nu(X,hop) | |
9 Y=zipaccum(@olap,{hop,X},[]); | |
10 | |
11 function [y,s1]=olap(hop,x,s) | |
12 ls=length(s); | |
13 lx=length(x); | |
14 if lx>=hop | |
15 if ls>=hop | |
16 % NB: this will fail if ls>lx, but this shouldn't happen since ls<=lx-hop | |
17 y=(x(1:hop)+s(1:hop))'; | |
18 s1=[s(hop+1:ls)+x(hop+1:ls);x(ls+1:end)]; | |
19 else | |
20 y=[x(1:ls)+s;x(ls+1:hop)]'; | |
21 s1=x(hop+1:end); | |
22 end | |
23 else | |
24 if ls>=hop | |
25 y=[s(1:lx)+x;s(lx+1:hop)]'; | |
26 s1=s(hop+1:end); | |
27 else | |
28 y=zeros(1,hop); | |
29 y(1:ls)=y(1:ls)+s'; | |
30 y(1:lx)=y(1:lx)+x'; | |
31 end | |
32 end | |
33 end | |
34 end | |
35 |