Labels Export: using samples data instead of seconds

I searched for this without any luck.
I’m looking for a way to export the data contained in each label but instead of ‘Seconds’ (which is what ‘Export labels’ does) I need the ‘Samples’ information, is that possible?
This could be pretty useful for some sampling programs that requires the start and end info of each slice of sound.

Thanks in advance.


For obvious reasons, “Export Labels” exports in the same format as used by “Import Labels”.

To export labels using sample values you would need to write your own plug-in.
There’s a lot of information about writing Nyquist plug-ins here:

To read labels, you will need to use Nyquist macro commands (See: as that’s the only way that Nyquist can access labels.

One problem is that labels are not audio, so they don’t have a sample rate. Audacity supports having multiple audio tracks with different sample rates, so there is no clear cut answer to which sample rate to use. I think the most obvious solution would be to use the “Project Rate”, which is the sample rate used for playing, recording and exporting.

Here’s an example of how to get label times in samples.
This code may be run in the Nyquist Prompt ( and will display the data, which you can then copy to a file.
Outputting directly to a file is a bit tricky, but can be done using the “File-Button” widget (see: See the code for “Sample Data Export” for an example:

;type analyze
;debugflags trace

(let ((txt "")
      (rate (get '*project* 'rate))
      (label-tracks (aud-get-info "labels")))
  (dolist (labels label-tracks)
    (setf labels (second labels))
    (dolist (label labels)
      (setf txt (format nil "~a~a\t~a\t~a~%"
                        (round (* rate (first label)))
                        (round (* rate (second label)))
                        (third label)))))
  (format t txt)