# [fpc-pascal] Good FFT example anywhere?

Michael Schnell mschnell at lumino.de
Tue Apr 11 11:05:51 CEST 2017

```On 10.04.2017 23:20, Bo Berglund wrote:
> - A pulse stimulus is applied to the object to measure
> - The response transient is recorded for up to 150 ms

OK. In this case you will not need the "Windowing".

Instead you need to make sure that the pulse is surrounded by enough
Zero-line data. I suggest to place the Pulse's non-zero data in the
middle of an array of at least the double count of samples, the rest
being zero. Supposedly th Pulse starts with Zero, anyway, so no problem
here. If at the end the measurement is truncated, you should use a
"sinc" or similar curve to force it smoothly down to zero with the last
measured sample before the Zero-line starts.

Not doing this will result in a huge aliasing and unusable "spectrum data.

The cause is that Digital Fourier Transform converts a number of samples
in the same number of "bins" (= complex amplitude / phase spectrum data
for a dedicated frequency).

If there are n (="Window-Size") samples and the Sample Frequency is f,
the bins represent the frequencies 0, f/n, 2f/n, 3f/n, ... Hence the
bin[1] represents the Sample Frequency by the Window Size, which is the
lowest frequency usable, while the last bin represents the Sample
Frequency which in fact is not usable due to the Nyquist Theorem, that
allows for using only frequencies lower than half the Sample Frequency.
(This said, you need to make sure by hardware means that no frequencies
higher than half the sample even reach the A/D converter. Otherwise you
will feature aliasing that will make the spectrum unusable. )

The Nyquist Theorem also is visible in the fact that a DFT does not
really convert the signal you measured to a spectrum you want to see,
but in fact converts a periodic signal to a periodic spectrum. The
(assumed) period of the signal being the Window Size divided by the
Sample Frequency, the period of the spectrum being the Sample Frequency
divided by the Window Size. Hence adding the Zero-Line will allow your
signal to be the significant part of a period.

-Michael

```

More information about the fpc-pascal mailing list