reading, writing and processing .wav files in Matlab

조회 수: 5 (최근 30일)
Haraldur Mímir Bjarnason
Haraldur Mímir Bjarnason 2015년 8월 24일
댓글: Star Strider 2015년 8월 30일
Im on a school project and my problem is that I have a .wav file and I want to find the highest Db vs. frequency (Hertz) in that file. I'm measuring what frequency will sound (in the human ear) the highest. So I need a plot Db vs. frequency.
any idea?

채택된 답변

Star Strider
Star Strider 2015년 8월 25일
The fft function will do what you want, although you have to specify the magnitude of the fft in dB. The documentation for fft has the essential code between the first two figures in the documentation. You will need the log10 function to calculate dB from the magnitude.
  댓글 수: 2
Haraldur Mímir Bjarnason
Haraldur Mímir Bjarnason 2015년 8월 30일
I don't really know how to use the fft function, this is a script that I've been using, with psd.
[y,Fs]=audioread('2.h10-2000Hz.wav');
%mic
mic = y(:,1);
dt = 1/Fs;
%figure
plot(psd(spectrum.periodogram,mic,'Fs',Fs,'NFFT',length(mic)));
axis([0 2.1 -180 0])
Star Strider
Star Strider 2015년 8월 30일
Here is the approach I outlined, with a synthesised signal since I don’t have your .wav file:
t = linspace(0, 1, 1E+4); % Create Signal
y = sin(2*pi*t*100) + cos(2*pi*t*50);
Fs = 1/mean(diff(t));
Fn = Fs/2; % Nyquist Frequency
fty = fft(y)/length(y); % Take FFT & Normalise
fv = linspace(0, 1, fix(length(fty)/2)+1)*Fn; % Frequency Vector For Plot
iv = 1:length(fv); % Index Vector For Plot
figure(1)
plot(fv, 20*log10(abs(fty(iv)))) % Plot In dB
xlabel('Frequency (Hz)')
ylabel('Amplitude (dB)')
axis([0 250 ylim])
You will likely have to experiment to get the result you want with your signal.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Pulsed Waveforms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by