Here’s the current version of that script for Vegas Pro 8.
/**
* This script will set four points around the selection area on all selected tracks.
*
* Written By: Edward Troxel
* Copyright 2004-2009 - JETDV Scripts
* Modified: 07-18-2006
**/
using System;
//using System.IO;
//using System.Windows.Forms;
using Sony.Vegas;
public class EntryPoint
{
Vegas myVegas;
public void FromVegas(Vegas vegas)
{
myVegas = vegas;
//Change this line to change the distance between the points
Timecode FPDist = new Timecode("00:00:01:00");
foreach(Track track in myVegas.Project.Tracks)
{
//Now check for Volume Envelope
if (track.IsAudio() && track.Selected)
{
// Find the volume envelope on this track - add if needed
Envelope VolEnv = FindEnvelope(track, EnvelopeType.Volume);
if (null == VolEnv)
{
VolEnv = new Envelope(EnvelopeType.Volume);
track.Envelopes.Add(VolEnv);
}
double ClipVol = VolEnv.ValueAt(myVegas.SelectionStart);
//Now set the points
SetPoint(VolEnv, myVegas.Transport.LoopRegionStart, ClipVol);
SetPoint(VolEnv, myVegas.Transport.LoopRegionStart - FPDist, ClipVol);
SetPoint(VolEnv, myVegas.Transport.LoopRegionStart + myVegas.Transport.LoopRegionLength + FPDist, ClipVol);
SetPoint(VolEnv, myVegas.Transport.LoopRegionStart + myVegas.Transport.LoopRegionLength, ClipVol);
}
}
}
private Envelope FindEnvelope(Track track, EnvelopeType etype)
{
foreach(Envelope env in track.Envelopes)
{
if (env.Type == etype)
{
return env;
}
}
return null;
}
private void SetPoint(Envelope menv, Timecode PLoc, double PVal)
{
EnvelopePoint a = menv.Points.GetPointAtX(PLoc);
if (a == null)
{
a = new EnvelopePoint(PLoc, PVal);
menv.Points.Add(a);
}
else
{
a.Y = PVal;
}
}
}
Just save it as “FourPoints.cs” and it should do the job for you. You do need to have a selection area (it will still work even if you don’t but won’t give you what you want) and a selected audio track.
Edward Troxel
