Page 1 of 1

Time remap a Precomp(loop), to sync to layer markers

Posted: December 9th, 2006, 7:06 am
by mauroz
Hi there,

I'm trying to time remap a loop I have in a Pre-comp so that in the main comp it start always when the time cursor hit a layer marker.
Basically I need strech the duration of the Pre-comp so that it always fit the distance between two layer markers.

I tried Dan Ebberts' express:

hit=marker.key(1).time;
t=time-this_comp.layer("audio.wav").marker.nearest_key(time).time;
t+hit

but the loop stop at half time of the animation.
I think because the time cursor as soon as it cross half of the loop is getting the value of the next layer marker.
I also try to add some statement but with no luck..
Does anybody have any idea?

Mauro
xxxxxxxxxxxxxxxxx

Posted: December 10th, 2006, 11:14 am
by Dan Ebberts
Try this one. It should get you close. Change "marker layer" to the name of your layer where the markers will be.

L = thisComp.layer("marker layer");

p = 0;
if (L.marker.numKeys > 0){
p = L.marker.nearestKey(time).index;
if (L.marker.key(p).time > time){
p--;
}
}

n = 0;
if (L.marker.numKeys > 0){
n = L.marker.nearestKey(time).index;
if (L.marker.key(n).time <time> L.marker.numKeys) n = 0;
}
}

if ((p == 0) || (n == 0)){
inPoint
}else{
linear(time,L.marker.key(p).time,L.marker.key(n).time,inPoint,inPoint + source.duration)
}


Dan

Posted: December 10th, 2006, 2:57 pm
by Dan Ebberts
Yikes! The forum formatting trashed my code. Let me try it again:

L = thisComp.layer("marker layer");

p = 0;
if (L.marker.numKeys > 0){
p = L.marker.nearestKey(time).index;
if (L.marker.key(p).time > time){
p--;
}
}

n = 0;
if (L.marker.numKeys > 0){
n = L.marker.nearestKey(time).index;
if (L.marker.key(n).time <= time){
n++;
if (n > L.marker.numKeys) n = 0;
}
}

if ((p == 0) || (n == 0)){
inPoint
}else{
linear(time,L.marker.key(p).time,L.marker.key(n).time,inPoint,inPoint + source.duration)
}

Posted: December 10th, 2006, 5:48 pm
by mauroz
Dan,

What can I say....

I love you!!!


[thanks]


xxxxxxxxxxxxxxxxxxxx
Mauro
[/b]

Posted: December 11th, 2006, 1:42 pm
by Disciple
Dan, in case you don't know this, you can use the "code" tags to keep clean code formatting on the forum

HTH

Alex