0
$\begingroup$

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 
[Input_sig_16k,Fs] = audioread(‘filename);

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?

$\endgroup$
7
  • $\begingroup$ 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. $\endgroup$
    – Peter K.
    Jun 1, 2017 at 12:52
  • $\begingroup$ @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 ? $\endgroup$ Jun 1, 2017 at 15:26
  • $\begingroup$ 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? $\endgroup$
    – Peter K.
    Jun 1, 2017 at 15:30
  • $\begingroup$ 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 . $\endgroup$ Jun 1, 2017 at 15:35
  • $\begingroup$ 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 ? $\endgroup$ Jun 1, 2017 at 15:36

1 Answer 1

2
$\begingroup$

Don't overlap. Don't use a Von Hann window. Zero-pad by at least the length of the impulse response of your desired equalization filter. Then use an overlap add or overlap save fast convolution method or algorithm to combine your zero-padded and filtered FFT/IFFT blocks.

Otherwise circular convolution artifacts will corrupt (severely distort) your attempts at filtering your signal.

If you want to analyze or visualize the audio, use separate overlapped and windowed FFT blocks, not the ones used for overlap add/save fast convolution filtering.

$\endgroup$
1
  • $\begingroup$ i will be eventually implementing this in real time on an embedded device . As part of a project , the first step involves building a pass through device with a window function. I'm currently pressed for time, so I will be implementing the overlap and add at a later stage . For now I just want to get rid of the special leakages by adding a windowing function . So how could I add just window ( with no overlap ) and get the original signal back ? $\endgroup$ Jun 1, 2017 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.