Change sensitivity according to speed list

Jorge-Vegas wrote on 6/5/2023, 12:52 PM

In the image below you can see an example of what I have in my Vegas Pro project. An event that has sensitivity turned on, this sensitivity has all its "green keyframes" in hold mode, starts at 0% velocity and, every so often, it should increase its speed and then it goes back to 0%.

I actually have a video that has over 120 of these speed "increments" and I have to manually change the speed percentage at each initial keyframe at each increment.

On the right you can see the values that I have to enter manually, it is in an excel sheet but it could be in a notepad or inside a Vegas text file. The fastest I have managed to do this is by moving the mouse to the corresponding "keyframe", right clicking, pressing the "T" key (in Spanish) which opens the window to manually type the speed (as seen in the image ), but many times I fail when trying to right-click on the keyframe (because it has a very small hitbox), and doing this 120 times means a lot of failures.

I tried to modify the sensitivity values by entering the Vegas project or an exported version in "xml" format with notepad, but I did not find a section that mentions the sensitivity values.

Could a script change the sensitivity values? Is there another way to change the sensitivity manually but that is more precise? In vegas there is a keyboard shortcut to advance to the next keyframe or marker, but it doesn't work with the "green keyframes", is there a shortcut or something similar to move between these "green keyframes"?

Any help will surely improve this repetitive task.

Thank you very much, George!


Comments

jetdv wrote on 6/5/2023, 2:14 PM

Yes, a script can change velocity envelope values.

Jorge-Vegas wrote on 6/5/2023, 3:01 PM

Gracias por su respuesta. Intentaré hacer algo con la segunda opción que muestra en su video, con los ajustes de envolvente. Ese código funcionará en Vegas 18? Puedo copiarlo textualmente de algún lugar o debo transcribirlo desde su video?

Muchas gracias!

Thanks for your reply.  I'll try to do something with the second option you show in your video, with the envelope settings.  Will that code work in Vegas 18?  Can I copy it verbatim from somewhere or should I transcribe it from your video?

 Thank you so much!

jetdv wrote on 6/5/2023, 3:26 PM

Yes, the current tutorials typically work with VEGAS Pro 14 and newer. The same code will work with older versions but you have to change the "using" statement to "Sony" instead of "ScriptPortal".

For that tutorial, you'll need to transcribe from the video. You may be able to copy some from the example below, though.

Here's code that will "unfreeze" and event that has the velocity set to "Freeze Frame" at the cursor location to give you an example:

//"Unfreeze/de-freeze" after using the "Freeze Frame at Cursor"
            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            VideoEvent vevnt = (VideoEvent)evnt;
                            Envelope vEnv = null;
                            foreach (Envelope env in vevnt.Envelopes)
                            {
                                if (env.Type == EnvelopeType.Velocity)
                                {
                                    vEnv = env;
                                }
                            }
                            if (vEnv == null)
                            {
                                vEnv = new Envelope(EnvelopeType.Velocity);
                                vevnt.Envelopes.Add(vEnv);
                            }
                            Timecode cursorloc = myVegas.Transport.CursorPosition;
                            if (cursorloc >= vevnt.Start && cursorloc < vevnt.End)
                            {
                                Timecode newPoint = cursorloc - vevnt.Start;
                                AddVelocityPoint(vEnv, newPoint, 0.0);
                                newPoint = newPoint + Timecode.FromMilliseconds(1);
                                AddVelocityPoint(vEnv, newPoint, 1.0);
                            }
                        }
                    }
                }

And the "AddVelocityPoint" routine:

        public void AddVelocityPoint(Envelope VelEnv, Timecode PointLoc, double PointSpeed)
        {
            EnvelopePoint a = VelEnv.Points.GetPointAtX(PointLoc);
            if (a == null)
            {
                a = new EnvelopePoint(PointLoc, PointSpeed);
                VelEnv.Points.Add(a);
            }
            else
            {
                a.Y = PointSpeed;
            }
        }

 

Jorge-Vegas wrote on 6/5/2023, 5:44 PM

I didn't mention it earlier because I didn't know if it would be useful, but in my original file I have markers at the start and end of each sensitivity increment and when it goes back to 0%, so I think the lines of code I saw in the The first video you shared with me could help me.

 That is, in the line "AddVelocityPoint(VelEnv, new linecode('TIME'),'SPEED' );"  I could change each 'TIME' with the time code of the first marker, change 'SPEED' by the value of the data table (if decimal numbers can be written there, because in your example I only see that you entered integers) .  Then in the next line I change the 'TIME' to the timecode of the next marker and I put the 'SPEED' to 0, so that the sensitivity goes back to 0%, I just need the sensitivity to stay all the time in the mode "hold" to prevent the sensitivity from dropping over time instead of staying constant until the next keyframe is reached.

 Example of what I came up with:
 AddVelocityPoint(VelSend, new linecode("00:00:01:23"), 2;64);
 AddVelocityPoint(VelSend, new linecode("00:00:03:56"), 0);
 AddVelocityPoint(VelSend, new linecode("00:00:05:12"), 4;78);
 AddVelocityPoint(VelSend, new linecode("00:00:07:45"), 0);

 would this work?  Can they be put in "hold" mode?

 

jetdv wrote on 6/6/2023, 7:49 AM

I typically place two markers at each point (in the example above, you can see I moved forward 1 millisecond for the second point making it an instantaneous change).

However, you can change the curve type on the envelope points. In the AddVelocityPoint routine, you could use something like: a.Curve = CurveType.Slow;

Unfortunately, it appears that "Hold" is not one of the options there...

So, I would tend to do it more like:

Timecode tc = Timecode.FromString("00:00:01:23");
AddVelocityPoint(VelSend, tc, 0);
AddVelocityPoint(VelSend, tc + Timecode.FromMilliseconds(1), 2;64);

tc = Timecode.FromString("00:00:03:56");
AddVelocityPoint(VelSend, tc, 2;64);
AddVelocityPoint(VelSend, tc + Timecode.FromMilliseconds(1), 0);

tc = Timecode.FromString("00:00:05:12");
AddVelocityPoint(VelSend, tc, 0);
AddVelocityPoint(VelSend, tc + Timecode.FromMilliseconds(1), 4;78);

tc = Timecode.FromString("00:00:07:45");
AddVelocityPoint(VelSend, tc, 4;78);
AddVelocityPoint(VelSend, tc + Timecode.FromMilliseconds(1), 0);

Or, better yet, make you can use an "add range" routine, pass it the starting and ending points, and let it add all four points for you.

        public void AddVelocityRange(Envelope VelEnv, Timecode StartPointLoc, Timecode EndPointLoc, double PointSpeed)
        {
            AddVelocityPoint(VelEnv, StartPointLoc, 0);
            AddVelocityPoint(VelEnv, StartPointLoc + Timecode.FromMilliseconds(1), PointSpeed);
            
            AddVelocityPoint(VelEnv, EndPointLoc, PointSpeed);
            AddVelocityPoint(VelEnv, EndPointLoc + Timecode.FromMilliseconds(1), 0);
        }

        public void AddVelocityPoint(Envelope VelEnv, Timecode PointLoc, double PointSpeed)
        {
            EnvelopePoint a = VelEnv.Points.GetPointAtX(PointLoc);
            if (a == null)
            {
                a = new EnvelopePoint(PointLoc, PointSpeed);
                VelEnv.Points.Add(a);
            }
            else
            {
                a.Y = PointSpeed;
            }
        }

Then call it with something like:

AddVelocityRange(VelEnv, Timecode.FromString("00:00:01:23"), Timecode.FromString("00:00:03:56"), 2;64);
AddVelocityRange(VelEnv, Timecode.FromString("00:00:05:12"), Timecode.FromString("00:00:07:45"), 4;78);