Regular Interval Labels - By Sample Length?

I’m hoping to hack the Regular Interval Labels plug-in.

I am trying to recover corrupted wav files. The original recording had 8 mono channels. What I have recovered so far is now a single wav file comprised of hours worth of audio whereby there is a chunk of channel 1 followed by a chunk of channel 2, etc. to channel 8 and then back to channel 1. Each chunk is only a couple of seconds. The file is many hours long. So, a lot of chunks.

Each segment is exactly 98304 samples long. The Regular Interval Labels plug-in is exactly what I need to split it up, except it can only define segment lengths in seconds. I have tried to convert from samples to seconds in order to use the plug-in as is (the file is encoded in 44.1KHz and 98304 samples; 98304/44100 is about 2.22911564 seconds). Unfortunately, the plug-in does not appear to consider more than 2 digits after the decimal and so is not precise enough.

What I’m wondering is how difficult it would be to modify the plug-in to allow the interval to be designated in samples instead of or in addition to seconds? I have no experience programming plug-ins.


Audacity tends to slow down quite badly if there are a vast number of labels, so you will probably need to work in sections rather than all in one go. I’d guess that you should be OK with with 1000 labels, so this code sets a limit of 1000 labels (line 3).

This code can be run in the Nyquist prompt. I think it is fairly self explanatory, but feel free to ask questions:

(setq num-samples 98304)
(setq step (/ num-samples *sound-srate*))
(setq max-labels 1000)

(setf labels ()) ; initialise an empty list
(do* ((i 0 (1+ i)))
     ((or (> i (/ len num-samples))(= i max-labels)) labels)
  (push (list (* i step)(* (1+ i) step) (format nil "~a" (1+ i)))

Thank you so much for writing that code for me! I’ll give it a go. :smiley: