Wanted: a plugin to find synchronous zero crossings

Help for Audacity 2.x.x on Windows.
Forum rules
ImageThis forum is for Audacity 2.x.x on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Ilya Kuligin
Posts: 7
Joined: Sun Jan 10, 2021 5:23 pm
Operating System: Windows 8 or 8.1

Re: Wanted: a plugin to find synchronous zero crossings

Post by Ilya Kuligin » Thu Jan 14, 2021 1:59 pm

steve wrote:
Wed Jan 13, 2021 9:26 pm
Does it do what you want it to do?
Looks like no.
What it does
not.png
not.png (3.38 KiB) Viewed 103 times
What I need
ok.png
ok.png (3.11 KiB) Viewed 103 times

steve
Site Admin
Posts: 78773
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Wanted: a plugin to find synchronous zero crossings

Post by steve » Thu Jan 14, 2021 2:12 pm

Image

That image shows the waveform in both tracks "crossing zero". That is what a "zero crossing point" is.


If you only want to find places where samples are exactly zero in both tracks, that will hardly ever occur in "real-world" audio. Other than "generated" audio and "absolute silence", sample values are hardly ever exactly at zero.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Ilya Kuligin
Posts: 7
Joined: Sun Jan 10, 2021 5:23 pm
Operating System: Windows 8 or 8.1

Re: Wanted: a plugin to find synchronous zero crossings

Post by Ilya Kuligin » Thu Jan 14, 2021 4:08 pm

steve wrote:
Thu Jan 14, 2021 2:12 pm
Image

That image shows the waveform in both tracks "crossing zero". That is what a "zero crossing point" is.
So the crossing is anywhere between two nearest dots? Or just where the split line placed? If second than it's hard to guess it manually, with no ability to see the waveform at current scale. That's why I've never used this method.
steve wrote:
Thu Jan 14, 2021 2:12 pm
If you only want to find places where samples are exactly zero in both tracks, that will hardly ever occur in "real-world" audio. Other than "generated" audio and "absolute silence", sample values are hardly ever exactly at zero.
It occurs in every "normal" song many times. You just haven't tried to find it.
My 2nd picture is not photoshop, it's a real 3rd party rock song, I can send you .aup if you want.

steve
Site Admin
Posts: 78773
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Wanted: a plugin to find synchronous zero crossings

Post by steve » Thu Jan 14, 2021 4:49 pm

Ilya Kuligin wrote:
Thu Jan 14, 2021 4:08 pm
It occurs in every "normal" song many times.
Not "exactly" zero.

For simplicity, try this code on a mono track. It adds a label each time a sample is exactly zero.

Code: Select all

(setf labels ())
(do ((val (snd-fetch *track*) (snd-fetch *track*))
     (count 0 (1+ count)))
    ((not val) labels)
  (when (= val 0)
    (push (list (/ count *sound-srate*) "") labels)))

9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 78773
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Wanted: a plugin to find synchronous zero crossings

Post by steve » Thu Jan 14, 2021 6:43 pm

Also, if you zoom in vertically as far as possible, in most cases you will be able to see that samples are not "exactly" zero.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

DVDdoug
Forum Crew
Posts: 8919
Joined: Fri Sep 10, 2010 11:30 pm
Operating System: Windows 10

Re: Wanted: a plugin to find synchronous zero crossings

Post by DVDdoug » Thu Jan 14, 2021 6:48 pm

It occurs in every "normal" song many times. You just haven't tried to find it.
There is NOTHING between digital samples.* The original analog or reconstructed analog will have a true-zero value twice per cycle.

In digital a "zero crossing" is just-before or just-after a polarity (sign) change. (We can't get in-between the digital samples.)

The sample times are essentially random (uncorrelated with the audio) so with 16 bits the odds of hitting zero are about 1 in 65,535. At a sample rate of 44.1kHz you'd expect a true-zero value about every 1.5 seconds on average (assuming mono files and random distribution). Actually the odds are a little better than that because the sample values are skewed toward lower values, and you double your odds with stereo. Or if there is "digital silence" you'll have a bunch of zeros in a row. "Artificially" generated tones could have much better odds depending on the relationship between frequency and sample rate. At 24-bits the odds of zero are about 1 in 16 million (again assuming true randomness and mono). With floating point (or files from MP3) the odds of an exact-zero are nearly zero.

The odds of a visual zero are a LOT higher because Audacity (and your video monitor) doesn't have as much pixel resolution as the audio file.

I don't know the odds of finding left & right zero crossings that match (digitally) but you'll probably have a good feel for it soon!


* If this doesn't make sense take a look at this little tutorial that shows how audio is digitized (quantized in both time & amplitude) and then converted back to analog when played back.

steve
Site Admin
Posts: 78773
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Wanted: a plugin to find synchronous zero crossings

Post by steve » Thu Jan 14, 2021 7:08 pm

DVDdoug wrote:
Thu Jan 14, 2021 6:48 pm
so with 16 bits the odds of hitting zero are about 1 in 65,535.
and for the default 32-bit float format, much, much, much less likely.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Ilya Kuligin
Posts: 7
Joined: Sun Jan 10, 2021 5:23 pm
Operating System: Windows 8 or 8.1

Re: Wanted: a plugin to find synchronous zero crossings

Post by Ilya Kuligin » Fri Jan 15, 2021 9:25 am

steve wrote:
Thu Jan 14, 2021 4:49 pm
For simplicity, try this code on a mono track. It adds a label each time a sample is exactly zero.
Works only when silent before the songs starts. Doesn't show zeros in song selections.
DVDdoug wrote:
Thu Jan 14, 2021 6:48 pm
The odds of a visual zero are a LOT higher because Audacity (and your video monitor) doesn't have as much pixel resolution as the audio file.
Now I got it more or less. Thank you for the explanation.
DVDdoug wrote:
Thu Jan 14, 2021 6:48 pm
I don't know the odds of finding left & right zero crossings that match (digitally)
Perfectionism plus ignorance :)

steve
Site Admin
Posts: 78773
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Wanted: a plugin to find synchronous zero crossings

Post by steve » Fri Jan 15, 2021 10:52 am

Ilya Kuligin wrote:
Fri Jan 15, 2021 9:25 am
Works only when silent before the songs starts. Doesn't show zeros in song selections.
That's because it is only adding labels when the sample is exactly zero.
This line:

Code: Select all

(when (= val 0)
Try changing that to:

Code: Select all

(when (< (abs val) 0.000001)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply