view arrows/dsp/adyniir.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
% adyniir - Apply dynamic IIR filter to input signal
%
% adyniir :: arrow({[[K,N+1]], [[K,M]]}, {[[K,M]]}, [[K,N]]).
%
% N is the order of the IIR filter
% K is the number of independent channels to filter.
% M is the number of consecutive samples in input signal

function o=adyniir
	o=loop1(2,1,@(s1,s2)deal( ifx(s2(2)==1,@next1,@nextm), zeros(s1(1),s1(2)-1)));
end


function [y,yp]=next1(a,x,yp)
	y=x-sum(a(:,2:end).*yp,2);
	yp=[y,yp(:,1:end-1)];
end

function [y,yp]=nextm(a,x,yp)
	M=size(x,2);
	y=zeros(size(x));
	for i=1:M
		[y(:,i),yp]=next1(a,x(:,i),yp);
	end
end