# Overlap and windowing a signal for signal processing

I’d like to digitally signal process an audio data. Therefore my idea was to:

• Split the audio data into individual blocks of 16 samples each.
• Each block has an overlap of 50% (8 samples are shared across each consecutive block).
• Each block of data is multiplied with a window (hanning),
• Do the FFT,
• apply an Equalizer to the FFT data (Which I will implement later),
• iFFT the data and recover the original signal back.

Due to the Equalizer, the output might differ a little from the input, but shouldn’t be distorted .

To this end, I implemented a MATLAB code,

% I am using an audio file sampled at 16kHz

window_size = 16;        % individual block size
overlap_win = 8;         % 50% overlap
data_full = zeros(1,length(Input_sig));
w = hanning(16);         % hanning windowing
for ii = 1:(length(Input_sig)/win_size)-1

data_range = ((ii-1)*overlap_win)+1:((ii-1)*overlap_win)+16;
%     [data_range(1) data_range(end)]
data_block = Input_sig_16k(data_range);

% windowing function
data_block = data_block.*w;
%     plot(data_block,'-rx');
%     ii

fft_sig = fft(data_block);                 %FFT of the signal

% I will multiply the frequency data with an Equalizer

ifft_sig = ifft(fft_sig);                  %iFFT of the signal

data_full(((ii-1)*window_size)+1:((ii-1)*window_size)+16) = ifft_sig;

end

subplot(2,1,1), plot(Input_sig_16k,'-og'), grid on;   % plot and compare both the signals
subplot(2,1,2), plot(data_full,'-xr'), grid on;


However the output data is quite distorted. I’m not sure what I need to do to recover the original signal. Could someone let me know the mistake behind what I have done.

So how do I obtain the correct output?

• Welcome to SE.DSP! What does changing the line data_full(((ii-1)*window_size)+1:((ii-1)*window_size)+16) = ifft_sig; to data_full(((ii-1)*window_size)+1:((ii-1)*window_size)+16) = data_block; do? Does it still sound distorted? You're modulating the data with a (co)sine-like function by windowing, so it's likely to be very distorted even without your yet-to-be-implemented FFT modification. Generally, you don't want to do windowing if you're trying to then filter the data.
– Peter K.
Jun 1, 2017 at 12:52
• @Peter K truth be told, I'm implementing a pass through application on an embedded device. Eventually I will add an overlap and add method with windowing which should help my program enormously . But for now , I just wanted to add a window function to get rid of spectral leakages. So is it not possible to apply just a windowing function ( without any overlap) and recover the original signal back ? Jun 1, 2017 at 15:26
• Only if you first multiply by the window and then divide it out... which is pointless. Windows have no use if you're filtering. They are only of use when you want to look at the spectrum. It seems you want to do the latter? Perhaps you are confusing overlap-add for filtering and COLA for spectrum smoothing?
– Peter K.
Jun 1, 2017 at 15:30
• I will implement WOLA ( a windowed overlap and add ) at a later stage. But since I'm pressed for time , I figured a windowed function would help me get rid of spectral leakages if any and preserve the quality of signal. So would you advise against windowing as well ? If that's the case , I'll most likely use just FFT-iFFT with time domain filters to smooth the signal and make a pass through device . Jun 1, 2017 at 15:35
• Would you recommmend any easy to do options to improve the quality of an audio signal ? I was thinking of using a few filters to smooth the signal ( with averaging ) . Is there anything in particular that you would recommend ? Jun 1, 2017 at 15:36