/**
 * This script normalizes all selected audio clips and
 * sets their in and out fade envelope types suitably
 * for dialog fragments.
 *
 * Revision Date: Jun 11, 2006.
 **/

import System.Windows.Forms;
import Sony.Vegas;

var normalizedCnt = 0;
var trkCnt, vntCnt, i, j;
trkCnt = Vegas.Project.Tracks.Count;
for (i = 0; i < trkCnt; i++) {
    var trk = Vegas.Project.Tracks[i];
    trk.Selected = !trk.Selected;
    vntCnt = trk.Events.Count;
    for (j = 0; j < vntCnt; j++) {
        var vnt = trk.Events[j];
        if ( vnt.Selected && vnt.IsAudio() )
        {
	        vnt.FadeOut.Curve = CurveType.Fast;
	        vnt.FadeOut.ReciprocalCurve = CurveType.Fast;

	        vnt.FadeIn.Curve = CurveType.Fast;
	        vnt.FadeIn.ReciprocalCurve = CurveType.Fast;
	        
	        vnt.Normalize = true;
	        vnt.RecalculateNorm();
	        normalizedCnt++;
    	}
    }
}

MessageBox.Show( "Normalized " + normalizedCnt + " selected audio clips.\nAlso set their fade types." );
