view dsp/unbuffer.m @ 36:9e7be347b3a0

Renamed sequence classes to avoid clashes with seq methods; Fixed default slicing dimension while retaining behaviour of window.m; Updated use of sequences in dsp/synth.
author samer
date Thu, 24 Jan 2013 14:51:23 +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