Why Are New Tracks Always Added to the End? You Should be Able to Add Them After the Selected Track

Inspired by trackmove.ny, I made a nyquist plug-in that:

  1. identifies the current track (call it track “a”)
  2. adds a label track and places it directly below that track
  3. moves focus back to track “a”.

I’m not sure if there are any differences to how plug-ins apply based on audacity version, but I’m running version 3.0.2 on linux, installed from the ppa.

A few notes:

  1. The plug-in picks “current track” based on the track that has focus–in particular, this means that if you:
  2. select some audio on track 1
  3. manually hit the down arrow to move focus to track 2
  4. run this plug-in
    then the plug-in will
  5. Place the new label track directly below track 2
  6. and then select the portion of track 2 matching the range of track 1 that you originally had selected
  7. The plug-in doesn’t try to do any sort of special handling if your selection spans multiple track–the plug-in will still:
  8. pick the one track that has focus (if you selected with the mouse from top to bottom, that’ll be the last track of the selection, if you selected from bottom to top, it’ll be the top track of the selection)
  9. make a label track directly below that one track
  10. and then, because it only knows about that one track, put the focus back there, de-selecting the other tracks.

I don’t understand nyquist well enough to address these limitations, and this is sufficient for my purposes, but if anyone else does want to address this, go for it! It is lines 47-50 that place the focus back on the original track, and the function get-focus-track that picks which track to put the label track directly below.


To make a similar plug-in that adds any other kind of track, you can change:

  1. Line 4:
;name "Add Labels Below"

This is the line that sets the display name you’ll see when you want to apply the plug-in in audacity (or use it as a step in a macro).
2. Line 40:

    (aud-do "NewLabelTrack:")

This is the line that makes a new label track. You can replace “NewLabelTrack:” with any of the other scripting ids under “Tracks: Add New” in the scripting reference.
3. The file name, so you’ll be able to recognize it in the enable/disable add-ons menu after installation.
add-labels-below.ny (1.64 KB)