Red freq audio file
이전 댓글 표시
For a project, I have to do the following 2 requirements.
-Use Matlab to read the attached audio file, which has a sampling frequency Fs= 48 KHz. Find the spectrum of this signal (the signal in frequency domain). [audioread, fft , fftshift , plot]
-Using an ideal Filter, remove all frequencies greater than 4 KHz
I wrote this part so far and I don't know if it's right or not and I'm stuck. Any help would be appreciated!
[xn, fs]=audioread('eric.wav');
nf=1024; %number of point in DTFT
Y = fft(xn,nf);
f = fs/2*linspace(0,1,nf/2+1);
plot(f,abs(Y(1:nf/2+1)));
댓글 수: 2
Rik
2021년 12월 21일
Reading audio file and finding spectrum
For a project, I have to do the following 2 requirements.
-Use Matlab to read the attached audio file, which has a sampling frequency Fs= 48 KHz. Find the spectrum of this signal (the signal in frequency domain). [audioread, fft , fftshift , plot]
-Using an ideal Filter, remove all frequencies greater than 4 KHz
I wrote this part so far and I don't know if it's right or not and I'm stuck. Any help would be appreciated!
%[xn, fs]=audioread('file_name.wav');
%nf=1024; %number of point in DTFT
%Y = fft(xn,nf);
%f = fs/2*linspace(0,1,nf/2+1);
%plot(f,abs(Y(1:nf/2+1)));
Rena Berman
2022년 1월 25일
편집: Rena Berman
2022년 2월 15일
(Answers Dev) Restored edit of post
답변 (1개)
William Rose
2021년 12월 19일
편집: William Rose
2021년 12월 19일
0 개 추천
Sounds like a good project. Your code looks like a good first step. What happens when you run your code? Do you get an error message? If it runs without error, then evaluate the plot of abs(Y) versus frequency: does it look reasonable?
Please attach the audio file file_name.wav, and format your code as "code" in your posting, and run it, so that we can see the plot that you get.
Why do you limit the fft to 1024 points? How long (how many points) is xn? When you limit the fft to 1024 points, the input signal is trucated to 1024 points, if it is longer. This means you are analyzing only the first 1/48th of a second of sound, which is probably less than what you want.
Next step will be to implement the ideal filter, to remove frequencies above 4 kHz. Any ideas for how you could do that?
댓글 수: 4
Blue MU
2021년 12월 19일
William Rose
2021년 12월 20일
First: The error occurs because Matlab can't find the audio file. It is not in your working directory. Fix it by putting the file there, or by adding its location to the Matlab path. If you're not sure how, read the Matlab help on the Path variable, or search this answers site for help on Path, since it is a common question.
I would analyze five to ten seconds. If you take a much shorter sample, it may be hard to tell the difference between the raw and filtered signals.
You have not uploaded file eric.wav to this discussion. If you don't want to, OK.
As for your choice of filter: designfilter can mke a very nice filter. "Ideal" is a funny term. There is no such thing as an ideal filter. They all have their issues. Filtering is often explained with reference to the frequency domain, and an ideal filter is often considered to be a filter with a "brick wall" stop-band: That is, the gain is unity up to the cutoff frequency, and zero above it. I doubt you can make such a filter in designfilter(), but you can implement such an approach easily, without special tools like designfilter. Think about it. Hint: do you know what an inverse Fourier transform is?
Walter Roberson
2021년 12월 20일
Filtering by manipulating the discrete fourier transform results only works for limited size buffers, or for reading the entire signal at one time and processing it. If you work based on frames of limited size, then you can never get a "brick wall" response for frequencies outside the bins implied by the buffer size and sampling frequency.
William Rose
2021년 12월 20일
편집: William Rose
2021년 12월 21일
@Walter Roberson is correct, of course. But you could do it in this case. Remember to manipulate the FFT symmetrically on either side of the Nyquist frequency.
카테고리
도움말 센터 및 File Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!