# Zero Crossing detection

**URL:** <https://forum.audacityteam.org/t/zero-crossing-detection/26237>\
**Category:** Nyquist\
**Created:** [September 10, 2012, 7:51pm UTC](https://forum.audacityteam.org/t/zero-crossing-detection/26237 "2012-09-10T19:51:54Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Robert\_J\_H](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@Robert\_J\_H](https://forum.audacityteam.org/u/Robert_J_H)\
**Post date:** [September 10, 2012, 7:51pm UTC](https://forum.audacityteam.org/t/zero-crossing-detection/26237/1 "2012-09-10T19:51:54Z")

</div>

That’s the fundamental code snippet, which will return a list of all zero (to positive value) crossings. It’s up to you to build a stretch routine or whatsoever from it.  
My main goal was to implement it in the “Append Tracks Deluxe” plug-in. Eventually it should produce the sound in between the played transitions, just as if you would press a fast forward button, but without a pitch-change (a replacement for pitchift). But the current routine which puts all together is much too slow and thus I won’t post it.

```plaintext
;;indexing
(Defun split (sig size)
(let* ((sr (snd-srate sig)) (split-list (list 0))
(single (snd-from-array 0 sr (vector (/ (float size))))) 
(zero (snd-from-array 0 sr #(0)))
(index (mult sr (integrate (trigger sig single))))
(last (sref (sound index) (* (- (snd-length index ny:all) 
1) (/ sr)))))
(display "" last)
(dotimes (num (truncate last))
(setf split-list (cons (float (sref-inverse index (1+ num))) split-list)))
(reverse (cons (second (snd-extent sig ny:all)) split-list))
)); end split

```

Size is the number of periods that are skipped i.e. every “size”-th time will be returned. Have fun.

---

_[View the full topic](https://forum.audacityteam.org/t/zero-crossing-detection/26237)._
