Nx = 1024; % input signal length (nonzero portion) Nh = 128; % FIR filter length A = 1; B = ones(1,Nh); % FIR "running sum" filter n = 0:Nx-1; x = sin(n*2*pi*7/Nx); % input sinusoid - zero-pad it: zp=zeros(1,Nx/2); xzp=[zp,x,zp]; nzp=[0:length(xzp)-1]; y = filter(B,A,xzp); % filtered output signalWe know that the transient response must end samples after the input sinewave switches on, and the decay-time lasts the same amount of time after the input signal switches back to zero.
For Infinite Impulse Response (IIR) filters, such as the recursive comb filter analyzed in Chapter 3, the transient response decays exponentially. This means it is never really completely finished. In other terms, since its impulse response is infinitely long, so is its transient response, in principle. However, in practice, we treat it as finished for all practical purposes after several time constants of decay. For example, seven time-constants of decay correspond to more than 60 dB of decay, and is a common cut-off used for audio purposes. Therefore, we can adopt as the definition of decay time (or ``ring time'') for typical audio filters. See 6.5 for a detailed derivation of and related topics. In summary, we can say that the transient response of an audio filter is over after seconds, where is the time it takes the filter impulse response to decay by dB.
FIR Software Implementations