Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums VEGAS Pro Script for inserting transition audio for every transition

  • Script for inserting transition audio for every transition

    Posted by Kevin Lee on February 23, 2019 at 3:08 pm

    I’m using an old version of Vegas 12 (it does what I need it to, no need to upgrade really) and I found a script (below) from these forums that automatically adds transitions with overlaps across all events. I was wondering if there’s a way to modify the script or make a new one to add a short .wav or .mp3 for all transitions in the project. I could not find anything anywhere for this but there’s gotta be a way to do it I would think?

    Here is the script for the transitions:

    /**
    * Save this text as ApplyTransitions.js
    *
    * Apply Transition to Adjacent Video events and optionally move
    * events to overlap events.
    *
    * For use with Sonic Foundry Vegas Video 5.0
    *
    * Copyright 2002 murkWare (**@********ks.com)
    * Modified 7/16/2003 https://www.jetdv.com/tts
    **/
    import System.Windows.Forms;
    import Sony.Vegas;
    var overlapTime = 1000;

    var dialog = new TransitionDialog(overlapTime);

    var bFade = false; //Only true if the second list item is chosen
    var bRandom = false; //Only true if the first list item is chosen

    dialog.m_transList.Items.Add("Random For each event")
    dialog.m_transList.Items.Add("Standard Cross Fade")

    var count = 0;
    var totalTrans = Vegas.Transitions.Count;
    var num;
    var transEnum = new Enumerator(Vegas.Transitions);
    while (!transEnum.atEnd()) {
    var trans = transEnum.item();
    if (count > 0)
    dialog.m_transList.Items.Add(trans.Name);

    count++;
    transEnum.moveNext();
    }

    try {
    dialog.m_transList.SelectedIndex = 0
    var dialogResult = dialog.ShowDialog();
    var iTrans = int(dialog.m_transList.SelectedIndex);

    if(System.Windows.Forms.DialogResult.OK == dialogResult) {
    if (iTrans == 0) {
    bRandom = true;
    } else if(iTrans == 1) {
    bFade = true
    }

    var plugIn;
    if(iTrans > 1) {
    plugIn = Vegas.Transitions.GetChild(int(iTrans -1));
    }

    overlapTime = new Timecode(int(dialog.overlapTimeBox.Text));
    var startoffset = new Timecode(int(dialog.overlapTimeBox.Text));
    var trackEnum = new Enumerator(Vegas.Project.Tracks);
    var fx;

    while (!trackEnum.atEnd()) {
    var tr = trackEnum.item();
    var eventEnum = new Enumerator(tr.Events);

    while (!eventEnum.atEnd()) {
    var ev = eventEnum.item();

    ev.FadeIn.Curve = CurveType.Slow
    if (bRandom) {
    num = int(Math.random() * totalTrans + 1);
    if (num > 23) {
    num = totalTrans - 1;
    }
    plugIn = Vegas.Transitions.GetChild(int(num));
    }

    var startTime = ev.Start.ToMilliseconds();
    var length = ev.Length.ToMilliseconds();

    startTime = ev.Start - startoffset;
    if (startTime.ToMilliseconds() < 0) {
    startTime = new Timecode("00:00:00:00");
    startoffset = startoffset - overlapTime;
    }

    var currTake = ev.ActiveTake;
    var currOffset = currTake.Offset;
    ev.Start = startTime;
    currTake.Offset = currOffset;

    Vegas.UpdateUI();

    if(ev.MediaType == MediaType.Video && !bFade) {
    fx = new Effect(plugIn);
    ev.FadeIn.Transition = fx;
    }

    eventEnum.moveNext();
    startoffset = startoffset + overlapTime;
    }

    startoffset = overlapTime;
    trackEnum.moveNext();
    }
    }
    } catch (e) {
    MessageBox.Show(e + "\n\nReport this error to **@*******rk.com\n\n" + num);
    }

    // Form subclass that is the dialog box for this script
    class TransitionDialog extends Form {

    var overlapTimeBox;
    var m_transList;

    function TransitionDialog(overlapTime) {
    this.Text = "Add Transitions to adjacent events";
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
    this.MaximizeBox = false;
    this.StartPosition = FormStartPosition.CenterScreen;
    this.Width = 480;
    this.Height = 120;

    var buttonWidth = 80;
    var buttonHeight = 24;
    var buttonTop = 60;

    overlapTimeBox = addTextControl("Overlap Time (ms)", 320, 140, 20, overlapTime.ToString());
    m_transList = addComboBox(20,80,20);

    var okButton = new Button();
    okButton.Text = "OK";
    okButton.Left = this.Width - ((buttonWidth+10));
    okButton.Top = buttonTop;
    okButton.Width = buttonWidth;
    okButton.Height = buttonHeight;
    okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    AcceptButton = okButton;
    Controls.Add(okButton);

    var label = new Label();
    label.AutoSize = true;
    label.Text = "Copyright 2003 murkWare"
    label.Left = 20;
    label.Top = 80;
    Controls.Add(label);
    }

    function addTextControl(labelName, left, width, top, defaultValue) {
    var label = new Label();
    label.AutoSize = true;
    label.Text = labelName + ":";
    label.Left = left;
    label.Top = top + 4;
    Controls.Add(label);

    var textbox = new TextBox();
    textbox.Multiline = false;
    textbox.Left = label.Right;
    textbox.Top = top;
    textbox.Width = width - (label.Width);
    textbox.Text = defaultValue;
    Controls.Add(textbox);

    return textbox;
    }

    function addComboBox(left,width,top)
    {

    var transList = new ComboBox();

    // transList.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
    // Or System.Windows.Forms.AnchorStyles.Right)
    transList.DropDownWidth = width;
    // transList.Items.AddRange(tem 5"});
    transList.Location = new System.Drawing.Point(left, top);
    transList.Size = new System.Drawing.Size(280, 21);
    transList.TabIndex = 7;
    Controls.Add(transList);

    return transList;
    }

    }

    Edward Troxel replied 7 years, 5 months ago 3 Members · 5 Replies
  • 5 Replies
  • Paul Berk

    February 23, 2019 at 6:55 pm

    I’m not sure a script would answer this … I’d think you’d need a video transition plugin that included a selection of audio FX that would match the exact length of the video transition. THis would also require the addition of a separate audio track to the timeline .. things could get very messy when making changes , so I doubt anything like this exists.

    One thing Vegas can do is to add the same video transition on all the “selected” video events within a track with one drag and drop.

  • Kevin Lee

    February 23, 2019 at 8:01 pm

    Yeah, I know about that.

    I could make the audio clip into a video clip (just blank or transparent video). Is there anyway to automatically add clips to a track wherever there is a marker? That might work. I just don’t want to paste the sound (a woosh) 1000 times. There’s gotta be a way! 😛

  • Paul Berk

    February 23, 2019 at 9:53 pm

    Stumped. I don’t know a way to automate what you want.

    Challenging problem for those expert at writing scripts or plug-ins.

  • Kevin Lee

    February 23, 2019 at 11:37 pm

    So I created a marker at every transition with timeline tools and then just hit ctrl+right arrow and then hit ctrl-v to paste sound event at each marker…..not automated but got the job done pretty easily I guess. Might be better off just to make a macro with these keybinds and then automate it that way via keyboard or mouse software.

  • Edward Troxel

    February 25, 2019 at 4:03 pm

    Kevin, the short answer is “yes”. However, it would take some work to accomplish what you are asking. But it could certainly be done via a script.

    Edward Troxel

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy