setting envellope control point using nyquest

I know nothing about nyquist, apart from the name and it’s existence :slight_smile:
But I would like to be able to set a whole bunch of envelope tool control point over the length of an audio track.
I found the following on this forum, and now I need some help modifying this to do what I want. Thanks.

;version 4
;type tool

(setf time 0)   ;time of label relative to start of the selection
(setf val 0.5)  ;envelop point value

(let ((start (get '*selection* 'start)))
  (setf command (format nil
                        "SetEnvelope: Time=~s Value=~s"
                        (+ start time)
                        val))
  (aud-do command))

Did you get it to work? (in the Nyquist Prompt effect)


How many, where, and at what level?

The script I posted works in the prompt.
As for the amount of control point, Don’t know what works best. But I think something like, one control point every 3 seconds for the complete length of the track.

Select the track that you want to add control points to, then run this code:

;version 4
;type tool

(setf interval 3.0) ;time interval between points
(setf val 0.5)  ;envelop point value


;; Add envelope points to selected audio.
(let ((start (get '*selection* 'start))
      (end (get '*selection* 'end)))
  (setf num (truncate (/ (- end start) interval)))
  (dotimes (i num)
    (setf command (format nil
                          "SetEnvelope: Time=~s Value=~s"
                          (+ start (* i interval))
                          val))
    (aud-do command)))

I don’t understand why this is useful, given that clicking with the envelope tool adds an envelope point, but it does what you asked for.

To be honest I’m not sure about the usefulness either :slight_smile:
But I’m cleaning up some old video’s with a lot of audio noise.
And after noise removal and normalisation I go though the whole track using the envelope tool, and placing all those control points is a bit tedious.

Your code worked perfectly :slight_smile: I just had to change the envelope point value to 1, so it would not effect the already normalised audio level.
I think this will save me some time, so thanks a lot for your help.
(You know what would make this even more useful, it the control points could be place and the start and end of sentences.
But something like that would probably overload my computer. It already took longer than expected to apply this code :slight_smile:

Quick follow up question, do you perhaps know how I can easily select a bunch of control points and delete them?

Isn’t it just as quick to click with the envelope tool to create an envelope point, since you need to click to set the height of the point. :confused:


This is for reducing the noise level between sentences? As I wrote in your other topic, I’d make a backup copy of the track, and then use the Noise Gate effect rather than using envelopes.


At present, you can’t.
You can remove all envelope points in a track, or you can drag them off one at a time.

In Audacity 3.x it will be possible to make a plug-in to delete all envelope points that are in a selected region, but it would be quite slow if the track has a lot of envelope points. The plug-in would work by making a note of all of the envelope points in the track, removing all envelope points, then replacing the envelope points that are outside of the selected region. A future version of Audacity may be better in this respect.

Usually I start on the left side of the audio file, placing control point one at the time, and work my way to the right.
I spent a lot of time placing the control point at the same height before adjusting them. I know it doesn’t matter all that much, it’s probably an o.c.b. thing. But having the control points placed automatically I’m sure I won’t end up lower or higher on the right end of the track.
It’s not so much for noise removal but for other speaking noises. Breathing and such. I tried to completely remove those sounds using ctrl-l but that sounds weird. Replacing it with some noise it tedious. So going though the audio with the envelope tool gets me the best result.
Would it be possible to use Nyquist to remove the control points for a selection?

This plug-in requires Audacity 3.0.0 or later:
DeleteEnvelope.ny (3.43 KB)

I upgraded to v3.0.0 without problems. Although for some reason lots of scripts are installed in two languages. But that is probably the result of the original Dutch language when my computer was installed. No problem, everything seems to work just fine. Perhaps a bit slower, maybe I just need a computer upgrade.
It took a while before I figured out where I would find this delete script. I kept looking for it under the effect pull-down menu. But it was just under tools. Anyway it works as expected and it is just what I needed :slight_smile: Thanks a lot!

Steve, Thanks again for your help on the Nyquist scripts. They worked great for me.
I made a video about how I use Audacity and Videopad to improve the audio quality on some of my old youtube videos.
I thought you might like it :)There’s no need to watch, I’m not posting this for a hand full of extra views.
But I am looking for tips and trick on how I can improve my result :slight_smile:

https://youtu.be/FGvr4z84WnA

Rather than running that first Nyquist code with the Nyquist Prompt, you could convert it into a plug-in and install it.

To convert it into a plug-in, you just need to add a few “header comments” at the top of the script, and save it as a plain text file. Then change the file extension from “.txt” to “.ny”.

See here for information about plug-in headers: https://wiki.audacityteam.org/wiki/Nyquist_Plug-in_Headers
You must include all of the “Required plug-in headers” (https://wiki.audacityteam.org/wiki/Nyquist_Plug-in_Headers#required_headers)

Notice that the code that I posted already has two of the required headers:

;version 4
;type tool

The first two line of actual code:

(setf interval 3.0) ;time interval between points
(setf val 0.5)  ;envelop point value

could be converted to slider controls like this:

;control interval "Time between points" float "" 3 0.1 10
;control val "Point value" float "" 1 0 2

More info about slider widgets: https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference#widgets