Is there a master volume envelope?

Hello,
i’m working on a multitrack recording. I want to mute the first 2 seconds of all tracks so there is a little silence before the music starts. some of the tracks have a little noise (me adjusting my chair, taking a breath, etc) that I want to mute all of that, for all tracks
the only way I can see to do this is to go into each track and use the envelope tool, one at a time.
is there an easier way?
thanks
gary in vermont

also related, I’m looking for a way to trim all tracks at once?

To apply

If you’re feeling adventurous, you can try running this code in the Nyquist Prompt tool:

;version 4
;type tool

(setf v-list (get '*audacity*' version))
(format t "Version ~a.~a.~a" (first v-list)(second v-list)(third v-list))
(setf good-ver
  (if (and (= (first v-list) 2)
            (= (second v-list) 3)
            (>= (third v-list) 0))
      t nil))

(setf end (get '*selection* 'end))

(defun do-mute ()
  (dotimes (i (get '*project* 'tracks))
    (aud-do
      (format nil "SelectTracks: Track=~a Mode=Set" i))
    (aud-do
      (format nil"SetEnvelope: Time=~a Value=0" (- end 0.1)))
    (aud-do
      (format nil"SetEnvelope: Time=~a Value=1" end))))

(if good-ver
    (if (< end 0.1)
        (format nil "Selection must be more than 0.1 seconds")
        (do-mute))
    (format nil "Audacity 2.3.x required"))

I say “if you’re adventurous” because this uses Audacity’s new “Nyquist Macro” feature (Nyquist-Macros - Audacity Manual)

To use it, click on a track where you want the “mute” to end, then apply the Nyquist Prompt with the above code.

Select the region that you wish to retain in one track, then
“Select menu > Tracks > In all Tracks (Shift + Ctrl + K)”

Then
“Edit menu > Remove Special > Trim Audio (Ctrl + T)”

That’s probably going to create a click : it’s not got a fade-in.
Noise gate maybe a better option : it has adjustable attack, so no click.

Actually, it does have a fade-in (well, sort of, but not really). It fades in from silence to full volume over 0.1 seconds, BUT…
Audacity’s envelopes are logarithmic (which I’ve always thought was a terrible idea, but that’s another story), and “fading in” logarithmically from absolute silence gives the sudden jump that you see with this effect.

To get a more reasonable fade-in, the initial envelope value needs to be a little higher than zero (not quite absolute silence).
To do that, change the line:

(format nil"SetEnvelope: Time=~a Value=0" (- end 0.1)))

to a slightly higher value (hint: 0.0001 is -80 dB, which is very nearly silent)

(format nil"SetEnvelope: Time=~a Value=0.0001" (- end 0.1)))

Also, the code assumes mono tracks.

Not in my case it didn’t : the mute effect was instant with a sharp cut-off

adventurous envelope code.gif
Also after applying that code, using undo does return it to the previous state.

Switch to the “Envelope Tool” and you will see the control points. This code is not acting directly on the audio, it is telling Audacity to create an envelope.

I think you may not have modified the code quite right. Try this:

;version 4
;type tool

(setf v-list (get '*audacity*' version))
(format t "Version ~a.~a.~a" (first v-list)(second v-list)(third v-list))
(setf good-ver
  (if (and (= (first v-list) 2)
            (= (second v-list) 3)
            (>= (third v-list) 0))
      t nil))

(setf end (get '*selection* 'end))

(defun do-mute ()
  (dotimes (i (get '*project* 'tracks))
    (aud-do
      (format nil "SelectTracks: Track=~a Mode=Set" i))
    (aud-do
      (format nil"SetEnvelope: Time=~a Value=0.1" (- end 0.1)))
    (aud-do
      (format nil"SetEnvelope: Time=~a Value=1" end))))

(if good-ver
    (if (< end 0.1)
        (format nil "Selection must be more than 0.1 seconds")
        (do-mute))
    (format nil "Audacity 2.3.x required"))

That’s fixed it …

adventurous envelope code #2.gif
However undo still fails to undo the effect of that code.
(and the top-edge of the Audacity-window flickers when the code is being applied)

That’s a “peculiarity” (aka “bug”) in the new scripting mechanism.
You can probably workaround it by undoing (Ctrl + Z) to one step past the point where the effect was applied, and then “redo” one step to bring you back to the correct state.

The problem here is that the history count is not quite right. I think the developer’s intention is that the entire script will count as one step, regardless of the number of “aud-do” commands.

I don’t see that on my (fairly fast) Linux machine, but it does not surprise me, or worry me unless it is extreme.
What’s happening when this code runs, is that Nyquist is telling Audacity to perform a series of commands:

  1. Set selection to first track
  2. Add an envelope point 0.1 seconds before the end of the selection at a low volume level
  3. Add an envelope point at the end of the selection at full volume
  4. Set selection to second tracl
  5. … (repeat for each track)

The failure I’m seeing with stereo tracks appears to be a bug in the scripting code in Audacity 2.3.1 alpha. I’ve just tested with Audacity 2.3.0, and it works for me with stereo tracks (on Linux).
Could you test with stereo tracks in the project and let me know if it works on Windows with 2.3.0.

For me (2.3.0 on Windows) the stereo behavior same as mono …

stereo test of adventurous envelope code #2.gif

Thanks trebor. So it seems that this new bug is only in the 2.3.1 alpha code.
I’ll add that info to the bugzilla report.

This has now been fixed.

And here’s a modified version of the script that gives a better fade-in:

;version 4
;type tool

(setf v-list (get '*audacity*' version))
(format t "Version ~a.~a.~a" (first v-list)(second v-list)(third v-list))
(setf good-ver
  (if (and (= (first v-list) 2)
            (= (second v-list) 3)
            (>= (third v-list) 0))
      t nil))

(setf end (get '*selection* 'end))

(defun do-mute ()
  (dotimes (i (get '*project* 'tracks))
    (aud-do
      (format nil "SelectTracks: Track=~a Mode=Set" i))
    (aud-do
      (format nil"SetEnvelope: Time=~a Value=0.0000001" (- end 0.1)))
    (aud-do
      (format nil"SetEnvelope: Time=~a Value=0.00001" (- end 0.09)))
    (aud-do
      (format nil"SetEnvelope: Time=~a Value=0.0001" (- end 0.05)))
    (aud-do
      (format nil"SetEnvelope: Time=~a Value=1" end))))

(if good-ver
    (if (< end 0.1)
        (format nil "Selection must be more than 0.1 seconds")
        (do-mute))
    (format nil "Audacity 2.3.x required"))