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

Comments

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

Add these two lines:

                            left.FadeOut.Length = Timecode.FromFrames(0);
                            right.FadeIn.Length = Timecode.FromFrames(0);

after left.length is set.

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

Change:

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; 
}

to

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; 
    left.FadeOut.Length = Timecode.FromFrames(0);
    right.FadeIn.Length = Timecode.FromFrames(0);
}

 

m3lquixd wrote on 3/20/2023, 2:24 PM

Insert a 200ms Crossfade in the audio of the selected events.ūüĒĹ

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);
    }
}

Remove Crossfade from selected event audios.ūüĒĹ

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; 
    left.FadeOut.Length = Timecode.FromFrames(0);
    right.FadeIn.Length = Timecode.FromFrames(0);
}
                    }
                }
            }


        }
    }
}

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

Insert 200ms Crossfade in all audios.ūüĒĹ

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);
    }
}

 

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

‚¨áÔłŹ Some of my jobs. ‚¨áÔłŹ
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
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))