Nyquist - Labels looped selection and apply effect [SOLVED]

Hi there !

I got a file opened, labels created, label track all selected.
I would like to make a script that will select labels and aply effect (FadeOut), one after the other, till the end of file.
Its a for a narrated audio book, I need to clean breath and others disturbing noises that are not so badly detected by Labels “in between sound” process but create undreds of Labels. I cant process them all manualy… I’d be dead before I finish ! :wink:
A simple script that select first label, apply fade out, then select the next one…and so on till the end !

For the moment, I try this, but doesn’t work at all :

;debugflags trace

(defun fadeout ()
  (let ((labels (second (first (aud-get-info "Labels")))))
    (dotimes (i (length labels))
      (aud-do "SelectNextLabel:")
      (aud-do "FadeOut:"))))

Thanx in advance for helping tips. :wink:

This should work:

;type tool
;debugflags trace

(defun fadeout ()
  (aud-do "CursProjectStart:")
  (let ((labels (second (first (aud-get-info "Labels")))))
    (dotimes (i (length labels))
      (aud-do "MoveToNextLabel:")
      (aud-do "FadeOut:")))
  "")

(fadeout)

Here is… Magic Steeve !!! :smiley:

I’ve been spending hours and hours to try to find this… ;(
That works perfectly !!!
A big big big THANX to you !!!


I’ve tried this now, cause I want 4 FadeOut in a raw :

;type tool
;debugflags trace

(defun fadeout ()
  (aud-do "CursProjectStart:")
  (let ((labels (second (first (aud-get-info "Labels")))))
    (dotimes (i (length labels))
      (aud-do "MoveToNextLabel:")
      (aud-do "FadeOut:")))
  "")

(fadeout)
(fadeout)
(fadeout)
(fadeout)

And it works too !
Good bye hugly breathes !
So nice, Thanx !

I’m gonna see what happen if I replace all the words “FadeOut” with another function, like “Silence” for example…
…what if I insert it into a Macro… Etc…
Anyway, I think it would be interesting to have different function batch on labels for a lot of people…
I’ll give feed back. :wink:

You could provide a menu with options to select which effect will be used. Something like (I’m just typing, so these commands might not be exactly correct):

;type tool
;version 4

;control effect "Select Effect" choice "Fade-In,Fade-out,Amplify +6 dB,Amplify -6dB" 0

... main code...

  (case effect
    (0 (aud-do "FadeIn:"))
    (0 (aud-do "FadeOut:"))
    (0 (aud-do "Amplify: Ratio=2"))
    (0 (aud-do "Amplify: Ratio=0.5")))

Mmm… sounds good… But may prompt, and then interrupt batching… Isn’t it ?

Well. For the moment I’m trying to insert that code in a macro… And it works, yeah !
But it scans the whole file four times (doing FadeOut on each). I think it takes more time than doing four FadeOut on each selection at the first pass.
So I try to optimize code… But doesn’t works ! :wink:

;type tool
;debugflags trace

(defun fadeout ()
  (aud-do "CursProjectStart:")
  (let ((labels (second (first (aud-get-info "Labels")))))
    (dotimes (i (length labels))
      (aud-do "MoveToNextLabel:")
         (dotimes (i (length 4)
           (aud-do "FadeOut:")))
  "")

(fadeout)

DEBUG :

nyx_error retourné par Console Nyquist.
error: unexpected EOF
Function: #<Subr-(null): #0000022D3E810868>
Arguments:
  #<File-Stream: #0000022D3C2FEF28>
  #\(
Function: #<Subr-(null): #0000022D3E810868>
Arguments:
  #<File-Stream: #0000022D3C2FEF28>
  #\(
1>

I think I must replace “(dotimes (i (length 4)” by something else, but don’t know what it is… I’m a real noob ! I do sounds, but not coding ! :smiley:

“EOF” means “End of form”, which means that it’s got to the end of the script before expected, which indicates that you’ve most likely missed a closing “)” or missed a quote. In this case you’re short of two closing parentheses.

If you’ve not got one already, get yourself a text editor that has “parentheses matching” (such as “NotePad++”).

Hint: Try running this in the Nyquist Prompt with the “Debug” button:

(dotimes (i 4)
  (print i))

Probably.

Note also that Audacity is quite slow running AUD-DO commands (especially on Linux for some reason). The actual processing time should be the same as when applying an effect manually, but Audacity takes some time between getting the AUD-DO command from Nyquist and starting the command that has been passed.

When running a plug-in that has controls, in a macro, you need to enter settings for the controls when you create the macro. The plug-in is not displayed when run from a macro.

Ok, no error.
Debug is :
0
1
2
3
…and so on.

But It doesn’t apply any “FadeOut” at all. (What ?!)

;type tool
;debugflags trace

(defun fadeout ()
  (aud-do "CursProjectStart:")
  (let ((labels (second (first (aud-get-info "Labels")))))
    (dotimes (i (length labels))
      (aud-do "MoveToNextLabel:")
        (dotimes (i 4)
          (Print i))
           (aud-do "FadeOut:")))
  "")

(fadeout)

…even if I remove "(print i)…

Look at your parentheses.

…My bad : It does. But only once !

Yes, got it !!! WORKS !!! :smiley:

Here it is :

;type tool
;debugflags trace

(defun fadeout ()
  (aud-do "CursProjectStart:")
  (let ((labels (second (first (aud-get-info "Labels")))))
    (dotimes (i (length labels))
      (aud-do "MoveToNextLabel:")
        (dotimes (i 4)
           (aud-do "FadeOut:"))))
  "")

(fadeout)

It runs just a very little quicker, but anyway, looks more professional ! :smiley:
Now to be perfect, this script should apply “FadeOut”, four times, on the first 99% of the selection, then “FadeIn”, one time on the last 1%.
And we’re done. :stuck_out_tongue:

For your information:

The reason that you need to use “length” in the line:

(dotimes (i (length labels))

is because “labels” is a list of labels. You want the loop to run once for each label.
(length labels) returns the length of the list, which is the “number of labels in the list”.


On the other hand, “(length 4)” doesn’t really make much sense as “4” is an integer. In Nyquist, integers don’t have a “length” property, so it returns an error:

error: bad argument type - 4

Have you worked out how you are going to do that?

If all of the labels are a similar length, then it would probably be easiest to make the fade-in section a fixed length, such as “0.1 seconds”.

Very interresting, thank you Steve. I pay my respect to your knowledge. :wink:

…And…

You’re right !
That makes no sense to select a percentage, as no label has the same lenght. :unamused:
It would be better to select a fixed duration like 50ms for example.
Then I got a problem about the order of processing… Who from the chicken and the egg, has appeared first ?
I mean, if I do “FadeOut” first on the whole selection, it will erase the end. No material to Fade In.
If I do “FadeIn” first, it’ll be erased by “FadeOut” in second. Same result. :nerd:
Now if I can select from the start of the current label to the end less 50 ms, FadeOut.
And then select from the end of the current label less 50 ms to the end, Fade In.
I’d be back in buisness ! :slight_smile:

Don’t you think so ?

Yes, that’s what I had in mind.

An example without the looping (I’ll leave that for you :wink:), something like:

;type tool
(aud-do "CursProjectStart:")
(aud-do "MoveToNextLabel:")
(aud-do "SelectTime: Start=0 End=-0.5 RelativeTo=\"Selection\"")
(aud-do "FadeOut:")
(aud-do "SelectTime: Start=0 End=-0.5 RelativeTo=\"SelectionEnd\"")
(aud-do "FadeIn:")
(aud-do "MoveToNextLabel:")
...

UN-BE-LIE-VA-BLE !! :open_mouth:

IT WORKS !!!

The best is that you make me understand what I’m doing. Maximum gratefullness… :wink:

I just had to change a dust of thing (and install NotePad++ by the way… :smiley: ).

Here It Is :

;type tool
;debugflags trace

(defun fadeout ()
  (aud-do "CursProjectStart:")
  (let ((labels (second (first (aud-get-info "Labels")))))
    (dotimes (i (length labels))
      (aud-do "MoveToNextLabel:")
	  (aud-do "SelectTime: Start=0 End=-0.05 RelativeTo=\"Selection\"")
        (dotimes (i 4)
           (aud-do "FadeOut:"))
      (aud-do "SelectTime: Start=-0.05 End=0 RelativeTo=\"SelectionEnd\"")
           (aud-do "FadeIn:")))
  "")

(fadeout)

What else ?
“I willl see wich chalenge I’m gonna generate for you… hin hin hin…” :smiling_imp:

For the moment, I’m gonna insert that in my special big “Narrator Editing Suite Macro” and share it with the world.
Maybe some kind of desperate editor, as I was yesterday, will come around and be happy to find The Answer… Mou-ha-ha-ha ! :smiling_imp:

:wink:

Congratulations :nerd:

Super :slight_smile:


To that end, I’ll close this topic so that “The Answer” doesn’t get buried under other posts.
Feel free to open a new topic when you have more questions.