Code covered by the BSD License  

Highlights from
Find Zero crossing per frame

Find Zero crossing per frame

by

deepa (view profile)

 

find zero crossing for winow of specified length(here 100)

ZCRnew.m
% /*this is according to formula

% Split the input into frames
[input]=wavread('C:\Program Files\MATLAB\R2007b\bin\wavfile\i.wav');
nx = length(input);
disp(nx)
%set window size in len
len=100;
%find no of frames in nf
nf = fix(nx/len);

%initialize x as (nf by len) matrix
x=zeros(nf,len);

% store every window of size 100 into x
k=1;l=len;
s=1;
for j=k:nf
     x(j,:)=input(s:l,1);
     s=s+len;
     l=l+len;
end;


% Calculate the zero crossings per frame
cross=zeros(1,nf);
res=0;
for j=1:nf
    cross(j)=0;
for i=1:len-1
    res=abs(sn(x(j,i))-sn(x(j,i+1))); 
        cross(j)=cross(j)+(res/2);
end;
end;


subplot(2,2,1)
plot(input),title('original wav')
subplot(2,2,2)
plot(cross),title('ZCR')

Contact us