-
Updating Expressions over time
Hi,
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
(a+b+c+d)/4
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:((a+b+c+d)/4)/d
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;(avArray[layerCount]/layerCount)/gapArray[layerCount]
(I know the expression would have needed a little tweaking as the array’s start from [0])
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.
Many thanks,
Laurie