フィルターのクリア

How to get dominant frequency of mp3 / wav file?

1 回表示 (過去 30 日間)
Yasir Ali
Yasir Ali 2019 年 4 月 4 日
編集済み: Jan 2019 年 4 月 5 日
Hello Seniors I want to plot dominant frequency for my wav file. I have a demo code for dominant frequency but I dont know how to get dominant frequency of wav file.
[Y,fs]=audioread('filename.wav);
Code is
Fs=1000;%sampling frequency 1 khz
t=0: 1/fs: 0.296;%time scale
f=200; %HZ, embedded dominant frequency
x=cos (2*pi*f*t)+ randn (size(t));% time series
Plot (t,x), axis ('tight'), grid('on') , title ('Time Series '),figure
nfft=512;% next larger power of 2
y=fft (x,nfft);% fast fourier transform
y= abs(y.^2); % raw power spectrum density
y=y(1:1+nfft/2);% half-spectrum
[v,k] = max (y);% find maximum
f_scale = (0:nfft/2)* fs /nfft;% frequency scale
Plot(f_scale,y),axis('tight'),grid ('on'),title ('Dominant frequency)
f_est=f_scale(k); % dominant frequency estimates
f hz, estimated
fprintf('Dominant freq.: true%f HZ, estimated % f HZ \ n', f, f_est)
fprintf (' Frequency step (resolution) =% f HZ\n', f_scale(2))
  3 件のコメント
Yasir Ali
Yasir Ali 2019 年 4 月 4 日
I want to get dominant frequency of wav file.
Jan
Jan 2019 年 4 月 5 日
編集済み: Jan 2019 年 4 月 5 日
The posted code does not run for several reasons:
Fs=1000;%sampling frequency 1 khz
t=0: 1/fs: 0.296;%
You define Fs and use fs. Matlab is case-sensitive. Same for Plot (t,x).
Do you really want to create the diagram at first and the figure afterwards?
Plot (t,x), axis ('tight'), grid('on') , title ('Time Series '),figure
Add a trailing quote in:
title ('Dominant frequency)
I assume, if your code runs, it will determine the dominant frequency. So all you have to do is to use the loaded Y instead of the created x.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by