view dsp/unbuffer.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
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