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');
Error using audioread>readaudio (line 143)
The filename specified was not found in the MATLAB path.

Error in audioread (line 136)
[y, Fs] = readaudio (filename, range, datatype);
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 comentarios

Rik
Rik el 21 de Dic. de 2021
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
Rena Berman el 25 de En. de 2022
Editada: Rena Berman el 15 de Feb. de 2022
(Answers Dev) Restored edit of post

Iniciar sesión para comentar.

Respuestas (1)

William Rose
William Rose el 19 de Dic. de 2021
Editada: William Rose el 19 de Dic. de 2021

0 votos

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 comentarios

Blue MU
Blue MU el 19 de Dic. de 2021
How big should the fft be to analyze entire sound?
I thought about using designfilt to make a low pass filter to remove frequencies above 4kHz.
William Rose
William Rose el 20 de Dic. de 2021
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
Walter Roberson el 20 de Dic. de 2021
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
William Rose el 20 de Dic. de 2021
Editada: William Rose el 21 de Dic. de 2021
@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.

Iniciar sesión para comentar.

Categorías

Más información sobre Audio Processing Algorithm Design en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de Dic. de 2021

Editada:

el 15 de Feb. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by