How to Align multiple tracks in ALIGN TRACKS Plug in

Hi, I’m using windows 10 and Audacity version 3.4.2 32 bits. I’ve recently installed a Nyquist plug in called Align Tracks. Align Tracks | AudioNyq

And noticed that I’m only able to select up to 2 tracks at a time. I wished to do multiple tracks, up to 4 at least. I heard it’s possible to create a keyboard shortcut with it. However I’m not very use to using/modifying macros or anything in fact. If anyone could show me step by step what I can do that would be much appreciated.

Say you have 4 tracks, and all tracks have a synchronisation marker (clapperboard sound) at the beginning (as required by the plug-in:

  1. Select tracks 1 and 2.
  2. Apply the Align Tracks effect.
  3. Ctrl + Click on the “Select” button of track 2 to de-select that track.
  4. Ctrl + Click on the “Select” button of track 3 to select track 3 (in addition to the already selected track 1).
  5. Ctrl + R to repeat the Align Tracks effect.

Repeats steps 3 to 5 for the remaining tracks.

Is it possible to make a command or something that can Align all the tracks instead?

Yep that’s the old way I’ve been doing, however with the plug in it was more automatic and easier. For my work I need it to be more automatic and faster, having it be able to auto sync/align multiple tracks at once. Hence, why I wanted to see if theres a way to do it all at once instead of individually selecting pairs.

The plug-in could be modified to support multiple tracks. However, modifying the plug-in would require time and effort. You already have a fairly efficient workflow as I described in my previous post, so I wonder how much time and effort you are willing to invest.

I’m willing to invest all the time needed. It seems like I’m the only one at my workplace that has the time to do this. I already tried modifying the code beforehand but it doesn’t seem to work. So how should I go about this?

In the main function:

(defun main (sig)
  (let ((tracknum (get '*track* 'index))
    (when (> tracknum 2)
      (throw 'err "Second selected track adjusted.\nLater tracks ignored."))
    (case tracknum
      (1 (setf count (startsample sig))
         (if count
             ; Convert to time so that mixed sample rates will work.
             (putprop '*scratch* (/ count *sound-srate*) 'id)
             (throw 'err "Threshold detection level was not exceeded."))
      (2 (setf count (startsample (snd-copy sig)))
         (setf firstcount (get '*scratch* 'id))
         (remprop '*scratch* 'id)
         (unless count
            (throw 'err "Threshold detection level was not exceeded."))
          ; Convert firstcount back to samples.
          (setf firstcount (* firstcount *sound-srate*))
          (if (> count firstcount)
              (trim (- count firstcount))
              (pad (- firstcount count)))))))

Notice the lines:

    (when (> tracknum 2)
      (throw 'err "Second selected track adjusted.\nLater tracks ignored."))

That tells Nyquist to throw an error if more than 2 tracks are selected. Those lines need to be removed for it to support more than 2 selected tracks.

Also notice the conditional:

    (case tracknum
      (1 ...
      (2 ...

That is telling Nyquist to do one thing for the first track, and something else for the second track.
For the first track, you want Nyquist to calculate the synchronisation start time. For all other selected tracks you will want to adjust the tracks to start at the same synchronisation point.

I don’t have time to work on this more right now. See how far you can get and I’ll be back later to see if you need more help.

1 Like

I’ve posted a new version of the plug-in for aligning multiple tracks. Aligning Multiple Tracks | AudioNyq

1 Like

Thank you so much I really appreciate the help. I wanna learn more about this programming language. Is it just LISP?

“LISP” is a big family (many different dialects).
The Nyquist language is an extension of XLISP, which is a small and extendable version of Lisp.
Audacity has a slightly modified version of Nyquist, modified specifically for Audacity.

You can find all of the recommended documentation on my blog. (Unfortunately the website is no longer available, but can be accessed from the Internet Archive (Wayback Machine) - the link is on my blog.

I assume that you use Windows, in which case I recommend NotePad++ for editing Nyquist code (it’s free).

You may find it interesting to compare the code of the two versions of the Align Tracks plug-ins. The required changes turned out to be quite small.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.