help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zero Crossing Rate - optimize implementation


From: Akira Nishimura
Subject: Re: Zero Crossing Rate - optimize implementation
Date: Sat, 08 May 2010 10:06:11 +0900 (JST)

Hi,

Do you define the following vector as `zero crossed' ?  Your original
program and my revised one will find two zero crossing points.

s = [2 1 0 1 2];

> s=wavread('sample.wav');
> N=length(s)
> framesize=2000;
> frame_lim=[1:framesize:N-1];
> FN=length(frame_lim);
> zcr=zeros(1,FN-1);
> tic()
> for i=1:FN-1
    s1 = s(framesize*(i-1)+1:framesize*i);
    s2 = s(framesize*(i-1)+2:framesize*i+1);
    zcr(i) = length(find(s1.*s2 <= 0))-length(find(s1 == 0 & s2 == 0));
%    for k=frame_lim(1,i):frame_lim(1,i+1)
%        if sign(s(k)) != sign (s(k+1))
%         zcr(i)=zcr(i)+1;
%        endif
%    endfor
> endfor
> toc()
> 
> N =  236352
> Elapsed time is 41.39265 seconds.

Akira Nishimura, Associate Professor
Department of Media and Cultural Studies
Tokyo University of Information Sciences



reply via email to

[Prev in Thread] Current Thread [Next in Thread]