Need help creating a script for volicty

Hyrep wrote on 2/25/2018, 1:13 PM

Hello, I need help creating a script. I want it to add a velocity envelope on the video track for the clip on it. So at the start of the track I want a point at the beginning of the clip and set it to 300% then fade type to Fast. Then I want it to go 5 clicks to the right from the video and the marker, then I want it to add another point and drop it to 50% and set the fade type to Slow. And then go to the end of the clip and create another point and set it to 300% and set the fade type to Fast. And then Lastly go 5 back from the end of the clip and set it to 50% and the fade type to slow. Hopefully that makes sense I cant seem to get my script to work so can you please make me one. Also I want another script that does the same thing but instead of going 5 clicks foward/backwards I want it to go 10 clicks forward/backward. Hopefully that isnt to much Ill reward any way possible I am not so good at scripting so thanks. Ill link a screen shot of what It should look like! Thanks for any and all help. <3 Screenshot

Comments

jetdv wrote on 2/27/2018, 1:23 PM

Try this routine:
 

    public void SetVelocityPoint(Timecode markLoc, string markLabel)
    {
        Timecode OStartTime = Vegas.Project.Ruler.StartTime;
        Vegas.Project.Ruler.StartTime = new Timecode(0);
    
      foreach (Track track in Vegas.Project.Tracks)
      {
        if (track.IsVideo()) {
          foreach (TrackEvent evnt in track.Events)
          {
            if (evnt.Selected) {
              if ((evnt.Start.ToMilliseconds() < markLoc.ToMilliseconds()) && ((evnt.Start.ToMilliseconds() + evnt.Length.ToMilliseconds()) > (markLoc.ToMilliseconds()))) {
                VideoEvent vevnt = (VideoEvent)evnt;
    
                // Find the velocity envelope - add if needed
                Envelope VelEnv = FindVEEnvelope(vevnt, EnvelopeType.Velocity);
                if (null == VelEnv) {
                    VelEnv = new Envelope(EnvelopeType.Velocity);
                    vevnt.Envelopes.Add(VelEnv);
                }
                

    
                Timecode PointLoc = markLoc - evnt.Start;
                double PointSpeed;
                if (markLabel == "")
                {
                    PointSpeed = VelEnv.ValueAt(PointLoc);
                }
                else
                {
                    PointSpeed = Convert.ToSingle(markLabel) / 100.0;
                }
                  
                EnvelopePoint a = VelEnv.Points.GetPointAtX(PointLoc);  
                if (a == null) {
                  a = new EnvelopePoint(PointLoc, PointSpeed);
                  VelEnv.Points.Add(a);
                } else {
                  a.Y = PointSpeed;
                }
                //a.Curve = curve type - you can change the "fast" and "slow" here.
              }
            }
          }
        }
      }
        Vegas.Project.Ruler.StartTime = OStartTime;
    }

 

markLoc would be the location on the timeline you want the velocity to change

markLabel would be the value of the speed (i.e. 300 or 0 or 50).

I added a comment where you can change the curve type. You can use "CurveType.Fast" or "CurveType.Slow" or any of the other options for CurveType.