Regular Interval Labels - By Sample Length?

Using Nyquist scripts in Audacity.
Post and download new plug-ins.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
surgderm
Posts: 4
Joined: Sat Feb 21, 2015 11:53 pm
Operating System: Please select

Regular Interval Labels - By Sample Length?

Post by surgderm » Sun Feb 22, 2015 4:21 am

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.

Thoughts?

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Regular Interval Labels - By Sample Length?

Post by steve » Sun Feb 22, 2015 5:31 am

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:

Code: Select all

(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)))
        labels))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

surgderm
Posts: 4
Joined: Sat Feb 21, 2015 11:53 pm
Operating System: Please select

Re: Regular Interval Labels - By Sample Length?

Post by surgderm » Wed Feb 25, 2015 4:23 am

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

Post Reply