Scripting documentation

mohsen-amini wrote on 1/9/2020, 4:42 PM

Hello everyone. my question is 2 part:

- The company confirmed that they don't have any good sources or documentation regarding how to script in vegas pro. so I was wondering if you guys made any documentation that can help me start. I am a developer but have no idea about the commands and everything.

- to start I want to make a script so I can volume down the selected part of an audio track with a shortcut. there are some unwanted voices in a video clip. I can select the beginning and the end and try to add points then pull down the volume. so imagine I need these with a shortcut. of course, only the adding points and volume down part/ not the finding unwanted voice. also, Automation is not a good way for me to do this. would you please help me if you know good commands for this purpose?

Comments

frmax wrote on 1/9/2020, 5:18 PM

Imho Nick´s post https://www.vegascreativesoftware.info/us/forum/vegas-pro-scripting-faqs-resources--104563/ is a starting point

jetdv wrote on 1/9/2020, 8:06 PM

Something like this?


 

    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);
      }
    }

 

jetdv wrote on 1/9/2020, 8:07 PM

You'll also need these two subroutines:


 

 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;
    }
  }

 

mohsen-amini wrote on 1/11/2020, 12:12 PM

You'll also need these two subroutines:


 

 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;
    }
  }

 

That was really helpful. thank you so much ^^

jetdv wrote on 1/14/2020, 2:12 PM

Glad to help.