Mixing Tracks with Macros

Using latest Windows 10 and Audacity 2.3.0

I have a large set of voice .wav files with varying length and I want to mix a single sound fx file (fixed length) to them in a batch using Audacity’s Macros system. Further, that sound fx file being applied to all those voice wav files should fade in then fade out at the end while the voice wav files being processed stay the same volume.

So workflow looks like…

  1. Load a batch of varying length voice .wav files
  2. Copy single sound fx to clipboard
  3. Fade in #2 and loop it (if its length were less than #1)
  4. When near the end of #1 Fade out #2
  5. Trim and save as new file

This would then move onto next voice .wav file to repeat.

Any help is VERY appreciated as I need all this automated via the macros. Thank you community!

A “normal” Macro can’t do things conditionally. A normal Macro just runs a list of commands.

“IF” is a “conditional statement”. A normal Macro can’t do that (“Nyquist-Macros” and scripting via an external language with mod-script-pipe can do this, but these approaches are much more complex and unnecessary in this case).

The approach I would take:

  1. Manually loop the “sound fx” so that it is at least as long as the longest voice file.
  2. Manually fade-in the start of the “sound fx” (only need to do this once).

Then create a Macro to import the “sound fx”, trim it to the same length as the first track, fade out the end, (normalize?), export.

Thank you Steve (and everyone else in the community)! Appreciate this help.

This is what I have so far in my Macro…

Command                                 Parameters
Import2                                 [path to my single fixed length sound fx .wav]
Mix and Render to New Track     
Export as WAV

What this does is grab the fixed length sound fx and mix it with any multi-length sound file I wish.

Problem is it does not trim the output based on the random length of the sound files that pass through.

I have faded in the fixed length sound fx .wav so that part is done but my current challenge is now:

  1. Mix the fixed length sound fx to each incoming variable length sound file and trim it to those (not to the fixed length sound byte) and
  2. Fade out only the fixed length sound fx based on the trim of #1.

I get a feeling #2 is gonna be a challenge if I cannot get the macro to dynamically fade in the fixed length sound fx based on when each variable length sound file starts.

Any help is appreciated especially at each stage but I’ll need actual Macro Commands, applicable parameters, and where in the sequence to place them to figure this out.

You will need to refer to the Scripting Reference to get the exact names for these commands (Scripting Reference - Audacity Manual)

  • Select the first track and make the selection 0 seconds relative to the end of the track. (Cursor is now at the end of the track)
  • Select the second track, and extend the selection to the end of the track (“SelEnd:”)
  • Delete the selected audio
  • For a 2 second fade out, select “-2” seconds, relative to the end of the track, and apply a fade-out

Then you can mix the tracks as before.

So based on what you said the Macro goes as:

Command                                 Parameters
Select					RelativeTo="SelectionEnd" Tracks="1"
Import2					[path to my single fixed length sound fx .wav]
Cursor To Track End
Select Tracks				Mode="Set" TrackCount="2"
Selection to End
Delete
Mix and Render to New Track     
Export as WAV

I’m hoping this is somewhat close at least so it can properly trim first before I figure out the fade out of the sound fx.

If possible, please correct the above: I am very sure this will be used by others as I’ve never found another Audacity macro which does this.

Almost but not quite…

Command                                 Parameters
Select					End="0" RelativeTo="SelectionEnd" Track="0"
Select					RelativeTo="SelectionEnd" TrackCount="2"
Select					End="-10" RelativeTo="SelectionEnd" Track="0"
Fade Out				Use_Preset="<Factory Defaults>"
Import2					[path to my single 14sec sound fx .wav]
Delete
Mix and Render to New Track     
Export as WAV

So the above will cut back -10 seconds from the end of the fixed length sound FX but that only works for voice files passing that fit correctly so this is not a solution to properly cut/trim each sound file that passes. Its also not fading out the sound fx still.

Can one see what is incorrect with the above Macro?

Try this:

Import2:Filename="<path to sfx file>.wav"
Select:End="0" Mode="Set" RelativeTo="SelectionEnd" Start="0" Track="1" TrackCount="1"
SelCursorToTrackEnd:
Delete:
SelectTime:End="2" RelativeTo="ProjectEnd" Start="0"
FadeOut:
SelectAll:
MixAndRender:
ExportWav:

Utterly marvelous Steve!

Very close now! Almost there! :smiley:

Ok so the final tweaks I need are:

  1. Fade in the background sound fx for 0.5 second from the start (we got the end one now working but if I Select Time at Project Start it will cut off the sound fx within a second) and…
  2. Change the decibel level of the fixed length sound fx itself (taking into account the fade in and out at the ends).

Thank you so very much Steve!!

Edit: Re-evaluated your original logic and got the Fade in 0.5 at the start of the sound FX to work perfectly… Here is my update…

Import2:Filename="<path to sfx file>.wav"
Select:End="0" Mode="Set" RelativeTo="SelectionEnd" Start="0" Track="1" TrackCount="1"
SelCursorToTrackEnd:
Delete:
SelectTime:End="0" RelativeTo="ProjectStart" Start="0.5"
FadeIn:
SelectTime:End="1" RelativeTo="ProjectEnd" Start="0"
FadeOut:
SelectAll:
MixAndRender:
ExportWav:

So essentially the new tweak is at Project Start to Fade In the fixed length Sound Fx in 0.5 seconds. Also made it 1sec (instead of 2) for the Fade Out on the fixed length Sound Fx .

So final question is if one can change the volume of either the Sound FX (Project?) or the different length sound files being shuttled through (Selection)?

Edit: ok I think I figured how to isolate the fixed-length sound fx and not the different length sound files. Here is the final Macro…

Import2:Filename="<path to sfx file>.wav"
Select:End="0" Mode="Set" RelativeTo="SelectionEnd" Start="0" Track="1" TrackCount="1"
SelCursorToTrackEnd:
Delete:
SelectTime:RelativeTo="Project"
Amplify:Ratio="0.89" [-1.0 db]
SelectTime:End="0" RelativeTo="ProjectStart" Start="0.5"
FadeIn:
SelectTime:End="1" RelativeTo="ProjectEnd" Start="0"
FadeOut:
SelectAll:
MixAndRender:
ExportWav:

Change here was Selecting Time “Relative to Project” then using the Amplify option in the sequence above. :mrgreen: