Overlap–add method: Difference between revisions

Content deleted Content added
Replace graphic depiction of algorithm with new version derived from Overlap-save method
Pseudocode: simplify
Line 60:
==Pseudocode==
 
AThe following is a [[pseudocode]] of the algorithm is the following:
 
<font color=green>('''AlgorithmOverlap-add 1''' (''OAalgorithm for linear convolution'')</font>
h = FIR_impulse_response
Evaluate the best value of N and L (L > 0, N = M + L - 1 nearest to power of 2).
Nx M = length(xh);
Nx = length(x)
H N = FFT(h, N) 4 × M <span style="color:green;">(''zero-paddedor a nearby FFT''power-of-2)</span>
i = 1
step_size = N - y = zeros(1, M + Nx - 1)
H = DFT(h, N)
'''while''' i <= Nx <span style="color:green;">(''Nx: the last index of x[n]'')</span>
position = 0
il = min(i + L - 1, Nx)
y(1 : Nx + M-1) = 0
yt = IFFT( FFT(x(i:il), N) * H, N)
 
k = min(i + N - 1, M + Nx - 1)
'''while''' position + step_size ≤ Nx
y(i:k) = y(i:k) + yt(1:k - i + 1) <span style="color:green;">(''add the overlapped output blocks'')</span>
y(position+(1:N)) = y(position+(1:N)) + IDFT(DFT(x(position+(1:step_size)), N) × H)
i = i + L
position = position + step_size
'''end'''
 
== Cost of the overlap-add method ==