Detecting sudden rises and printing on the console

2 views (last 30 days)
Hi, I'd like to detect the number of claps in a given wav file. Here's my first attempt. I can draw the spectogram but how can I print " There is only one clap " or " There are two claps " on the console according to the sudden rises?? Here is my code, for the file that includes one clap, there exist a single sudden rise and two sudden rises for the file that includes two claps. But how can I detect the sudden rises from the plotting and write it on the console?
hfile = 'one.wav';
[stereo1, Fs, nbits, readinfo] = wavread(hfile);
mono1 = mean(stereo1,2);
M = round(0.01*Fs);
N = 2^nextpow2(4*M);
w = gausswin(M);
[S,F,T,P] = spectrogram(mono1,w,120,N,Fs);
thresh_l=1000;
thresh_h=10000000;
% take the segment of P relating to your frequencies of interest
P2 = P(F>thresh_l&F<thresh_h,:);
%show the mean power in that band over time
m = mean(P2);
plot(T,m);

Answers (0)

Community Treasure Hunt

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

Start Hunting!