Question

I'd like get zero crossing rate of an audio signal. I tried to write the code of this formula:

enter image description here

But I dont excatly understand whole formula.

To process my code I split the signal by blocks, I mean "frame blocking". For example each lenght of blocks are 512(there are 512 sample of signal). And lets say I have 100 blocks. Then will zero crossing rate return just one value for each block or not? I mean will I have 100 value for whole signal according to formula?

And also I dont understand w() means. Is it hamming which I use for windowing? And how can it calculate for n-m? It will be most likely a negative number?

I am very confused please help me?

Was it helpful?

Solution

Forget the formula -- it makes it more complex when you try to express it that way.

The zero crossing rate is the number of times the signal changes sign in a given period of time (usually one second). That's all you need to know. Usually, you are interested in rate at which it goes from negative to positive or vice versa only, not every time the sign changes. Looking at the number of times it goes from negative to positive can be used as a proxy for the frequency of the signal.

As to what the w(n-m) is all about, that's a window function. This is what changes the question your formula answers from "how many times has the signal crossed zero ever?" to "how many times did the signal cross zero in the last n samples?". Honestly, it kinda makes my eyes go crossed, so don't feel bad for not understanding it -- it confuses me, too. For zero crossing rate, we will choose a window function such that w will return 1 in a certain range and zero otherwise. (this is called a rectangular window). A better way to express this formula for that kind of window would be to forget "windowing" as a general concept, and limit the bounds on sigma (sorry I don't know how to express formulae on SO):

Z_n(m) = sum_{m=x-n}^0|sign[x(m)] - sign[x(m-1)]|

if n = your sample rate, this will give you your zero crossing rate in Hz. That makes more sense: no more w and no more infinities! The source you were using may have included the window in an attempt to generalize, but, in this case, there is nothing to be gained (as far as I know -- but I don't know everything!)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top