Create Label for Each Clip in Track

I’m looking for a plug-in that will create a label for each clip on a particular track. For example, on track one, I have split the .wav into five pieces. Clicking on the menu item for this hypothetical plug-in it should create a corresponding label on a single label track for each clip.

If this has been built before, I’d love to hear about it.

In the meantime, I’ve been going through the board and found a smattering of create label plug-ins which I can leverage but can’t find anything to just loop through a track and identify each clip/clip boundary. I’m new to Audacity and Nyquist so I might not be using the right nonmenclature.

Any guidance you could give me would be appreciated.

I have gotten a little farther down the road. I can print out the list of clip start/end times and I can add a label but when I combine the two within a loop, it just ignores the list command (no error message). Any insight?

(setf mylist (get 'track 'clips))

(print
(dolist (x mylist)
(print x)
(list (list x “label”) )
(setf i (1+ i))))

Until recently, that would not have been possible.
In “version 4” plug-in code, you can get the times for start and end of audio clips from the TRACKS property list.
For more info, see: http://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference#.2ATRACK.2A

Some info about creating labels: http://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference#Return_Values

Is that enough? Ask if you get stuck.

Crossed posts.

You’re pretty close.
To create the labels, you need to return the specially crafted “list of lists”. You don’t need to print it.

Assuming that you are dealing with mono tracks, “mylist” in your example should look something like this:

(setf mylist (get '*track* 'clips))
(print mylist)

Debug output:

((0 1.9127) (2.84981 5.08344) (5.08344 6.53402) (7.00899 9.99998))

So this is a list containing lists with the start and end times of each clip. In fact, that is very nearly what we want.

To create labels, what we want is:
((0 1.9127 “string”) (2.84981 5.08344 “string”) (5.08344 6.53402 “string”) (7.00899 9.99998 “string”))

Because we want to modify each list within the list, it’s easier to do this with a DO loop rather than DOLIST.
I’ve added some comments to this code, but if you need clarification about it, just ask.

;version 4
(setf label-string "Clip")

(let ((cliplist (get '*track* 'clips))
      labels) ;local variable = NIL
  (do ((i 0 (1+ i)))
      ((not (nth i cliplist)) labels)  ;return value is 'labels'
    ;; create the label and push onto "labels" list
    (push (append (nth i cliplist) (list label-string))
          labels)))

This was awesome! Thank you, Steve.

Did you understand the code? If not, I’d be happy to answer questions.
If you’d be interested in making it into an installable plug-in (that just needs a few more headers adding), and support for stereo tracks (that needs “(get 'track 'clips)” to be handled fully), then I think it could be a useful tool for other and could be uploaded to the Audacity wiki plug-ins page. No problem if not - that was just a thought :wink: