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 Kommentare

Jan
Jan am 24 Apr. 2018
Did you try to attach the file? What do you mean by "simulation"? What does "number of kick pedal" mean - the number of different pedals or the number of hits? What is "number of frequency"? A kick pedal produces a spectrum of frequencies. The number of different frequencies you find in the signal depends on the resolution of the data acquisition. Most likely you will find an amplitude for each signal, which is allowed by the Nyquist theorem and the block width of the FFT analysis.
Pleas edit the question and add more details.
faiz hazizi
faiz hazizi am 24 Apr. 2018
yes sir, i already upload the file as you can see on my question, i provide the coding.i use the same pedals, so it is the number of hits. so how to identified the number of kick pedal hits from my audio file?
Jan
Jan am 25 Apr. 2018

"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 findpeaks to determine the number of peaks.

faiz hazizi
faiz hazizi am 25 Apr. 2018
sorry sir, here are the file. so as you can see at the graph, i want to calculate the number of hits for the kick pedal. so i need to count the number of amplitude, for example the number of amplitude is 8.
Von Duesenberg
Von Duesenberg am 25 Apr. 2018
From your figure, the approach suggested by Jan seems adequate.
faiz hazizi
faiz hazizi am 25 Apr. 2018
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 am 26 Apr. 2018
@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.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jan
Jan am 26 Apr. 2018

0 Stimmen

[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 Kommentar

faiz hazizi
faiz hazizi am 29 Apr. 2018
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Von Duesenberg
Von Duesenberg am 25 Apr. 2018

0 Stimmen

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 Kommentare

faiz hazizi
faiz hazizi am 26 Apr. 2018
hi, thank you for the command, however after i run the program it has an error. how can i fix this problem ?
Which MATLAB version are you using? Earlier versions of findpeaks did not expect that option.
Von Duesenberg
Von Duesenberg am 26 Apr. 2018
Bearbeitet: Von Duesenberg am 26 Apr. 2018
Are you sure your audio is mono? If this is not the case, you should do this instead:
[myEnv, ~] = envelope(y(:,1), 3000, 'peak');
faiz hazizi
faiz hazizi am 26 Apr. 2018
i'm not sure either my audio is mono or what. actually my audio file was a recorded kick pedal sound. is it a mono type audio? and currently i'm using matlab 2016b.
Von Duesenberg
Von Duesenberg am 26 Apr. 2018
Bearbeitet: Von Duesenberg am 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
Jan am 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Measurements and Spatial Audio finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 24 Apr. 2018

Kommentiert:

am 29 Apr. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by