Misplaced Pages

Overlap–add method

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Overlap-add method) This article is about the convolution method. For the "Weight, OverLap, Add" channelization method, see Sampling the DTFT.

In signal processing, the overlap–add method is an efficient way to evaluate the discrete convolution of a very long signal x [ n ] {\displaystyle x} with a finite impulse response (FIR) filter h [ n ] {\displaystyle h} :

y [ n ] = x [ n ] h [ n ]     m = h [ m ] x [ n m ] = m = 1 M h [ m ] x [ n m ] , {\displaystyle y=x*h\ \triangleq \ \sum _{m=-\infty }^{\infty }h\cdot x=\sum _{m=1}^{M}h\cdot x,}    

(Eq.1)

where h [ m ] = 0 {\displaystyle h=0} for m {\displaystyle m} outside the region [ 1 , M ] . {\displaystyle .}   This article uses common abstract notations, such as y ( t ) = x ( t ) h ( t ) , {\textstyle y(t)=x(t)*h(t),} or y ( t ) = H { x ( t ) } , {\textstyle y(t)={\mathcal {H}}\{x(t)\},} in which it is understood that the functions should be thought of in their totality, rather than at specific instants t {\textstyle t} (see Convolution#Notation).

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 M = 16 {\displaystyle M=16} samples, the length of the segments is L = 100 {\displaystyle L=100} samples and the overlap is 15 samples.

The concept is to divide the problem into multiple convolutions of h [ n ] {\displaystyle h} with short segments of x [ n ] {\displaystyle x} :

x k [ n ]     { x [ n + k L ] , n = 1 , 2 , , L 0 , otherwise , {\displaystyle x_{k}\ \triangleq \ {\begin{cases}x,&n=1,2,\ldots ,L\\0,&{\text{otherwise}},\end{cases}}}

where L {\displaystyle L} is an arbitrary segment length. Then:

x [ n ] = k x k [ n k L ] , {\displaystyle x=\sum _{k}x_{k},\,}

and y [ n ] {\displaystyle y} can be written as a sum of short convolutions:

y [ n ] = ( k x k [ n k L ] ) h [ n ] = k ( x k [ n k L ] h [ n ] ) = k y k [ n k L ] , {\displaystyle {\begin{aligned}y=\left(\sum _{k}x_{k}\right)*h&=\sum _{k}\left(x_{k}*h\right)\\&=\sum _{k}y_{k},\end{aligned}}}

where the linear convolution y k [ n ]     x k [ n ] h [ n ] {\displaystyle y_{k}\ \triangleq \ x_{k}*h\,} is zero outside the region [ 1 , L + M 1 ] . {\displaystyle .} And for any parameter N L + M 1 , {\displaystyle N\geq L+M-1,\,} it is equivalent to the N {\displaystyle N} -point circular convolution of x k [ n ] {\displaystyle x_{k}\,} with h [ n ] {\displaystyle h\,} in the region [ 1 , N ] . {\displaystyle .}   The advantage is that the circular convolution can be computed more efficiently than linear convolution, according to the circular convolution theorem:

y k [ n ]   =   IDFT N (   DFT N ( x k [ n ] )   DFT N ( h [ n ] )   ) , {\displaystyle y_{k}\ =\ \scriptstyle {\text{IDFT}}_{N}\displaystyle (\ \scriptstyle {\text{DFT}}_{N}\displaystyle (x_{k})\cdot \ \scriptstyle {\text{DFT}}_{N}\displaystyle (h)\ ),}    

(Eq.2)

where:

  • DFTN and IDFTN refer to the Discrete Fourier transform and its inverse, evaluated over N {\displaystyle N} discrete points, and
  • L {\displaystyle L} is customarily chosen such that N = L + M 1 {\displaystyle N=L+M-1} is an integer power-of-2, and the transforms are implemented with the FFT algorithm, for efficiency.

Pseudocode

The following is a pseudocode of the algorithm:

(Overlap-add algorithm for linear convolution)
h = FIR_filter
M = length(h)
Nx = length(x)
N = 8 × 2^ceiling( log2(M) )     (8 times the smallest power of two bigger than filter length M.  See next section for a slightly better choice.)
step_size = N - (M-1)  (L in the text above)
H = DFT(h, N)
position = 0
y(1 : Nx + M-1) = 0
while position + step_size ≤ Nx do
    y(position+(1:N)) = y(position+(1:N)) + IDFT(DFT(x(position+(1:step_size)), N) × H)
    position = position + step_size
end

Efficiency considerations

Fig 2: A graph of the values of N (an integer power of 2) that minimize the cost function N ( log 2 N + 1 ) N M + 1 {\displaystyle {\tfrac {N\left(\log _{2}N+1\right)}{N-M+1}}}

When the DFT and IDFT are implemented by the FFT algorithm, the pseudocode above requires about N (log2(N) + 1) complex multiplications for the FFT, product of arrays, and IFFT. Each iteration produces N-M+1 output samples, so the number of complex multiplications per output sample is about:

N ( log 2 ( N ) + 1 ) N M + 1 . {\displaystyle {\frac {N(\log _{2}(N)+1)}{N-M+1}}.\,}    

(Eq.3)

For example, when M = 201 {\displaystyle M=201} and N = 1024 , {\displaystyle N=1024,} Eq.3 equals 13.67 , {\displaystyle 13.67,} whereas direct evaluation of Eq.1 would require up to 201 {\displaystyle 201} complex multiplications per output sample, the worst case being when both x {\displaystyle x} and h {\displaystyle h} are complex-valued. Also note that for any given M , {\displaystyle M,} Eq.3 has a minimum with respect to N . {\displaystyle N.} Figure 2 is a graph of the values of N {\displaystyle N} that minimize Eq.3 for a range of filter lengths ( M {\displaystyle M} ).

Instead of Eq.1, we can also consider applying Eq.2 to a long sequence of length N x {\displaystyle N_{x}} samples. The total number of complex multiplications would be:

N x ( log 2 ( N x ) + 1 ) . {\displaystyle N_{x}\cdot (\log _{2}(N_{x})+1).}

Comparatively, the number of complex multiplications required by the pseudocode algorithm is:

N x ( log 2 ( N ) + 1 ) N N M + 1 . {\displaystyle N_{x}\cdot (\log _{2}(N)+1)\cdot {\frac {N}{N-M+1}}.}

Hence the cost of the overlap–add method scales almost as O ( N x log 2 N ) {\displaystyle O\left(N_{x}\log _{2}N\right)} while the cost of a single, large circular convolution is almost O ( N x log 2 N x ) {\displaystyle O\left(N_{x}\log _{2}N_{x}\right)} . 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.

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.

See also

Notes

  1. This condition implies that the x k {\displaystyle x_{k}} segment has at least M 1 {\displaystyle M-1} appended zeros, which prevents circular overlap of the output rise and fall transients.
  2. Cooley–Tukey FFT algorithm for N=2 needs (N/2) log2(N) – see FFT – Definition and speed

References

  1. Rabiner, Lawrence R.; Gold, Bernard (1975). "2.25". Theory and application of digital signal processing. Englewood Cliffs, N.J.: Prentice-Hall. pp. 63–65. ISBN 0-13-914101-4.

Further reading

Categories: