Macro selection help for crossfading multiple audio clips

Help for Audacity on macOS.
Forum rules
ImageThis forum is for Audacity on macOS 10.4 and later.
Please state which version of macOS you are using,
and the exact three-section version number of Audacity from "Audacity menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
tlm
Posts: 91
Joined: Thu Nov 22, 2012 4:32 am
Operating System: macOS 10.15 Catalina or later

Macro selection help for crossfading multiple audio clips

Post by tlm » Fri Jan 17, 2020 4:36 pm

I'm trying to crossfade a series of audio clips. I know how to do this using 2 overlapping clips on different tracks, but I want to be able to crossfade many more than 2 -- in fact, about 100. I obtain the clips as isolated clips in a single track, as shown in the top of the figure. I know that I can use sound finder to label these, export them, re-drag in that ordered sequence and then align the tracks end-to-end, as at the bottom of the figure.

But to crossfade I would need to select across every adjacent track -- which would be a lot of work.

So I looked into Audacity's Macro feature. But I became really puzzled as to how to make each selection prior to the crossfade? I looked and looked for tutorials and did learn a few things. But I can't figure it out. Any help would be appreciated.
Attachments
Screen Shot 2020-01-17 at 5.21.38 PM.jpg
Screen Shot 2020-01-17 at 5.21.38 PM.jpg (86.29 KiB) Viewed 404 times

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

Re: Macro selection help for crossfading multiple audio clips

Post by steve » Fri Jan 17, 2020 5:10 pm

Macros only provide a "list of commands". There is no "control logic", so you can't say "repeat these steps until the end".
This means that to do this job with a Macro, you need to know exactly how many clips are in the track, and adjust the script to suit.

This example is for 6 clips in the track (5 crossfades), and the crossfade is the last 0.2 seconds of one clip with the first 0.2 seconds of the next clip.

Code: Select all

SelectAll:
TruncateSilence:Action="Truncate Detected Silence" Compress="50" Independent="0" Minimum="0.001" Threshold="-60" Truncate="0"

SelNextClip:
SelectTime:End="0.2" RelativeTo="SelectionStart" Start="-0.2"
CrossfadeClips:Use_Preset="<Factory Defaults>"

SelNextClip:
SelectTime:End="0.2" RelativeTo="SelectionStart" Start="-0.2"
CrossfadeClips:Use_Preset="<Factory Defaults>"

SelNextClip:
SelectTime:End="0.2" RelativeTo="SelectionStart" Start="-0.2"
CrossfadeClips:Use_Preset="<Factory Defaults>"

SelNextClip:
SelectTime:End="0.2" RelativeTo="SelectionStart" Start="-0.2"
CrossfadeClips:Use_Preset="<Factory Defaults>"

SelNextClip:
SelectTime:End="0.2" RelativeTo="SelectionStart" Start="-0.2"
CrossfadeClips:Use_Preset="<Factory Defaults>"

Unfortunately we don't yet have the facility to import/export macros, but you can do it manually. See here for details: https://manual.audacityteam.org/man/man ... html#store
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

tlm
Posts: 91
Joined: Thu Nov 22, 2012 4:32 am
Operating System: macOS 10.15 Catalina or later

Re: Macro selection help for crossfading multiple audio clips

Post by tlm » Fri Jan 17, 2020 6:02 pm

Thank you for your help. I made a file containing one track with 5 clips to test your code and ran into the error shown in the top portion of the figure below. I then tried to reproduce the steps of your code manually up to the point where the error occurs and from what I can tell it looks like your code worked for the first crossfade -- but I'm not sure.

Here are the details of what I did:
1) I went to the folder where the Audacity macros are stored and opened one of the txt files, renamed it to MultipleCrossFade.txt
2) pasted in all your code, closed it
3) closed Audacity & restarted Audacity
4) made a test.aup having 5 clips in one track
5) Put my cursor in that track and ran the MultipleCrossFade macro

I did this all twice just to make sure and got the exact same error each time, and took the screenshot

I then manually moved together all 5 clips on the one track, selected 0.2 on either side of the first 2 clips, and used Effect-->Crossfade clips and took the screenshot. I'm not used to using Crossfade clips, but I assume they work the same -- even though the clips version has no way to enter parameters.

Let me know if there's something else I can try. If this works, I can handle doing what's needed for 100+ clips
Attachments
Screen Shot 2020-01-17 at 6.53.03 PM.jpg
Screen Shot 2020-01-17 at 6.53.03 PM.jpg (91.44 KiB) Viewed 393 times

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

Re: Macro selection help for crossfading multiple audio clips

Post by steve » Fri Jan 17, 2020 6:23 pm

Which version of Audacity are you using? (look in "Audacity menu > About Audacity")
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

tlm
Posts: 91
Joined: Thu Nov 22, 2012 4:32 am
Operating System: macOS 10.15 Catalina or later

Re: Macro selection help for crossfading multiple audio clips

Post by tlm » Fri Jan 17, 2020 6:40 pm

I'm using Audacity 2.3.2 on Catalina(Mac)

I did a little more to investigate. First, I see that you want me to use 6, not 5, clips, so I added one. Second, I removed the gap preceding the first clip and found it did 2 crossfades. So I removed all the gaps between and when I ran it, this time it seemed to work.

This is great and I think I can work with it -- just remove the gaps first -- but if you have more to offer, I'll take it.

Looking forward to more Macro capability in the future!

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

Re: Macro selection help for crossfading multiple audio clips

Post by steve » Fri Jan 17, 2020 7:20 pm

Are you sure that you included the first two lines:

Code: Select all

SelectAll:
TruncateSilence:Action="Truncate Detected Silence" Compress="50" Independent="0" Minimum="0.001" Threshold="-60" Truncate="0"
They should remove all of the gaps.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

tlm
Posts: 91
Joined: Thu Nov 22, 2012 4:32 am
Operating System: macOS 10.15 Catalina or later

Re: Macro selection help for crossfading multiple audio clips

Post by tlm » Fri Jan 17, 2020 7:35 pm

I believe I have the first 2 lines you mention. See the first screenshot.
Screen Shot 2020-01-17 at 8.24.56 PM.jpg
Screen Shot 2020-01-17 at 8.24.56 PM.jpg (300 KiB) Viewed 388 times
I decided to make another test file with 6 clips, and I made a 2nd macro called removeGaps.txt with just those 2 lines and as the 2nd and 3rd screenshots show, do indeed remove the gaps.
Screen Shot 2020-01-17 at 8.30.51 PM.jpg
Screen Shot 2020-01-17 at 8.30.51 PM.jpg (79.09 KiB) Viewed 388 times
Screen Shot 2020-01-17 at 8.31.06 PM.jpg
Screen Shot 2020-01-17 at 8.31.06 PM.jpg (83.29 KiB) Viewed 388 times

But as you can see in the 4th screenshot, when I try the original macro it is now giving another error.
Screen Shot 2020-01-17 at 8.31.33 PM.jpg
Screen Shot 2020-01-17 at 8.31.33 PM.jpg (93.59 KiB) Viewed 388 times

tlm
Posts: 91
Joined: Thu Nov 22, 2012 4:32 am
Operating System: macOS 10.15 Catalina or later

Re: Macro selection help for crossfading multiple audio clips

Post by tlm » Fri Jan 17, 2020 7:40 pm

and when I remove the first gap in front of the clips, I get the original error again:
Screen Shot 2020-01-17 at 8.37.52 PM.jpg
Screen Shot 2020-01-17 at 8.37.52 PM.jpg (65.87 KiB) Viewed 387 times

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

Re: Macro selection help for crossfading multiple audio clips

Post by steve » Fri Jan 17, 2020 8:21 pm

You will need to do some troubleshooting - it works for me, and I've even tried on the old Audacity 2.3.2 :?

In the Macro Editor, build the script up one line at a time, and test.

First test:

Code: Select all

SelectAll:
TruncateSilence:Action="Truncate Detected Silence" Compress="50" Independent="0" Minimum="0.001" Threshold="-60" Truncate="0"
Expected result = Selects all, and removes the gaps.


Second test:

Code: Select all

SelectAll:
TruncateSilence:Action="Truncate Detected Silence" Compress="50" Independent="0" Minimum="0.001" Threshold="-60" Truncate="0"
SelNextClip:
Expected result = All gaps removed, and second clip is selected.


Third test:

Code: Select all

SelectAll:
TruncateSilence:Action="Truncate Detected Silence" Compress="50" Independent="0" Minimum="0.001" Threshold="-60" Truncate="0"
SelNextClip:
SelectTime:End="0.2" RelativeTo="SelectionStart" Start="-0.2"
Expected result = All gaps removed, selected region is 0.4 seconds long, spanning the "split" between the first and second clips.



Fourth test:

Code: Select all

SelectAll:
TruncateSilence:Action="Truncate Detected Silence" Compress="50" Independent="0" Minimum="0.001" Threshold="-60" Truncate="0"
SelNextClip:
SelectTime:End="0.2" RelativeTo="SelectionStart" Start="-0.2"
CrossfadeClips:Use_Preset="<Factory Defaults>"
Expected result = All gaps removed, and first split crossfaded.


and so on.


At what point does the script break down?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

tlm
Posts: 91
Joined: Thu Nov 22, 2012 4:32 am
Operating System: macOS 10.15 Catalina or later

Re: Macro selection help for crossfading multiple audio clips

Post by tlm » Fri Jan 17, 2020 8:25 pm

I can’t work on this right now but I will follow your instructions and get back to you when I can

Post Reply