samer@0: % adynfir - Apply dynamic FIR filter to input signal samer@0: % samer@0: % adynfir :: samer@0: % N:natural ~'number of FIR filter coefficients', samer@0: % M:natural ~'number of samples per input block' samer@0: % -> arrow({[[N]], [[M]]}, {[[M]]}, pair(empty,[[N-M]])). samer@0: samer@0: function o=adynfir(N,M) samer@0: samer@0: o=arr(@(f,u){f,u})*loop(@next,@(sz)zeros(N-1,1)); samer@0: samer@0: function [y,s2]=next(x,s) samer@0: if iscell(x) samer@0: u=[s;x{2}]; samer@0: y=conv2(u,x{1},'valid'); samer@0: s2=u(M+1:end); samer@0: else samer@0: y=zeros(M,1); samer@0: s2=s; samer@0: end samer@0: end samer@0: end