Tuesday, November 19, 2013

Filtering and Algorithms

digital-filters
Digital filters are used in audio systems for attenuating or boosting the energy content of a sound wave at specific frequencies. The most common filter forms are high-pass, low-pass, band-pass and notch. Any of these filters can be implemented in two ways. These are the Finite Impulse Response (FIR) filter and the Infinite Impulse Response (IIR) filter, and they constitute building blocks to more complicated filtering algorithms like parametric equalizers and graphic equalizers.

Finite Impulse Response (FIR) Filter

The FIR filter's output is determined by the sum of the current and past inputs, each of which is first multiplied by a filter coefficient. The FIR summation equation is shown in figure below and its also known as convolution, one of the most important operations in signal processing. In this syntax, x is the input vector, y is the output vector, and h holds the filter coefficients. The figure also shows a graphical representation of the FIR implementation.

fir-filter

Convolution is such a common operation in media processing that many processors are designed to execute a multiply-accumulate (MAC) instruction along with multiple data accesses (reads and writes) and pointer increments in one cycle.

Infinite Impulse Response (IIR) Filter

Unlike the FIR filter, whose output depends only on its inputs, the IIR filter relies on both inputs and past outputs. The basic equation for an IIR filter is a difference equation as shown in figure below. Because of the current output's dependence on past outputs, IIR filters are often referred to as recursive filters. Graphical perspective on the structure of the IIR filter also shown in the following figure.

iir-filter

 

Fast Fourier Transform (FFT)

Quite often, we can do a better job describing an audio signal by characterizing its frequency composition. A Fourier transform takes a time-domain signal and translates it into the frequency domain; the inverse Fourier transform achieves the opposite, converting a frequency-domain representation back into the time domain. Mathematically, there are some nice property relationships between operations in the time domain and those in the frequency domain. Specifically, a time-domain convolution (or an FIR filter) is equivalent to a multiplication in the frequency domain. 

This tidbit would not be too practical if it weren't for a special optimized implementation of the Fourier transform called the Fast Fourier Transform (FFT). In fact, it is often more efficient to implement an FIR filter by transforming the input signal and coefficients into the frequency domain with an FFT, multiplying the transforms, and finally transforming the result back into the time domain  with an inverse FFT.

There are other transforms that are used often in audio processing. One of the most common is the Modified Discrete Cosine Transform (MDCT), which is the basis for many audio compression algorithms.

Sample Rate Conversion

There are times when you will need to convert a signal sampled at one frequency to a different sampling rate. One situation where this is useful is when you want to decode an audio signal sampled at, lets say 8 kHz, but the DAC you are using does not support that sampling frequency. Another scenario is when a signal is oversampled, and converting to a lower sampling frequency can lead to a reduction in computation time. The process of converting the sampling rate of a signal from one rate to another is called sampling rate conversion (SRC).



References:
- FPGAs World Class Designs, Clive "Max" Maxfield, Elsevier, 2009
- www.maximintegrated.com (source of figure "The Digital Filter") 



No comments:

Post a Comment