 The Fast Fourier Transform is amazing at telling you which frequencies your signal is built out of, but like any tool, if you put garbage in, you'll get garbage out. I once fed the FFT a poorly sampled signal and got back complete gibberish. In this video, we'll learn how to avoid that problem by exploring three key pitfalls to dodge when preparing your signal for the FFT. Stay tuned to discover how you too can master the Fourier Transform. Hi, I'm Mark Newman and I'm here to help you understand the fascinating world of signals and systems. Here are three tips that will improve your chances of finding all the frequencies that exist in your signal. 1. Set the optimum sampling rate For accurate frequency analysis of the FFT, providing it with enough data to do its job is crucial, but giving it too much information will cost you increased computational load and memory usage. When you sample a signal, you are, by definition, throwing away some of the information about that signal. It's like taking snapshots of a scene. What is happening between those snapshots? Nyquist Rule says that so long as you take at least twice the number of snapshots per second as the fastest moving element in your scene, then you will have enough information to perfectly reconstruct that movement. However, if you don't, a phenomenon known as aliasing occurs. In an audio signal, this is what it sounds like. Aliasing occurs because there are not enough samples to faithfully describe the higher frequencies of your signal. Any frequencies greater than half your sampling rate, also known as the Nyquist frequency, will disguise themselves as lower ones and distort your signal. So to make sure you get an accurate representation of your signal, you must set the sampling frequency at least twice as high as the highest frequency in your signal. But why not set the sampling frequency to 10 times the highest frequency? That way you can be sure to capture all those high frequencies. Sampling your signal too often can lead to computational overload. The FFT may be very efficient, but it too has its limits. So just like the story of Goldilocks and the Three Bears, make sure you don't set your sampling frequency too high or too low, but make sure it's set just right. Number 2 Use an Anti-Aliasing or Low Pass Filter Audio engineers often record signals like music, which typically contains frequencies up to 20 kHz, the upper limit of the human hearing range. However, there may well be noise around with higher frequencies that your ears cannot detect. These high frequencies can get into your recording and without proper filtering can lead to aliasing distorting your signal. To prevent aliasing, use an Analog Low Pass Filter before sampling. But remember, these filters don't have a sharp cutoff. They gradually attenuate frequencies above the specified cutoff frequency. While setting the cutoff frequency to 20 kHz might seem sufficient, some higher frequencies will still leak through due to the filter's roll-off. Therefore, the sampling frequency needs to be higher than twice the cutoff frequency to ensure you capture relevant information and avoid aliasing. For audio applications, a common choice is 44.1 kHz, which allows an accurate representation of human audible frequencies while accounting for the filter's roll-off. Number 3 Use a Windowing Function to Reduce Spectral Leakage Silence, they say, is golden. Silence at the beginning and end of the signal you feed into your FFT improves the accuracy of its output, enabling it to more faithfully represent the frequencies present in your signal. Imagine this recording of me suddenly ended before I had finished what I was saying. Did you hear that click? That click happened because I cut the signal short. I didn't wait until it fell silent. That click is full of frequencies that shouldn't be there. This distorts the FFT's output, a distortion known as spectral leakage. Some of the energy of the signal has leaked into adjacent frequencies due to discontinuities at the beginning and end of the frame. So how does windowing help? Real-world signals are generally not periodic signals, they don't keep on repeating. Life would be very boring if they did, as no new information can be transferred in a repeating signal. The problem is that within a limited band of frequencies, non-repeating signals involve sinusoids at an infinite number of intermediate frequencies. No matter when you end the recording, some of those sinusoids will not have completed a whole number of cycles. The best we can do is to wait for these signals to fall silent, but they won't necessarily have done so by the time you need to stop your recording to run the FFT. So we need to force them to do so by using a windowing function to prevent discontinuities like the click we just heard. Windowing functions fade a signal in from zero at the beginning of the window and fade them out again at the end. This ensures that there are no sharp edges at the beginning and end of the signal, and it reduces, but doesn't solve, the problem of spectral leakage. Unfortunately no windowing function can perfectly achieve both minimizing spectral leakage and maintaining high frequency resolution. Reducing spectral leakage often comes at the cost of broadening the main frequency peaks, which reduces our ability to distinguish between closely spaced frequencies. Therefore, choosing the right windowing function depends on your specific needs and priorities. For example, here's a signal containing only one sinusoid at a frequency of 16.5 Hertz. The output of the Fourier transform should show us a single line at 16.5 Hertz because that is the only frequency present. However, because of the length of my FFT window, I've had to cut the signal short and the sinusoid has not had time to complete a whole number of cycles, leading to all this spectral leakage. Let's apply a 2-key window to the signal in the time domain. The 2-key window has given us a reasonably sharp frequency peak, but suffers from these side lobes, meaning there is still some spectral leakage. In contrast, if I try a hanning window, the peak is not quite as sharp as the 2-key window, but there are no side lobes, meaning it has got rid of more of the spectral leakage. If you want the best of both worlds, a hanning window gives a reasonable balance between these two conflicting requirements, which is why it is one of the most commonly used windowing functions. By following these tips, you've prepared your data for accurate and insightful analysis with the FFT, but the real magic happens inside the black box. Ever wondered what's going on in there? Understanding the Fourier transform isn't just about using it, it's about unlocking its true potential. Imagine being able to interpret its results with confidence, troubleshooting issues like a pro, and squeezing even more insights from your data. That's why I've created How the Fourier Transform Works, an online course that breaks down the mathematical complexities of the Fourier transform into clear bite-sized lessons, no more feeling lost in equations. On the course, you'll learn to unravel the mystery of sine waves, and build a solid foundation for understanding the building blocks of the Fourier transform. We'll demystify the world of complex numbers and learn how they make your calculations a lot easier to do, and you'll discover the power of convolution to reveal the secrets your data has been hiding. The official release is still a few months away, but you can be one of 50 early birds and get 50% off the course price, instant access to the first 15 lectures, automatic updates as new lectures are completed revealing how all these concepts combine to form the Fourier series and the Fourier transform, and the chance to shape the development of the course with your valuable feedback. Don't wait to unlock the awesome power of the Fourier transform. Click the link in the description and secure your spot as one of the lucky 50 today.