This is a little testing & debug suite of the FFT tools I'd written for Amit Pitaru's SONIA library. The actual FFT code is based on C implementations of Nullsoft's VMS and a paper by ProSoniq founder Stephan M. Sprenger. This code does not actually use SONIA nor does it perform the FFT on a real audio signal (ie. your sound input). Instead it synthesizes a sine wave made of 4 oscillators all linked to a common base frequency which can be controlled by the mouse position: X position changes the overall pitch, Y controls the amplitude of the signal. The The filter is used to ensure ultrasonic frequencies and their distortions are being removed from the spectrum. Frequencies higher than the Nyquist threshold can unfortunately not be filtered out and will appear in the spectrum mirrored. For example, a frequency of 25kHz cannot be replicated when using the standard sampling frequency of 44.1kHz. According to Nyquist's law the highest possible frequency in this case is 22.05kHz (equals 1/2 of 44.1kHz). When computing the FFT of this 25kHz signal the result will be distorted and a peak actually appears at: 22.05 - 25 + 22.05 = 19.1 kHz You can see this distortion effect happening by slowing moving the mouse to the far right. First the highest (rightmost) of the four peaks will slowly lose on gain and disappear from the The spectrum itself represents the distribution of the energy potential of all frequencies in the analysed signal. The resolution of the spectrum is variable and depends on the size of the time window used. In this example the window size is 1024 samples long and results in 512 frequency bands in the spectrum. This has to do with the fact that we only make use of the first half of the spectrum, which represents the range between 0 and the Nyquist frequency (here 22.05kHz). The 2nd half of the spectral data is discarded as it represents the so called "imaginary" part which is a mirrored version of the data contained in the lower half. As this example is using a fairly simple waveform, you can clearly see the four peaks of the contributing frequencies. The Naturally lower frequencies tend to be more energetic than higher ones, so to balance the resulting spectrum values and to help their further analysis, you can choose to apply an |

Source code |

Built with Processing |