Add/Change an OFX keyframe value of a certain parameter

ad48hp wrote on 3/23/2019, 2:29 PM

I've been browsing a forum for a while, and couldn't find a definite answer yet.

How should i add an keyframe to a certain parameter (X Shake) at certain position in the scripting ?

I tried to create a new keyframe and it to the effect Keyframes collection, however there seem to be no argument for the parameter name.

Comments

j-v wrote on 3/23/2019, 3:26 PM

For each FX you can make your own PRESETS with your own keyframes.

met vriendelijke groet
Marten

Camera : Pan X900, GoPro Hero7 Hero Black, DJI Osmo Pocket, Samsung Galaxy A8
Desktop :MB Gigabyte Z390M, W11 home version 24H2, i7 9700 4.7Ghz,16 DDR4 GB RAM, Gef. GTX 1660 Ti with driver
566.14 Studiodriver and Intel HD graphics 630 with driver 31.0.101.2130
Laptop  :Asus ROG Str G712L, W11 home version 23H2, CPU i7-10875H, 16 GB RAM, NVIDIA GeForce RTX 2070 with Studiodriver 576.02 and Intel UHD Graphics 630 with driver 31.0.101.2130
Vegas software: VP 10 to 22 and VMS(pl) 10,12 to 17.
TV      :LG 4K 55EG960V

My slogan is: BE OR BECOME A STEM CELL DONOR!!! (because it saved my life in 2016)

 

ad48hp wrote on 3/23/2019, 5:40 PM

I don't get it..

What code am i supposed to write down to add a keyframe with name/value combination to the effect ?

j-v wrote on 3/23/2019, 6:02 PM

Look to the title of your post. It asks not for a script but for changing the (default) keyframe settings of an OFX, that is how I read your question and that has nothing to do with a script, unless you are using a script to make keyframes. But than, what kind of script are you talking about?

What I'm trying to say to make a preset means that in an effect you can make settings plus keyframe them and than you can make of that changed OFX a preset by giving it a name and store that through the map symbol , after you gave it your own name. Next time you open that OFX you can use yours.

met vriendelijke groet
Marten

Camera : Pan X900, GoPro Hero7 Hero Black, DJI Osmo Pocket, Samsung Galaxy A8
Desktop :MB Gigabyte Z390M, W11 home version 24H2, i7 9700 4.7Ghz,16 DDR4 GB RAM, Gef. GTX 1660 Ti with driver
566.14 Studiodriver and Intel HD graphics 630 with driver 31.0.101.2130
Laptop  :Asus ROG Str G712L, W11 home version 23H2, CPU i7-10875H, 16 GB RAM, NVIDIA GeForce RTX 2070 with Studiodriver 576.02 and Intel UHD Graphics 630 with driver 31.0.101.2130
Vegas software: VP 10 to 22 and VMS(pl) 10,12 to 17.
TV      :LG 4K 55EG960V

My slogan is: BE OR BECOME A STEM CELL DONOR!!! (because it saved my life in 2016)

 

ad48hp wrote on 1/30/2021, 4:04 PM

Hey, i've meant the OFX parameter keyframe in the C# scripting api.. I put this in the category 'Scripting' ..

I've been writing a plug-in for Vegas Pro in that language, i search for a function that would allow me to Add / Change keyframes at specific position..

So let's say, for that image you posted..

 

Program.cs

Effects("AddNoise").KeyFrames("NoiseLevel").SetValue(0,1);

This adds a keyframe at Frame 0 (beggining) of that effect at value 1 ..

Effects("AddNoise").KeyFrames("NoiseLevel").SetValue(30,0)

This adds a keyframe at Frame 30 (second 1) of that effect at value 0...

So the final effect would be the noise getting lower to complete abscence at the Frame 30..

 

Do you wonder, Why i want to program this ?

Well, i'm trying to make an effect randomizer, that means, that it would create random keyframes with random values, because chaos fascinates me to a degree.. I can make that manually for few effects, but i wonder, how would it look like with 5 effects ? Or 20 effects ? As many as can my CPU handle in the rendering process..

I also want to make a noise effect, which would add tiny random values to the keyframes and their values, so i can see if my editing is precise by seeing how would it look like if it was a bit different..

I think that the bigger negative impact would the small changes make on the perceived quality, the more memorable would the original composition be.. If the changes would be positive, it would show me that i don't pay enough attention to specific effects to that extent..

jetdv wrote on 1/31/2021, 8:27 AM

Not sure which type of variable you're looking at changing but this will give you the general rule-of-thumb on how to add keyframes to effect:

OFXDouble2DParameter p2 = (OFXDouble2DParameter)ofx[Parameter];
  //Find the parameter to change
p2.IsAnimated = true;
  //If you're keyframing, this MUST be true

Timecode tc = //Timecode for the keyframe

OFXDouble2D oc;
oc.X = //x value
oc.Y = //y value

p2.SetValueAtTime(tc, oc);
 //Add a new keyframe at the tc timecode with the oc value

It does not matter what type of parameter it is, the above process will work to add keyframes.

 

ad48hp wrote on 8/10/2021, 1:29 PM

Hello and thankz, it worked, i also understand it more, now..

I found out that it's possible to change the keyframe directly, too..

if (parameter is OFXDoubleParameter)
                            {
                            var p = parameter as OFXDoubleParameter;
                            if (p.Keyframes.Count > 0)
                            {
                                for (int i = 0; i < p.Keyframes.Count; i += 1)
                                {
                                    p.Keyframes[i].Value = p.DisplayMin + (p.DisplayMax - p.DisplayMin) * ((double)i / (double)(p.Keyframes.Count - 1));
                                }
                            }
                            }