Page 2 of 2

Re: Wanted: a plugin to find synchronous zero crossings

Posted: Thu Jan 14, 2021 1:59 pm
by Ilya Kuligin
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 152 times
What I need
ok.png
ok.png (3.11 KiB) Viewed 152 times

Re: Wanted: a plugin to find synchronous zero crossings

Posted: Thu Jan 14, 2021 2:12 pm
by steve
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.

Re: Wanted: a plugin to find synchronous zero crossings

Posted: Thu Jan 14, 2021 4:08 pm
by Ilya Kuligin
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.

Re: Wanted: a plugin to find synchronous zero crossings

Posted: Thu Jan 14, 2021 4:49 pm
by steve
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)))


Re: Wanted: a plugin to find synchronous zero crossings

Posted: Thu Jan 14, 2021 6:43 pm
by steve
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.

Re: Wanted: a plugin to find synchronous zero crossings

Posted: Thu Jan 14, 2021 6:48 pm
by DVDdoug
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.

Re: Wanted: a plugin to find synchronous zero crossings

Posted: Thu Jan 14, 2021 7:08 pm
by steve
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.

Re: Wanted: a plugin to find synchronous zero crossings

Posted: Fri Jan 15, 2021 9:25 am
by Ilya Kuligin
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 :)

Re: Wanted: a plugin to find synchronous zero crossings

Posted: Fri Jan 15, 2021 10:52 am
by steve
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)