view arrows/aolapadd.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 672052bd81f8
children
line wrap: on
line source
function o=aolapadd(N,hop)
% aolapadd - overlap-and-add signal reconstruction arrow
% 
% aolapadd ::
%    N:natural ~'frame size',
%    M:natural ~'hop size'
% -> arrow( {[[N]]}, {[[M]]}, [[N-M]]).


	I=1:hop;
	ol=N-hop;

	o=loop1(1,1,@olapadd);

	function [fn,s0]=olapadd(sz)
		s0=zeros(ol,1);
		if ol<=hop, J=1:ol; K=hop+1:N; fn=ifx(sz(2)==1,@st1,@st2);
		else    J=hop+1:ol; K=ol+1:N; fn=ifx(sz(2)==1,@st3,@st4);
		end

		function [y,s]=st1(x,s)
			y=x(I);
			y(J)=y(J)+s;
			s=x(K);
		end

		function [y,s]=st2(x,s)
			width=size(x,2);
			y=zeros(hop,width);
			for i=1:width
				y(:,i)=x(I,i);
				y(J,i)=y(J,i)+s;
				s=x(K,i);
			end
		end

		function [y,s]=st3(x,s)
			y=(s(I)+x(I));
			s=[s(J)+x(J);x(K)];
		end

		function [y,s]=st4(x,s)
			width=size(x,2);
			y=zeros(hop,width);
			for i=1:width
				y(:,i)=(s(I)+x(I,i));
				s=[s(J)+x(J,i);x(K,i)];
			end
		end
	end
end