counting the number of frequency in wav file

조회 수: 5 (최근 30일)
faiz hazizi
faiz hazizi 2018년 4월 24일
댓글: faiz hazizi 2018년 4월 29일
hi, i would like to count the number of frequency on my sample audio file. it is a recorded drum audio file which contain 8 beat of kick pedal in 7 seconds. so the problem is, how to make a simulation to count the number of kick pedal in this audio file (.wav)
here are my .wav file
[y,fs]=audioread('C:\Users\Faiz\Desktop\Kick.wav');
t=linspace(0,length(y)/fs,length(y));
plot (t,y)
  댓글 수: 7
faiz hazizi
faiz hazizi 2018년 4월 25일
sorry sir, but i dont understand ? why is it need to calculate the rms value ? and what is the relationship between rms value and findpeaks ? i do found the coding of the findpeaks which is numel(findpeaks(your_signal)) but it didn't works on my work. and i don't understand what is the "(your_signal)"should be ? is it .wav file or what ?
Jan
Jan 2018년 4월 26일
@faiz hazizi: Remember that a diagram without labels does not explain anything. What do the two diagram represent?
The original signal has positive and negative values. You are not interested in the maximum value, but in the maximum amplitude. This can be positive or negative. Using abs helps to move all values to the positive side. If you have a single signal (mono sound), this is exactly the same as RMS: The mean of a scalar is the scalar, and Root of Squared value makes the sign positive. For a stereo signal, RMS considers both channels.
There is no "relationship" between RMS and findpeaks. The first one converts the signal to do what you want, the second one finds the peaks.
"your_signal" is the "y" in your code: The variable in which the audio signal is stored.

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

채택된 답변

Jan
Jan 2018년 4월 26일
[y, fs] = audioread('C:\Users\Faiz\Desktop\Kick.wav');
yRMS = sqrt(sum(y .^ 2, 2)); % Root mean square, same as abs(y) for mono signal
[pk, loc] = findpeaks(yRMS, 'MinPeakHeight', std(yRMS));
See doc findpeaks for more methods.
  댓글 수: 1
faiz hazizi
faiz hazizi 2018년 4월 29일
thank you sir, appreciate that, i'll try run the program first. if there's is any in problem regarding to this program i'll ask again sir, thank you

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

추가 답변 (1개)

Von Duesenberg
Von Duesenberg 2018년 4월 25일
A possible workflow:
%compute the envelope of y (your signal)
%assuming it's mono, and adjust the second
%parameter of the envelope function with
%successive plots of myEnv
[myEnv, ~] = envelope(y, 3000, 'peak');
%apply findpeaks, and adjust 'MinPeakProminence'
%to your needs
[pk, loc] = findpeaks(myEnv, 'MinPeakProminence', .5);
%get the number of peaks
nbPk = length(pk);
  댓글 수: 6
Von Duesenberg
Von Duesenberg 2018년 4월 26일
편집: Von Duesenberg 2018년 4월 26일
If you do
size(y)
And the second output says 2, then your audio is stereo; if it says 1, your audio is mono.
Jan
Jan 2018년 4월 26일
@faiz: "Mono" means, that the sound has been recorded with 1 channel. "Stereo" uses 2 channels, and needs 2 microphones. Ask WikiPedia for details.
If a sound is recorded with 2 channels, the output of audioread must have two columns also. See: doc audioread.

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

카테고리

Help CenterFile Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by