Mercurial > hg > ishara
view 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 |
line wrap: on
line source
% unbuffer_nu - Non-uniform hop overlap and add % % unbuffer_nu :: % seq([[1,_]]) ~'sequence of overlapping frames', % seq(natural) ~'sequence of hop sizes' % -> seq([[1,_]]) ~'sequence of de-overlapped frames'. function Y=unbuffer_nu(X,hop) Y=zipaccum(@olap,{hop,X},[]); function [y,s1]=olap(hop,x,s) ls=length(s); lx=length(x); if lx>=hop if ls>=hop % NB: this will fail if ls>lx, but this shouldn't happen since ls<=lx-hop y=(x(1:hop)+s(1:hop))'; s1=[s(hop+1:ls)+x(hop+1:ls);x(ls+1:end)]; else y=[x(1:ls)+s;x(ls+1:hop)]'; s1=x(hop+1:end); end else if ls>=hop y=[s(1:lx)+x;s(lx+1:hop)]'; s1=s(hop+1:end); else y=zeros(1,hop); y(1:ls)=y(1:ls)+s'; y(1:lx)=y(1:lx)+x'; end end end end