18 views (last 30 days)

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)

Jan
on 26 Apr 2018

[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));

Von Duesenberg
on 25 Apr 2018

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);

Von Duesenberg
on 26 Apr 2018

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
on 26 Apr 2018

@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.

Opportunities for recent engineering grads.

Apply Today
## 7 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560405

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560405

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560430

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560430

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560685

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560685

"Upload" would mean, that you have posted the file in this forum such that the readers can try to solve the problem by their own.

You could calculate the RMS (root mean square) of the signal and call

findpeaksto determine the number of peaks.## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560864

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560864

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560869

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560869

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560927

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_560927

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_561171

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/397069-counting-the-number-of-frequency-in-wav-file#comment_561171

Sign in to comment.