I want to locate the zero crossings in a short wav file. The obvious way is to take two consecutive points and do something like IF (A>0 and B<0) or (A<0 and B>0) then store that point and move ahead one. Is there any more elegant way?
Announcement
Collapse
No announcement yet.
Find zero crossings in wav file
Collapse
X
-
Is it 8 bit, or 16 bit, wav?
8 bit has a 128 mid point, 16 bit is signed; either way just look for a change in most significant bit. That should be faster than < and > comparisons.
For 8 bit something like:
mask byte with &h10
XOR with previous masked byte
if result of XOR is true then zero was crossed (MSB is different)
keep this masked byte for XOR with following byte, etc, etc.
Cheers,Dale
Comment
-
-
Think this might be the base templete. I also think the simplest thing is to look for going from negitive to postive and visa versa to find zero crossing.
if x is postive then x is true
if x is neg then x is fasle
if x is true loop until false
if x is false - zero cross from positive to negative occured -exit loop - now test for false to true condition
if x is false loop until true
if x is true zero cross from negative to positive to occured -exit loop
do this until end of file.A dozen what.
Comment
-
-
Hi
Make sure that there are no dc offsets in your signal, if so you will have to normalise the data if you want to use Dale's method (which by the way rocks!).
In other words, find the average and add the difference to each sample before doing the zero crossing analysis.
CheersGary Barnes
The Control Key
If you are not part of the solution
then you are either a gas, solid, plasma or some other form of matter.
Comment
-
-
Probably not near optimal, but this works just great for what I'm doing-
Code:temp = Amplitude(0) OR &h7FFF 'mask is 0111 1111 1111 1111 FOR count = 0 TO NumberOfSamples-1 IF temp XOR (Amplitude(count+1) OR &h7FFF) THEN crossings(x)=count : INCR x temp = Amplitude(count+1) OR &h7FFF NEXT count
Comment
-
Comment