view dsp/unbuffer.m @ 42:ae596261e75f

Various fixes and development to audio handling
author samer
date Tue, 02 Dec 2014 14:51:13 +0000
parents c3b0cd708782
children
line wrap: on
line source
function x=unbuffer(X,hop,H)
% unbuffer - overlap-and-add signal reconstruction (opposite of buffer)
% 
% unbuffer ::
%    [[N,T]] ~'overlapping frames',
%    natural ~'hop size',
%    ([[N]] | N:natural->[[N]]) ~'window or window function'
% -> [[T]].


[N L]=size(X);
T=N+(L-1)*hop;
x=zeros(T,1);
K=1:N;
if (nargin<3), H=hanning(N); 
elseif ~isnumeric(H)
	% assume it's a window function handle
	H=feval(H,N);
end

for k=1:L
	x(K)=x(K)+H.*X(:,k);
	K=K+hop;
end