Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books



Chapters

Chapter Contents:

Search Spectral Audio Signal Processing

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

Example of Overlap-Add Convolution

Let's look now at a specific example of FFT convolution:

We will work through the matlab for this example and display the results.

First, set up the simulation parameters:

L = 31;         % FIR filter length in taps
fc = 600;       % lowpass cutoff frequency in Hz
fs = 4000;      % sampling rate in Hz 

Nsig = 150;     % signal length in samples
period = round(L/3); % signal period in samples

FFT processing parameters:

M = L;                  % nominal window length
Nfft = 2^(ceil(log2(M+L-1))); % FFT Length
M = Nfft-L+1            % efficient window length
R = M;                  % hop size for rectangular window
Nframes = 1+floor((Nsig-M)/R);  % no. complete frames

Generate the impulse-train test signal:

sig = zeros(1,Nsig);
sig(1:period:Nsig) = ones(size(1:period:Nsig));

Design the lowpass filter using the window method:

epsilon = .0001;     % avoids 0 / 0
nfilt = (-(L-1)/2:(L-1)/2) + epsilon;   
hideal = sin(2*pi*fc*nfilt/fs) ./ (pi*nfilt);
w = hamming(L);
h = w' .* hideal;    % window it

hzp = [h zeros(1,Nfft-L)];  % zero-pad h to FFT size
H = fft(hzp);               % filter frequency response

Carry out the overlap-add FFT processing:

y = zeros(1,Nsig + Nfft); % allocate output+'ringing' vector
for m = 0:(Nframes-1)
    index = m*R+1:min(m*R+M,Nsig); % indices for the mth frame
    xm = sig(index);  % windowed mth frame (rectangular window)
    xmzp = [xm zeros(1,Nfft-length(xm))]; % zero pad the signal
    Xm = fft(xmzp);
    Ym = Xm .* H;               % freq domain multiplication
    ym = real(ifft(Ym))         % inverse transform
    outindex = m*R+1:(m*R+Nfft); 
    y(outindex) = y(outindex) + ym; % overlap add
end

The time waveforms for the first three frames ($ m=0,1,2$) are shown in Figures 8.13 through 8.15. Notice how the causal linear-phase filtering results in an overall signal delay by half the filter length. Also, note how frames 0 and 2 contain four impulses, while frame 1 only happens to catch three; this causes no difficulty, and the filtered result remains correct by superposition.

Figure 8.13: OLA Example, Frame 0.
\includegraphics[width=3in]{eps/ola0}
Figure 8.14: OLA Example, Frame 1.
\includegraphics[width=3in]{eps/ola1}
Figure 8.15: OLA Example, Frame 2.
\includegraphics[width=3in]{eps/ola2}


Order a Hardcopy of Spectral Audio Signal Processing

Previous: Acyclic Convolution
Next: Overlap-Add FFT Processing Summary

written by Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


No comments yet for this page


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )