How can I Plot a simple linear plot of sound pressure v/s frequency from an audio track?

1 visualización (últimos 30 días)
I need to plot power v/s frequency (Hz) simple 2-d plots of an audio file.

Respuestas (1)

Star Strider
Star Strider el 9 de Nov. de 2018
Us e the fft (link) function.
The full code would go something like this:
filename = 'YourFile.wav';
[y,Fs] = audioread(filename); % Import File
N = size(y,1); % Assuming Column Vectors
t = linspace(0, N, N)/Fs; % Time Vector (If Necessary)
Fn = Fs/2; % Nyquist Frequency
Fy = fft(y)/N;
Fv = linspace(0, 1, fix(N/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv): % Index Vector
figure
plot(Fv, abs(Fy(Iv,:))*2)
grid
  2 comentarios
AKSHAT NEGI
AKSHAT NEGI el 12 de Nov. de 2018
Thank you very much. Also I have multiple tracks and i need to plot all of them in one , Can that be done?
Star Strider
Star Strider el 12 de Nov. de 2018
My pleasure.
I am not certain what you want to do.
You can certainly plot them, although I would plot each track in a separate axes, probably using the subplot function. You can make all the frequency vectors the same by using the second ‘NFFT’ argument to the fft funciton.

Iniciar sesión para comentar.

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by