-
Script for inserting transition audio for every transition
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 chosendialog.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;
}}
