The x-axis is limited to the range in this plot to show more detail at the peak frequency. Next, the original data are plotted in the time domain and the FFT of the data is plotted. This step is important to determine the actual frequencies contained in the audio data. In the following line, the data that will be used for the abscissa is prepared by using the sampling frequency and the number of samples in the time domain. This is done for the purposes of this example, but for many applications, the entire spectrum is interesting. In the next line, half of the points in the FFT are discarded. The “fft” function allows the number of points outputted by the FFT to be specified, but for this example, we will use the same number of input and output points. ![]() ![]() Only the magnitude of the FFT is saved, although the phase of the FFT is useful is some applications. Matlab has no “dft” function, as the FFT computes the DFT exactly. The FFT is performed using the “fft” function. The sampling frequency is important for interpreting the data, as shown below. Note that the file extension “.wav” does not have to be specified in the function call. The sound file tuning_fork_A4 is opened using the wavread function, which returns the sampled data from the file, the sampling frequency, and the number of bits used in the A/D converter. Title('Frequency Response of Tuning Fork A4') Y_fft = y_fft(1:Nsamps/2) %Discard Half of Pointsį = Fs*(0:Nsamps/2-1)/Nsamps %Prepare freq data for plot T = (1/Fs)*(1:Nsamps) %Prepare time data for plot This shows how the Fourier transform works and how to implement the technique in Matlab. The file in this example is the recording of a tuning fork resonating at the note A4. The following is an example of how to use the FFT to analyze an audio file in Matlab. ![]() Matlab uses the FFT to find the frequency components of a discrete signal. The Fast Fourier Transform (FFT) is an efficient way to do the DFT, and there are many different algorithms to accomplish the FFT. The Discrete Fourier Transform (DFT) transforms discrete data from the sample domain to the frequency domain. This means that the Fourier transform can display the frequency components within a time series of data. This technique transforms a function or set of data from the time or sample domain to the frequency domain. The Fourier transform has applications in signal processing, physics, communications, geology, astronomy, optics, and many other fields. The Fourier transform is one of the most useful mathematical tools for many fields of science and engineering.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |