Extend Silences

Share your Audacity/Nyquist plug-ins here, or test drive the latest plug-ins submitted by Audacity users.

After testing a plug-in from this forum, please post feedback for the plug-in author.
steve
Site Admin
Posts: 81229
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Extend Silences

Post by steve » Tue May 22, 2018 3:45 pm

Dashakol wrote:If you have several audios with several of those high threshold segments in them, manual scanning, selecting and running effect for each segment will take a very long time.
Yes, but still much quicker than manually extending each silence.

If there was an option was added to "Extend silences" plug-in for setting a limiting duration and a higher second threshold, how would the plug-in know which parts to use the higher threshold on, and which to use the lower threshold?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Dashakol
Posts: 32
Joined: Tue May 22, 2018 4:23 am
Operating System: Windows 8 or 8.1

Re: Extend Silences

Post by Dashakol » Tue May 22, 2018 6:27 pm

steve wrote: If there was an option was added to "Extend silences" plug-in for setting a limiting duration and a higher second threshold, how would the plug-in know which parts to use the higher threshold on, and which to use the lower threshold?
The same way we do it manually, it should actually run two times. After the first run with the base settings, it should check if some audio segments have been left which are longer than the "limiting duration". Then in the second run it should search within those segments for a "higher threshold" so they could be divided further.

Actually the only additional setting for this plug-in would be the "limiting duration". For example if you wish to have audio segments no more than 3 seconds, that would be your "limiting duration" and if a 7sec segment is left after the first run, the "Extend Silences" plug-in can analyze that segment and find the smallest value as a "higher threshold" which can divide this segment to less than 3sec parts. This threshold may be different for each long segment which is left after the first run.

eg_lim
Posts: 8
Joined: Sat Jan 12, 2019 10:44 pm
Operating System: Windows 10

Re: Extend Silences

Post by eg_lim » Sat Jan 12, 2019 11:36 pm

I want to share my modification of steve's ExtendSilence.ny.
The repeating segment(chunk) feature is added for 'hard' training.
If 'Number of exercise' option is 1, segments won't be repeated.

I used segrep command at final stage, which is very slow. But I don't know the better way because I'm a novice.
So the progress indicator will be meaningless in most cases.
Please be patient to get the result.

This is my first modification of GPL program.
If my header in the source has mistakes, please let me know. I'll correct them.

Thank steve for the original work.
Attachments
ExtendSilenceThenRepeat.ny
modified plug-in
(5.73 KiB) Downloaded 67 times

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

Re: Extend Silences

Post by steve » Sun Jan 13, 2019 3:49 pm

Congratulations eg_lim on completing your first plug-in modification :D

There is one problem that I see with this (modified) plug-in, which is that it requires a silence at the end, otherwise it messes up.
Here's my test track. It has 3 sounds, each of duration 2 seconds, and each of different amplitudes so that they can be easily identified visually. The space between each sound is 3 seconds.

First Track000.png
First Track000.png (8.45 KiB) Viewed 1322 times
If I select the whole thing, including the trailing silence, then it works as expected. With default settings, the result is:

First Track001.png
First Track001.png (8.68 KiB) Viewed 1322 times

However, if there is no silence at the end, or only a short silence at the end, like this:

First Track002.png
First Track002.png (8.45 KiB) Viewed 1322 times
then the result is:
First Track003.png
First Track003.png (8.7 KiB) Viewed 1322 times

Also, it is highly recommended to set your text editor to use spaces rather than tabs, so that indentation is consistent when viewing the code.

There's also quite a few minor things that could be improved, several of which come from improvements to Nyquist in Audacity that were made after "Extend Silences" was written. If you would like me to detail these I'd be happy to do so.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

eg_lim
Posts: 8
Joined: Sat Jan 12, 2019 10:44 pm
Operating System: Windows 10

Re: Extend Silences

Post by eg_lim » Thu Jan 17, 2019 4:33 pm

Thank steve for the review.
I also found that add-dur and add-sil-pc were ignored in repetition.
I was too careless then.

I'm attaching a bug-fixed version which doesn't have tabs any more.
Unfortunately, It takes more time than the previous one does.

p.s. steve, would you please detail the improvements?
Attachments
ExtendSilenceThenRepeat.ny
some bugs fixed...
(6.18 KiB) Downloaded 70 times

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

Re: Extend Silences

Post by steve » Thu Jan 17, 2019 7:25 pm

eg_lim wrote:
Thu Jan 17, 2019 4:33 pm
would you please detail the improvements?
Sure.

Headers (https://wiki.audacityteam.org/wiki/Nyqu ... in_Headers)

;version 3
The current plug-in version is version 4.
Note that version 4 plug-ins use *TRACK* for the audio passed from the track rather than S.

;categories
Categories are no longer used.

;name "Extend Silences, then Repeat..."
I'd suggest using a shorter name. This is the name that will appear in Audacity's Effect menu.
Though some existing Nyquist plug-ins have quite long names, commercial plug-ins tend to have quite short names. When chatting on-line about a plug-in, it quickly becomes tedious to type out a long name. If the plug-in becomes very popular, people will become familiar with the name, whatever it is called, but for new and lesser known plug-ins, a "somewhat descriptive" name can be helpful, but it is "just a name", not a description. Probably not the best idea to go a brief as iZotope do (with names like "Rx7"), so calling it "ESTeR" may be a bit too abbreviated, but it's just a name, so up to you what you call it ;)

;action
Again this is rather verbose. This is what shows in the progress bar window. All that the user needs to know, is that the plug-in is doing something.
;action "Processing..." would be adequate.
;action "ESTeR is busy..." is more fun.
;action "Extending and repeating..." hints at the name of the plug-in.
Again it's your choice, but "Finding silences then inserting more, and repeat the segments" is rather long.

;info
This header is no longer used.


Validating user input:
This is often unnecessary in modern plug-ins. Slider widgets have a fixed range of values, and Audacity will complain if an out of range value is entered.
See: https://wiki.audacityteam.org/wiki/Nyqu ... ce#widgets
and: https://wiki.audacityteam.org/wiki/Nyqu ... ns_Widgets


Style and readability:

Code: Select all

(do ((n 0 (1+ n))
     (snd-pc-total 0)         ; running total of added '% of sound' added.
     (sil-pc-total 0)         ; running total of added '% of silence' added.
     (output (s-rest 0))      ; initialise output.
     (seg-list-reversed '())) ; initialise segment list
    ((= n (1- (length sil-list)))
      (let ((seg-list (reverse seg-list-reversed)))
        (seqrep (i (length seg-list)) (cue (extract-abs (first (nth i seg-list)) (second (nth i seg-list))  output)))))
Eughee, that's horrible ;)

I do tend to over-comment a lot of my plug-ins for the benefit of people learning Nyquist, but doing so is not really recommended. I think the first couple of comments are reasonable, but "initialise output", and "initialise segment list" are pretty self evident once you know that a "DO" loop has local bindings.

But then we come to the horrible bit - the return value:

Code: Select all

(let ((seg-list (reverse seg-list-reversed))) (seqrep (i (length seg-list)) (cue (extract-abs (first (nth i seg-list)) (second (nth i seg-list))  output)))))
Isn't this more readable:

Code: Select all

(do ((n 0 (1+ n))
     (snd-pc-total 0)   ; total "sound %"
     (sil-pc-total 0)   ; total "silence %"
     (output (s-rest 0))
     (seg-list '())
     (count (1- (length sil-list))))
    ((= n count) (build-output outpt seg-list))
and then define the "build-output" function somewhere nearby.

Defining short functions that do one thing each, aids readability and makes debugging much easier.


Same thing here:

Code: Select all

(dotimes (i repeat-N) (push (list segment-start (+ segment-start section-dur pause snd-sil-len snd-sel-len)) seg-list-reversed))
or:

Code: Select all

(dotimes (i repeat-N)
  (setf end-time (+ segment-start
                    section-dur pause
                    snd-sil-len
                    snd-sel-len))
  (setf seg-pair (list segment-start end-time) )
  (push seg-pair seg-list))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Extend Silences

Post by steve » Thu Jan 17, 2019 7:33 pm

Another bit:

Code: Select all

;;; For stereo tracks, use maximum of L/R channels
(defun mono (s-in)
  (if (arrayp s-in)               ; if stereo,
      (s-max                      ; absolute max of channels.
        (snd-abs (aref s-in 0))
        (snd-abs (aref s-in 1)))
      (snd-abs s-in)))            ; else absolute sample values.
You don't actually need to do SND-ABS for S-IN, because SND-AVG with OP-PEAK uses absolute sample values.
It's enough to just do:

Code: Select all

;;; For stereo tracks, use maximum of L/R channels
(defun mono (s-in)
  (if (arrayp s-in)
      (s-max (snd-abs (aref s-in 0))
             (snd-abs (aref s-in 1)))
      s-in))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

eg_lim
Posts: 8
Joined: Sat Jan 12, 2019 10:44 pm
Operating System: Windows 10

Re: Extend Silences

Post by eg_lim » Sun Jan 20, 2019 6:55 am

This is a nyquist plug-in version 4 of the former ExtendSilenceThenRepeat.ny.
'ESTeR...' you suggested sounds good, so I changed its name.

Using *track* instead of s resulted in some changes.

You reminded me many things which I have forgotten in programming.
Thank you very much, steve.
Attachments
ESTeR.ny
nyquist plug-in version 4 of ExtendSilenceThenRepeat.ny
(6.34 KiB) Downloaded 59 times

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

Re: Extend Silences

Post by steve » Sun Jan 20, 2019 9:16 pm

I suspect that there may be a way to make this effect very much faster as a "Nyquist-Macro", using new features in Audacity 2.3.1 (due for release in February). There is some information about Nyquist-Macros in the "2.3.1 alpha manual" https://alphamanual.audacityteam.org/man/Nyquist-Macros

I don't have a lot of time to work on this right now - I'm still in the process of documenting these new features. I'll try to post some relevant snippets over the next week.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Extend Silences

Post by steve » Tue Jan 22, 2019 12:16 am

Here's a "proof of concept" for ESTeR as a Nyquist-Macro. Sadly it isn't "much" faster. I'm not too disappointed by that as I think the speed of the pure Nyquist versions are pretty good, and this is a little bit quicker (on my machine).
I've been working on Audacity 2.3.1 alpha (2.3.1 is due for release in February). I've not tested on 2.3.0 but I suspect it will not work on any version earlier than 2.3.1.

I've left some debugging "print" statements in, but commented out. Uncommenting them may help with debugging / seeing how the plug-in works.
There are also a few other explanatory comments, and some "TODO's" that would need to be addressed to make this a release quality plug-in.

Despite these shortcomings, I thought you might be interested as it demonstrates several new features.
ESTeR3.ny
(4.6 KiB) Downloaded 72 times
Oh yes, and I've handled space at the end a little differently from your version. This version sets the minimum space after the last sound equal to the length of the last sound.

I'll be happy to answer any questions you may have about the new stuff.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply