{"id":291,"date":"2013-08-15T11:37:42","date_gmt":"2013-08-15T11:37:42","guid":{"rendered":"http:\/\/www.electronic-products-development.com\/?p=291"},"modified":"2022-02-17T10:13:21","modified_gmt":"2022-02-17T10:13:21","slug":"fft-fast-fourier-transform","status":"publish","type":"post","link":"https:\/\/ibex.tech\/programming\/signal_processing\/fft-fast-fourier-transform","title":{"rendered":"FFT &#8211; Fast Fourier Transform"},"content":{"rendered":"<h4>\nGood resources<br \/>\n<\/h4>\n<p>\n<a href=\"http:\/\/www.dspdimension.com\/admin\/dft-a-pied\/\" target=\"_blank\" rel=\"noopener\">The DFT &ldquo;&agrave; Pied&rdquo;: Mastering The Fourier Transform in One Day<\/a>\n<\/p>\n<p>\n<a href=\"http:\/\/code.compartmental.net\/tools\/minim\/manual-fft\/\" target=\"_blank\" rel=\"noopener\">http:\/\/code.compartmental.net\/tools\/minim\/manual-fft\/<\/a>\n<\/p>\n<p>\n<a href=\"http:\/\/music.columbia.edu\/cmc\/musicandcomputers\/chapter3\/03_05.php\" target=\"_blank\" rel=\"noopener\">http:\/\/music.columbia.edu\/cmc\/musicandcomputers\/chapter3\/03_05.php<\/a>\n<\/p>\n<h4>\nFFT Software Libraries<br \/>\n<\/h4>\n<p>\n<a href=\"http:\/\/sourceforge.net\/projects\/kissfft\/\" target=\"_blank\" rel=\"noopener\">Kiss FFT<\/a>\n<\/p>\n<h4>\nUsing FFT For An Audio Spectrum Analyzer<br \/>\n<\/h4>\n<p>\nSpecial terms:\n<\/p>\n<p style=\"margin-left: 40px;\">\n&#39;Nyquist frequency&#39; = half&nbsp;of the sampling rate of a discrete signal processing system\n<\/p>\n<p style=\"margin-left: 40px;\">\n<span style=\"font-size: 10px;\">&#39;Bin width&#39; = the width of each sample position in Hz<\/span>\n<\/p>\n<p>\nBasic FFT Decisions\n<\/p>\n<p style=\"margin-left: 40px;\">\nThe sample rate, which determines the &quot;<span style=\"font-size: 10px;\">Nyquist frequency&quot;,<\/span>\n<\/p>\n<p style=\"margin-left: 40px;\">\nThe number of samples per frame, which <span style=\"font-size: 10px;\">determines&nbsp;<\/span>the frame size or &quot;bin width&quot;.\n<\/p>\n<p>\nIf we have a bin width of 43 Hz (which will be a result of dividing Nyquist frequency by the FFT frame size), then we have bins from 0 Hz to 43 Hz, 43 Hz to 86 Hz, 86 Hz to 129 Hz, and so on. &nbsp;The problem with this from an audio point of view&nbsp;is that the human ear responds to frequency logarithmically, not linearly. At low frequencies, 43 Hz is quite a wide interval (the jump from 43 Hz to 86 Hz is a whole octave), but at higher frequencies, 43 Hz is a tiny interval (perceptually, &nbsp;less than a minor second). So the FFT has very fine high-frequency pitch resolution, but very poor low-frequency resolution.\n<\/p>\n<h5>\nThe design trade off decision for an audio FFT<br \/>\n<\/h5>\n<p>\nA trade&nbsp;off that has to&nbsp;be made between frequency and time resolution. The more accurately you measure the frequency content of a signal, the more samples you&nbsp;have to analyze in each frame of the FFT. However the cost of&nbsp;expanding the frame size is that the larger the frame&nbsp;the less you&nbsp;know about the temporal events which take place within that frame. &nbsp;\n<\/p>\n<h5>\nA good audio approach<br \/>\n<\/h5>\n<p>\n1,024 samples is&nbsp;common frame size for an audio FFT <span style=\"font-size: 10px;\">a<\/span><span style=\"font-size: 10px;\">t a sample rate of 44.1 kHz<\/span>. &nbsp;This gives a&nbsp;<span style=\"font-size: 10px;\">43 Hz frequency resolution.<\/span>\n<\/p>\n<p>\nAt a sample rate of 44.1 kHz, 1024 samples is about 0.023&nbsp;seconds of audio. &nbsp;All of the audio which takes place within that 0.023&nbsp;seconds will be lumped together and analyzed as one event. Because of the nature of the FFT, this &quot;event&quot; is actually treated as if it were an infinitely repeating periodic waveform. The amplitudes of the frequency components of all the sonic events in that time frame will be averaged, and these averages will end up in the frequency bins.\n<\/p>\n<p>\nIf you need more than the 43 Hz frequency resolution that a 1k FFT gives you need to use a bigger frame size. However a bigger frame size means that even more samples will be lumped together&nbsp;giving you a&nbsp;worse time resolution. With the next&nbsp;frame size up of 2048 samples you&nbsp;get a frequency resolution of about 21.5 Hz, but with a time resolution of approx.&nbsp;0.05 (1\/20) of a second. That may still seem fast but in audio a lot can happen in 1\/20 of a second.\n<\/p>\n<p>\nif you construct an FFT with a timeSize of 1024 and and a sampleRate of 44100Hz the spectrum will contain values for frequencies below 22010 Hz, which is the Nyquist frequency (half the sample rate). &nbsp;If you read&nbsp;the value of band 5 it&nbsp;will correspond to a frequency band centered on 5\/1024 * 44100 = 0.0048828125 * 44100 = 215 Hz. The width of that frequency band is equal to 2\/1024, expressed as a fraction of the total bandwidth of the spectrum. The total bandwith of the spectrum is equal to the Nyquist frequency, which in this case is 22100, so the bandwidth is equal to about 50 Hz. &nbsp;Therefore&nbsp;much of the FFT data is effectively wasted&nbsp;on recording high-frequency information very accurately, at the expense of the low&nbsp;frequency information which is generally more useful in a musical context.&nbsp;\n<\/p>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good resources The DFT &ldquo;&agrave; Pied&rdquo;: Mastering The Fourier Transform in One Day http:\/\/code.compartmental.net\/tools\/minim\/manual-fft\/ http:\/\/music.columbia.edu\/cmc\/musicandcomputers\/chapter3\/03_05.php FFT Software Libraries Kiss FFT Using FFT For An Audio Spectrum Analyzer Special terms: &#39;Nyquist frequency&#39; = half&nbsp;of the sampling rate of a discrete signal processing system &#39;Bin width&#39; = the width of each sample position in Hz Basic FFT [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-291","post","type-post","status-publish","format-standard","hentry","category-signal_processing"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":11,"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":1271,"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/posts\/291\/revisions\/1271"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/programming\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}