# Need description for the matlab code for baby cry detection

Status
Not open for further replies.

#### mkirankumar

##### Newbie level 1
Please give me the description for the code below.
This is based on baby cry detection. that is finding the pitch of the baby cry and controlling the cradle accordingly

*******************************************************************

x=fft(double);
z=length(x);
z1=int16(z/8000);
z2=z1*150;
z3=z1*200;
z4=z1*900;
m = abs(x(5:z));
b=m;
if z>100000
d=m>=100;
else
d=m>=20;
end
f = (4:length(x)-1)'*Fs/length(x);
% subplot(2,1,1)
% plot(f,m),
% title('Frequency Components of cry signal')
% ylabel('Abs. Magnitude'),
% xlabel('Frequency (Hz)')
% grid on
i=1; %variables declaration
k=1;
n=1;
l=1;
p=1;
y1=1;
y2=2;
for j=5:z/2 %extracting the indivisual Frequency Components of cry signal
if d(j)==1
k= j;
n(i)= f(max(k));
% t(i)=1/n(i);
% size
i=i+1;
end
end
for j=z1:z4
if d(j)==1
k= j;
t(i)= f(max(k));

y2=y2+1;
end
end

freq4=0;
for l=1:y2-1
freq5=n(1,l)+freq4;
freq6=freq5;
freq4=freq6;
end
maxfundfreq=freq5/(y2);
pitch2=maxfundfreq-20;
if pitch2<200
pitch1=215
else
pitch1=pitch2
end
% subplot(2,1,2)
% plot(pitch1,f(4:z4)),
% title('pitch of cry signal ')
% grid on

if(pitch1>=1200 && pitch1<=1500 && loud==0)
disp('Low');
fprintf(ser,'2');
pause(2)

elseif(pitch1>=1200 && pitch1<=1500 && loud==1)
disp('High');

fprintf(ser,'1');
pause(2)

else
disp('No Cry');
fprintf(ser,'3');
pause(1)
end
end %end of while
fclose(ser);

Status
Not open for further replies.