Overlap–add method
In signal processing, the overlap–add method is an efficient way to evaluate the discrete convolution of a very long signal with a finite impulse response filter :
where for outside the region
This article uses common abstract notations, such as or in which it is understood that the functions should be thought of in their totality, rather than at specific instants .
Algorithm
[Image:Overlap-add algorithm.svg|thumb|right|500px|Fig 1: A sequence of five plots depicts one cycle of the overlap-add convolution algorithm. The first plot is a long sequence of data to be processed with a lowpass FIR filter. The 2nd plot is one segment of the data to be processed in piecewise fashion. The 3rd plot is the filtered segment, including the filter rise and fall transients. The 4th plot indicates where the new data will be added with the result of previous segments. The 5th plot is the updated output stream. The FIR filter is a boxcar lowpass with samples, the length of the segments is samples and the overlap is 15 samples.]The concept is to divide the problem into multiple convolutions of with short segments of :
where is an arbitrary segment length. Then:
and can be written as a sum of short convolutions:
where the linear convolution is zero outside the region And for any parameter it is equivalent to the -point circular convolution of with in the region The advantage is that the circular convolution can be computed more efficiently than linear convolution, according to the circular convolution theorem:
where:
- DFTN and IDFTN refer to the Discrete Fourier transform and its inverse, evaluated over discrete points, and
- is customarily chosen such that is an integer power-of-2, and the transforms are implemented with the FFT algorithm, for efficiency.
Pseudocode
The following is a pseudocode representation of the algorithm:h = FIR_filter
M = length
Nx = length
N = 8 × 2^ceiling
step_size = N -
H = DFT
position = 0
y = 0
while position + step_size ≤ Nx do
y = y + IDFT
position = position + step_size
'''end'''
Efficiency considerations
[Image:FFT_size_vs_filter_length_for_Overlap-add_convolution.svg|thumb|400px|Fig 2: A graph of the values of N (an integer power of 2) that minimize the cost function ]When the DFT and IDFT are implemented by the FFT algorithm, the pseudocode above requires about complex multiplications for the FFT, product of arrays, and IFFT. Each iteration produces output samples, so the number of complex multiplications per output sample is about:
For example, when and equals whereas direct evaluation of would require up to complex multiplications per output sample, the worst case being when both and are complex-valued. Also note that for any given has a minimum with respect to Figure 2 is a graph of the values of that minimize for a range of filter lengths.
Instead of, we can also consider applying to a long sequence of length samples. The total number of complex multiplications would be:
Comparatively, the number of complex multiplications required by the pseudocode algorithm is:
Hence the cost of the overlap–add method scales almost as while the cost of a single, large circular convolution is almost. The two methods are also compared in Figure 3, created by Matlab simulation. The contours are lines of constant ratio of the times it takes to perform both methods. When the overlap-add method is faster, the ratio exceeds 1, and ratios as high as 3 are seen.
[Image:gain oa method.png|frame|none|Fig 3: Gain of the overlap-add method compared to a single, large circular convolution. The axes show values of signal length Nx and filter length Nh.]