Updating Expressions over time
Thanks in advance to anyone who takes the time to go down this rabbit hole, I would be really grateful to anyone who can help me get this working.
I've written an expression to calculate the average rate that layers switch on (become active):
//////time that each layer becomes active (in frames 50fps)
layer_01 = thisComp.layer("Layer 1").inPoint*50;
layer_02 = thisComp.layer("Layer 2").inPoint*50;
layer_03 = thisComp.layer("Layer 3").inPoint*50;
layer_04 = thisComp.layer("Layer 4").inPoint*50;
//////frame duration of gaps between layers
a = (layer_02 - layer_01);
b = (layer_03 - layer_02);
c = (layer_04 - layer_03);
d = (layer_05 - layer_04);
///////average duration of gaps between layers
This is working as I hoped.
Now, I would like to compare the frame duration of the gap most recent 2 layers with the overall average, like this:
which is also working great and gives me 0.97 (which is a kind of phase relationship between the average gap and the most recent gap).
Now the bit where I'm having trouble is calculating this value over time. As the play head moves through the composition, I want to compare the most recent gap with the overall average.
I'd hoped I'd be able to do this with a couple of arrays and an 'active layer counter' like this:
avArray = [(a+b),(a+b+c),(a+b+c+d)];
gapArray = [a,b,c,d];
layerCount = thisComp.layer("Layer 01").active+thisComp.layer("Layer 02").active+thisComp.layer("Layer 03").active+thisComp.layer("Layer 04").active;
(I know the expression would have needed a little tweaking as the array's start from )
Unfortunately, I got this far only to realise that you don't seem to be able to plug variables in to select from an Array, so my layerCount value was useless.
If anyone has read this far and has some ideas on how to help, it would be hugely appreciated.
Im on the phone, so that may get some things wrong but here is the idea:
My Envato portfolio.
Thanks for taking a look at this. I was hoping there would be a neater way of doing this that wouldn't require those array setups.
I've tried using the expression you have suggested but, I'm getting an error on line 1:
Error: inPoints is not defined
Please let me know if you can think of a fix for this.
This would be the first expression fixed:
And this would be a neat way to do it.
Put all those sequenced layers one after another in the timeline.init must be the index of the first one, layersNumber must be the nuber of the layers. The commented part of row 12 is the average. If you need the average, just take that commented text and replace the one in front.
My Envato portfolio.