FFT Length Definition

I am working on a tool to compare two wave files for similarity in my waveforms. Ex, I have a wave file with a duration of 1 minute, and I make another wave file using the first, but every 5 seconds I recorded with an interval of 5 seconds to 0. Now my software will report that there is a signal difference in the time interval of 5 seconds up to 10 seconds, from 15 seconds to 20 seconds, from 25 seconds to 30 seconds and so on ...

At the moment, with the initial development, this works fine. Below are 3 test suites:

  • I have two wave files with a sampling frequency of 960 Hz, mono, without data as 138551 (arnd 1min 12sec files). I use a 128-point FFT (128 split sample file) and the results are good.

  • When I use the same algorithm on wave files with a sampling frequency of 48 kHz, 2-channel without data 6927361 for each channel (file arnd 2min 24 s), the process becomes too slow. When I use 4096 FFT points, the process is better.

  • But 4096 FFT points in 22050 Hz files, 2-channel with 55776 data samples for each channel (arnd 0.6sec file) give very poor results. In this case, a 128-point FFT gives a good result.

So, I am confused about how to determine the FFT length so that my results are good in every case.

I assume that the length should depend on the number of samples and the sampling rate. Please provide your details about this.

thanks

+4
source share
2 answers

The length of the FFT, N , will determine the resolution in the frequency domain:

 resolution (Hz) = sample_rate (Hz) / N 

So, for example, in case (1) you have resolution = 960 / 128 = 7.5 Hz . Thus, each bit in the resulting FFT (or presumably the power spectrum obtained from this) will have a width of 7.5 Hz, and you will be able to distinguish frequency components that are at least far from each other.

Since you are not saying what waveforms or goals of your application, it’s hard to understand what resolution you need.

Another important point - many people using FFT for the first time do not know that in general you need to apply the window function before FFT to avoid spectral leakage .

+4
source

I have to say that I found your question very mysterious. I think you should take a look at the short Fourier transform. The reason I say this is because you look at a fairly large number of samples if you use a sampling frequency of 44.1 kHz for more than 2 minutes with 2 channels. One fft over the entire sum will take quite a lot of time, not to mention that the estimate will be biased, since the average value of the signals and variance will change dramatically throughout the duration. To avoid this, you want to record the signal in the time domain first, these frames can be as small as 20 ms-40 ms (usually used for speech) and often overlap ( Welch method of spectral estimation ). Then you apply a window function, such as a Hamming or Hanning window, to reduce spectral leakage and calculate the N-point fft for each frame. Where N is the next power twice the number of samples in this frame. For instance:

  • Fs = 8Khz, one channel;
  • time = 120sec;
  • no_samples = time * Fs = 960000;
  • frame length T_length = 20ms;
  • frame length in samples N_length = 160;
  • frame overlap T_overlap = 10ms;
  • overlapping frames in samples N_overlap = 80;
  • The number of frames N_frames = (no_samples - (N_length-N_overlap)) / N_overlap = 11999;
  • FFT Length = 256;

So, you will process 11999 frames in total, but your FFT length will be small. You only need the length of the FFT 256 (the next power is twice the frame length of 160). Most algorithms that implement fft require the signal length and fft to be the same. All you have to do is add zeros to your framed signal up to 256. So overlap each frame with x number of zeros, where x = FFT_length-N_length. My latest Android app does this on recorded speech and uses short-term FFT data to display Speech Spectrograms, and also performs various spectral modifications and filtering called Speech Improvement for Android

+1
source

Source: https://habr.com/ru/post/1381245/


All Articles