increasing accuracy of Silence Marker

Using Nyquist scripts in Audacity.
Post and download new plug-ins.

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

increasing accuracy of Silence Marker

Permanent link to this post Posted by Edgar » Thu Nov 27, 2014 8:09 pm

SilenceMarker1.2
Code: Select all
;Reducing the samples per second should improve the performance and decrease
;the accuracy of the labels. Increasing the samples per second will do the
;opposite. The more samples checked, the longer it takes. The more samples
;checked, the more precisely the program can place the silence labels.
;my-srate-ratio determines the number of samples in my-s. Set the number after (snd-srate s)
;higher to increase the number of samples.

(defun my-s (s-in)
 (setq my-srate-ratio (truncate (/ (snd-srate (mono-s s-in))(/ *sound-srate* 100))))
 (snd-avg (mono-s s-in) my-srate-ratio my-srate-ratio OP-PEAK)
)

Set the number after (snd-srate s) higher to increase the number of samples.

This plug-in is very fast - on my machine, on the order of four seconds per hour of audio at 44100. If it were more accurate and took twice as long I would be satisfied with the time consumption. How do I "increase the number of samples"?

You and I have both customized this so I have attached the entire plug-in source.
Attachments
SilenceMarker1.2.zip
(2.25 KiB) Downloaded 53 times
-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1490
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by steve » Thu Nov 27, 2014 8:21 pm

There's quite a lot that should be updated in this plugin, so I'd not suggest spending too much time on it (unless you want to rewrite it from scratch).

For personal use, just try different values for "my-srate-ratio".

Try changing the line:
Code: Select all
 (setq my-srate-ratio (truncate (/ (snd-srate (mono-s s-in))(/ *sound-srate* 100))))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45394
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by Edgar » Thu Nov 27, 2014 8:28 pm

steve wrote:There's quite a lot that should be updated in this plugin, so I'd not suggest spending too much time on it (unless you want to rewrite it from scratch).

For personal use, just try different values for "my-srate-ratio".

Try changing the line:
Code: Select all
 (setq my-srate-ratio (truncate (/ (snd-srate (mono-s s-in))(/ *sound-srate* 100))))

I may rewrite it in C++ as trying to read the lisp is giving me headaches. How should I change that line?
Code: Select all
 (setq my-srate-ratio XXX)

If so, what are reasonable minimum and maximum values of XXX? Otherwise, should I be changing some of those variables (I tried changing the "100": 500, 3000, 30,000 - none of these values had any effect on execution time nor accuracy.
-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1490
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by steve » Fri Nov 28, 2014 12:55 am

Try this in the Nyquist prompt.
Note: if you're using 2.1.0 alpha, enable "legacy" mode.
The first three lines are for user input. If you want this as a plugin, make those into "controls".

Code: Select all
(setf threshold -20)  ;dB
(setf min-length 2.0) ;seconds
(setf label-text "Silence")  ;the label text

;; --------- End of user input -------------

(setf threshold (db-to-linear threshold))
(setf minlen (* min-length *sound-srate*))

(if (arrayp s)
    (setf s (s-max (s-abs (aref s 0))
                   (s-abs (aref s 1)))))

(do ((val (snd-fetch s)(snd-fetch s))
     (labels ())
     (count 0 (1+ count))
     (start 0)
     (silcount 0))
    ((not val) (if (> (length labels) 0)
                   labels
                   "No silence found."))
  (cond
    ((< (abs val) threshold)
      (if (= silcount 0)
          (setf start count))
      (incf silcount))
    ((> silcount minlen)
      (push
        (list (/ start *sound-srate*)
              (/ count *sound-srate*)
              label-text)
        labels)
      (setf silcount 0))
    (T (setf silcount 0))))

This is rather slow on my machine, taking about 1:40 for a 10:00 mono track, but it's accurate.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45394
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by Edgar » Fri Nov 28, 2014 1:46 am

Very strange - Audacity 2.0.5 (did not know how to use "legacy" mode), I tried this on a '70s era Aerosmith vinyl; there was at least three seconds of almost-silence between tracks. The result was no labels created and a mess of the audio:
Aero.png
Aero.png (24.18 KiB) Viewed 1320 times
-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1490
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by steve » Fri Nov 28, 2014 2:03 am

Edgar wrote:did not know how to use "legacy" mode

In Audacity 2.1.0 alpha, there is a checkbox near the bottom of the Nyquist Prompt effect: "Use legacy (version 3) syntax".
To run "version 1, 2 or 3" code in the Nyquist Prompt effect, that checkbox must be selected.

The "mess" with the audio is that it has been "rectified" (sample value converted to absolute values, so negative value samples become positive).
Are you sure that you copied the entire code (33 lines)?
If you did, please try it with the Debug button and post any debug info that there may be.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45394
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by steve » Fri Nov 28, 2014 2:06 am

Oops, hang on a second - there seems to be a problem. The code on the forum is not the same as the code that I posted :shock: :?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45394
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by Edgar » Fri Nov 28, 2014 2:07 am

-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1490
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by steve » Fri Nov 28, 2014 2:15 am

Well I've not seen that happen before.
The code on the forum had an extra line break :o
I've reposted it, and I think it's OK now.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45394
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: increasing accuracy of Silence Marker

Permanent link to this post Posted by steve » Fri Nov 28, 2014 2:52 am

Very peculiar, but here you can see the difference between my original code, and what I copied from the post (scroll down to the bottom of the image):

error.gif
error.gif (86.37 KiB) Viewed 1320 times


Anyway, I've checked the reposted code and it's working.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45394
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Next

Return to Nyquist



Who is online

Users browsing this forum: No registered users and 3 guests