ūüďĚ‚öôÔłŹ(Script) Smooth cuts with audio transitions

m3lquixd wrote on 3/18/2023, 8:27 PM

@jetdv
Could you make a script that makes a 200 millisecond crossfade (specifically) in the audio between the selected events. Even if video event is selected the crossfade will be applied to the grouped audio.

I like to make these short audio crossfades between cuts to make a less abrupt cut, but Vegas doesn't allow you to select several events and apply them all.

Last changed by m3lquixd

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

Comments

m3lquixd wrote on 3/19/2023, 7:39 AM

@jetdv I would like you to indicate in the code where the line is to change the milliseconds, in case I need it.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

jetdv wrote on 3/19/2023, 7:52 AM

Are you starting with cuts? Or could there already be existing crossfades?

Does it have to be centered? i.e. do you move the start of the right event slightly left and the end of the left event slightly right? Or do you just extend the left event far enough to cover the distance? Or do you move the right one far enough left to cover the distance? The SIMPLEST option is extending the left one to cover the distance..

The time covered would be very simple to put into a variable you could change.

m3lquixd wrote on 3/19/2023, 7:58 AM

I need it to be equal to these examples I showed above. A crossfade of 200 milliseconds, that is, the event on the left will expand 100 milliseconds to the right and the event on the right will expand 100 milliseconds to the left. This question you asked about the already existing crossfade is interesting, at first I thought about events that do not have a crossfade, but if it is possible for the script to identify whether the event already has a crossfade and not modify it if there is, that would be interesting. But at first I would apply the script where I'm sure there is no existing crossfade.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

m3lquixd wrote on 3/19/2023, 7:59 AM

Obs. I don't want the script to show an interface when executed, I want it to only crossfade. And the crossfade must always be on the audio and not on the video.

Last changed by m3lquixd on 3/19/2023, 8:00 AM, changed a total of 1 times.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

m3lquixd wrote on 3/19/2023, 8:16 AM

@jetdv 

But of course, it would be very interesting ALSO beyond this script, a separate script.
We select the events, then run the script. It would show an interface for us to choose whether we want to fade in, fade out, fade in and out or crossfade. Whether we want it in audio, video or both. The duration of these fades, option of seconds (you can put 0.2 seconds if you want it to be milliseconds) or frames. And the type of transition curve. By default, I would like it to come with 1 second in the duration field and the smooth type. In the option to choose whether it is fade or in, etc. Come unchecked.
Of course, this one would be more work, and I know you don't have much time to work on it, but here's the idea.

Ps. In case someone recommends it to me, I already know the script that crossfades The Happy Otter, but it doesn't have a frame option, only milliseconds and I would prefer it to be seconds. And there is the RatinFX script that fades in and out but does not crossfade. This script that I have idealized would be more complete. That's why I think it would be work, so @jetdv do it when you can and if you want.

Last changed by m3lquixd on 3/19/2023, 8:22 AM, changed a total of 1 times.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

Fu-Ji wrote on 3/19/2023, 6:17 PM

@jetdv Can you do this one?

Hey man, you shouldn't keep tagging a user to serve you, because you haven't paid him.

You should tag officials or developers because you paid for their product.

m3lquixd wrote on 3/19/2023, 9:07 PM

Sorry Edward.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

walter-i. wrote on 3/20/2023, 3:01 AM

@jetdv Can you do this one?

Hey man, you shouldn't keep tagging a user to serve you, because you haven't paid him.

You should tag officials or developers because you paid for their product.

In the country I grew up in, you at least say "please" when you want someone else to do something you don't want to pay for.
I haven't read this thread completely, but at least in the opening statements I can't detect this "please".

But of course that can be quite different in other countries.

m3lquixd wrote on 3/20/2023, 6:06 AM

@walter-i. @Fu-Ji I wasn't demanding, I was asking if it's possible to do it.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

jetdv wrote on 3/20/2023, 10:40 AM

@m3lquixd Ok, this assumes all events are together as shown in your images above. It does not look to see if there are gaps between them. However, it DOES look to see if it would extend an event past the BEGINNING of that event and will not do so. With this version, if you had a two second gap between audio events, they'll now be overlapped by 200 ms by extending the left one. If the right one cannot be extended left, the left one will be extended for the full amount.

Before:

After:


 

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            Timecode overlapTime = Timecode.FromMilliseconds(200);  //Change this number to change the overlap amount

            Timecode halfOverlapTime = Timecode.FromMilliseconds(overlapTime.ToMilliseconds() / 2.0);

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsAudio())
                {
                    for (int i=0; i<myTrack.Events.Count - 1; i++)
                    {
                        TrackEvent left = myTrack.Events[i];
                        TrackEvent right = myTrack.Events[i + 1];

                        if (right.ActiveTake.Offset >= halfOverlapTime)
                        {
                            right.Start = right.Start - halfOverlapTime;
                            right.Length = right.Length + halfOverlapTime;
                            right.ActiveTake.Offset = right.ActiveTake.Offset - halfOverlapTime;
                        }

                        left.Length = (right.Start + overlapTime) - left.Start;
                    }
                }
            }


        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

The two exceptions:

On the left overlap here, the left event was extended until it properly overlapped the right event even though there was a gap. This can be checked for and eliminated but this quick version does not check for that. If there *is* a gap, how big is two big? I'm thinking anything over 1 frame is too big!

On the right overlap here. the right event is the very beginning of a new clip so there is nothing "left" of the start of the event to be extended. Therefore, the entire distance was taken to the right of the split.

m3lquixd wrote on 3/20/2023, 10:52 AM

@jetdv From what I've tested here, it's applying the crossfade even without me selecting the events. The idea is for me to indicate which events I want to insert the crossfade.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

jetdv wrote on 3/20/2023, 10:55 AM

@m3lquixd Correct. It's looking at ALL audio events right now. If you select events, do both left AND right have to be selected in order for it to be applied?

m3lquixd wrote on 3/20/2023, 10:59 AM

@jetdv Yes, I would like it to only apply the crossfade to events that were selected by me.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

jetdv wrote on 3/20/2023, 11:01 AM

@m3lquixd, this version will work with only cases where the LEFT one is selected (right one doesn't matter) and will look for gaps bigger than 1 frame and those will not be processed either.

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            Timecode overlapTime = Timecode.FromMilliseconds(200);  //Change this number to change the overlap amount

            Timecode halfOverlapTime = Timecode.FromMilliseconds(overlapTime.ToMilliseconds() / 2.0);

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsAudio())
                {
                    for (int i=0; i<myTrack.Events.Count - 1; i++)
                    {
                        TrackEvent left = myTrack.Events[i];
                        TrackEvent right = myTrack.Events[i + 1];

                        bool ProcessCrossfade = left.Selected;

                        if (right.Start > left.End)
                        {
                            if ((right.Start - left.End) > Timecode.FromFrames(1))
                            {
                                ProcessCrossfade = false;
                            }

                        }

                        if (ProcessCrossfade)
                        {
                            if (right.ActiveTake.Offset >= halfOverlapTime)
                            {
                                right.Start = right.Start - halfOverlapTime;
                                right.Length = right.Length + halfOverlapTime;
                                right.ActiveTake.Offset = right.ActiveTake.Offset - halfOverlapTime;
                            }

                            left.Length = (right.Start + overlapTime) - left.Start;
                        }
                    }
                }
            }


        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

m3lquixd wrote on 3/20/2023, 11:02 AM

Like this

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

m3lquixd wrote on 3/20/2023, 11:06 AM

@jetdv Is there no way for it to identify if the 2 events were selected and crossfade between the two?
As shown here:

Like this

The way you did it and you explained it, it crossfades with the event to the right of the selected one.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

jetdv wrote on 3/20/2023, 11:11 AM

@m3lquixd Ok, so the answer to my question is; only if both left and right are selected...
 

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            Timecode overlapTime = Timecode.FromMilliseconds(200);  //Change this number to change the overlap amount

            Timecode halfOverlapTime = Timecode.FromMilliseconds(overlapTime.ToMilliseconds() / 2.0);

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsAudio())
                {
                    for (int i=0; i<myTrack.Events.Count - 1; i++)
                    {
                        TrackEvent left = myTrack.Events[i];
                        TrackEvent right = myTrack.Events[i + 1];

                        bool ProcessCrossfade = left.Selected && right.Selected;

                        if (right.Start > left.End)
                        {
                            if ((right.Start - left.End) > Timecode.FromFrames(1))
                            {
                                ProcessCrossfade = false;
                            }

                        }

                        if (ProcessCrossfade)
                        {
                            if (right.ActiveTake.Offset >= halfOverlapTime)
                            {
                                right.Start = right.Start - halfOverlapTime;
                                right.Length = right.Length + halfOverlapTime;
                                right.ActiveTake.Offset = right.ActiveTake.Offset - halfOverlapTime;
                            }

                            left.Length = (right.Start + overlapTime) - left.Start;
                        }
                    }
                }
            }


        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

m3lquixd wrote on 3/20/2023, 11:27 AM

@m3lquixd Ok, so the answer to my question is; only if both left and right are selected...

@jetdv Sorry for my lack of interpretation, I have difficulty with English.

The script worked perfectly now!

Even if video event is selected the crossfade will be applied to the grouped audio.

But is it possible for the script to do what I had requested since the initial post?
Where even if I marked the video event that is above the audio, it would crossfade the audio, taking into account that the audio is linked to that video.


 

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

jetdv wrote on 3/20/2023, 11:42 AM

@m3lquixd That would be a NO. I can see if an event has been grouped. I can get that group, I can add more events to that group. I cannot see what other events are in the group.

The only way to do something like that would be to make the assumption that "It's the event in the same place on the next track down" - but that's just an assumption. I recommend you select the audio events. You can select BOTH video and audio events, it doesn't matter as the video will be ignored anyway.

m3lquixd wrote on 3/20/2023, 11:50 AM

@jetdv OK perfect. I'm really used to selecting audio events. haha
We have a crossfade insert script. But to remove these crossfades using the same logic, select the events you want and remove the crossfade between the left and right event.It's possible? If yes, is it possible to insert in the same script? If not, it's okay to have 2 separate scripts, I can define a shortcut for both.

Last changed by m3lquixd on 3/20/2023, 12:05 PM, changed a total of 1 times.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

jetdv wrote on 3/20/2023, 12:10 PM

Just making the other one go backwards...
 

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            Timecode overlapTime = Timecode.FromMilliseconds(200);  //Change this number to change the overlap amount

            Timecode halfOverlapTime = Timecode.FromMilliseconds(overlapTime.ToMilliseconds() / 2.0);

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsAudio())
                {
                    for (int i = 0; i < myTrack.Events.Count - 1; i++)
                    {
                        TrackEvent left = myTrack.Events[i];
                        TrackEvent right = myTrack.Events[i + 1];

                        bool ProcessCrossfade = left.Selected && right.Selected;

                        if (right.Start > left.End - halfOverlapTime)
                        {
                            if ((right.Start - left.End - halfOverlapTime) > Timecode.FromFrames(1))
                            {
                                ProcessCrossfade = false;
                            }

                        }

                        if (ProcessCrossfade)
                        {
                            right.Start = right.Start + halfOverlapTime;
                            right.Length = right.Length - halfOverlapTime;
                            right.ActiveTake.Offset = right.ActiveTake.Offset + halfOverlapTime;

                            left.Length = right.Start - left.Start;
                        }
                    }
                }
            }


        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

m3lquixd wrote on 3/20/2023, 12:18 PM

@jetdv It's resulting in this. I don't want the event to have this fade out and fade in.

I need him to be left with nothing.

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))

jetdv wrote on 3/20/2023, 1:21 PM

That's VEGAS's standard fade out/in. Uncheck Options - Quickfade Audio Events.

Does it still do it after unchecking that?

 

m3lquixd wrote on 3/20/2023, 1:40 PM

@jetdv The standard vegas fade in and fade out is this one, from the second screenshot.

This fade is from the script itself, you can see that its size is 200 milliseconds.

 

Operating System
    Windows 11 Pro 64-bit
CPU
    AMD Ryzen 3 3200G 3.60 GHz
RAM
    16,0GB Dual-Channel DDR4 2666MHz
Motherboard
    Gigabyte Technology Co. Ltd. A320M-S2H-CF (AM4)
Graphics
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))