ReallyQuickEnvelope

RiCON wrote on 9/25/2009, 4:37 AM
I've based myself on the old QuickEnvelope to create a new, similar one. It doesn't have nearly as much options, because I tried to KISS.

Also, I don't know almost anything about JScript or C#, so if anyone could optimize it or even port it to C#, it would be awesome.

It just creates Volume Envelopes in all tracks if only one is selected or if more than one is selected, just creates on those. Also, I've grabbed just the function to delete envelopes and made a separate script just with it.

The original (seems to be almost lost, can't even remember where I got it): http://pastebin.com/f230f9eba

The ReallyQuickEnvelope creator: http://pastebin.com/f5ab85bc6

And the deleter: http://pastebin.com/f10ea9028

Comments

jetdv wrote on 9/25/2009, 6:32 AM
Here's an old version I last updated in 2005 that adds 4 points to an audio envelope. It may need to be updated to run properly in Vegas Pro 8/9.

/**
* This script will set four points around the selection area on all selected tracks.
*
* Written By: Edward Troxel
* Copyright 2004 - JETDV Scripts
* Modified: 07-26-2005
**/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;


//Change this line to change the distance between the points
var FPDist = new Timecode("00:00:01:00");


try {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());


//Now check for Volume Envelope
if (track.IsAudio() && track.Selected) {
// Find the volume envelope on this track - add if needed
var VolEnv = FindEnvelope(track, EnvelopeType.Volume);
if (null == VolEnv) {
VolEnv = new Envelope(EnvelopeType.Volume);
track.Envelopes.Add(VolEnv);
}

var ClipVol = VolEnv.ValueAt(Vegas.SelectionStart);
//Now set the points
SetPoint(VolEnv, Vegas.SelectionStart, ClipVol)
SetPoint(VolEnv, Vegas.SelectionStart + FPDist, ClipVol)
SetPoint(VolEnv, Vegas.SelectionStart + Vegas.SelectionLength - FPDist, ClipVol)
SetPoint(VolEnv, Vegas.SelectionStart + Vegas.SelectionLength, ClipVol)
}

trackEnum.moveNext();
}

} catch (e) {
MessageBox.Show(e);
}

function FindEnvelope(track : Track, etype : EnvelopeType) : Envelope {
var envEnum : Enumerator = new Enumerator(track.Envelopes);
while (!envEnum.atEnd()) {
var env : Envelope = envEnum.item();
if (env.Type == etype) {
return env;
}
envEnum.moveNext();
}
return null;
}

function SetPoint(menv : Envelope, PLoc : Timecode, PVal : Double) {
var a : EnvelopePoint = menv.Points.GetPointAtX(PLoc);

if (a == null) {
a = new EnvelopePoint(PLoc, PVal);
menv.Points.Add(a);
} else {
a.Y = PVal;
}
}