Filters A filter is any process that alters a signal. More specificially, though, it is a process that alters the spectrum (balance of frequency content) of a signal. The majority of commonly encountered digital filters are implemented by adding scaled and delayed versions of a signal to itself. Another way to think of this is that these filters modify each sample of a signal such that it is to some degree dependent upon recent past samples. The simplest filter configurations: Add a delayed (and scaled) version of the input signal to the current input signal (or subtract it from the current input signal). Add a delayed (and scaled) version of the output signal to the current input signal (or subtract it from the current input signal). The latter is known as a "feedback" filter (the delayed, scaled output is fed back into the input); the former is thus known as a "feedforward" filter (both the original and the delayed, scaled version are fed into the output). Feedforward: x(n) -> | -> -> -> * -> + -> y(n) | | |__->_x(n-d)_->__*__->__| Feedback: x(n) -> * -> + -> -> -> y(n) -> | -> | | |__<-__*__<-_y(n-d)_<-__| For example, if d = 1 sample, we get equations such as: y[n] = a0*x[n]+a1*x[n-1] or y[n] = a0*x[n]-a1*x[n-1] for a feedforward filter or y[n] = a0*x[n]+b1*y[n-1] or y[n] = a0*x[n]-b1*y[n-1] for a feedback filter where n is the current sample index, and n-1 is the index of the previous sample. By convention y is used for output samples and x is used for input samples. Thus y[n] represents the current output sample, x[n] represents the current input sample, x[n-1] represents the previous input sample, and y[n-1] represents the previous output sample. The scaling factors a0, a1, etc. and b1, b2, etc. are called filter coefficients. By convention we use a for input coefficients and b for output coefficients, with the numerical subscript representing the number of samples in the past to which that scaling coefficient is applied. These are lowpass filters in their effect. Each sample is constrained by (affected by, in a limiting manner) the previous input or output sample. This means that sudden drastic changes in the input signal - which correspond to high frequencies - are smoothed out, while gradual slight changes from sample to sample (corresponding to low frequency) in the input signal are minimally altered. Give an example in class to: Show the effect on a sample-by sample basis, and show how this reduces high frequencies more than low frequencies. Give an example in class to: Show the over-all amplitude-to-frequency response (a.k.a. frequency response), describe/define the term, and characterize different types of frequency response. Define: Lowpass, highpass, bandpass, notch, shelf Cutoff frequency, center frequency, bandwidth, Q impulse, impulse response, relationship to coefficients feedforward = finite impulse response = non-recursive; feedback = infinite impulse response = recursive General FIR filter equation: y[n] = a0*x[n]+a1*x[n-1]+a2*x[n-2]+...ai*x[n-i] This can be implemented by making a delay line of length i to hold past input samples. When a given past sample is not needed in the equation, we can just set its coefficient to 0. The list of coefficients can be thought of as a signal in its own right, and is called the impulse response of the filter because it is the signal that would result if you put a single impulse sample (a 1 followed by all 0s) into the filter. In effect, the input signal is convolved with the impulse response. (Each sample of one is delayed by and scaled by each sample of the other.) The longer the impulse response, the more detailed (and sharp) the frequency response of the filter can be, but the needed computation increases commensurately. Whenever a filter contains any past output samples, it is an IIR filter. So, the general equation for all filters of this type (FIR and IIR) is: y[n] = a0*x[n]+a1*x[n-1]+a2*x[n-2]+...ai*x[n-i]-b1*y[n-1]-b2*y[n-2]-...bj*y[n-j] This can also be written as a summation formula. FIR filters are safer and less likely to blow up, but they are often more costly computationally to get the same filtering effect. IIR filters, because they take advantage of the recursive computation, can do more with fewer coefficients. But they are more susceptible to extreme resonances and overloading.