• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Layer starts over at comp marker

Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

I recently asked for help to correlate multiple keyframes to markers, and it worked really well. I now have a somewhat similar question for another part of the same project.

 

My question is two-fold. and it's a bit hard to explain. Here's what I'm working on.

 

Screenshot 2022-11-08 094532.jpg

 

My previous question was for the "Line" layer there, such that at each marker, the line goes from one dot on the timeline to the next. That works. What I'd like to do now is I'd like the "Camera flash" layer to start over each time it reaches the marker. "Camera Flash" is another comp in my project which I brought into this comp. Currently, obviously, it only plays once. I'd like for it to play as many times as I want without having to copy-paste the layer over and over. I want to be able to just place a marker, and it automatically plays again, no matter how many markers I have. I already gave a try myself at adapting Dan Ebberts's code, and I failed miserably. 😛

 

The second part of my question is wondering if this could be done with comp markers rather than layer markers, so that I can correlate both of these layers to the same markers. It would just make things easier. Alternatively, I do have a "Controller" layer in this comp, so it would also work for me if they were correlated to "Controller" layer markers rather than to comp markers.

 

If this second part isn't possible, that's fine. It would just further streamline my animation creation.

 

Thanks for any help you can offer!

TOPICS
Expressions , How to , Scripting

Views

213

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 08, 2022 Nov 08, 2022

This should work with comp markers:

m = thisComp.marker;
t = 0;
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time) n--;
  if (n > 0) t = time - m.key(n).time;
}
t

Votes

Translate

Translate
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Also, I doubt this matters much, but "Camera Flash" has both video and audio, and I'd like both to replay when it hits a marker.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

This should work with comp markers:

m = thisComp.marker;
t = 0;
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time) n--;
  if (n > 0) t = time - m.key(n).time;
}
t

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

You're the best. 🙂 Thanks.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

One other question. If I wanted to offset this code, such that it actually starts two frames before the marker, how would I do that?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Try this:

m = thisComp.marker;
t = 0;
f = 2; // start 2 frames before marker
d = framesToTime(f);
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time - d) n--;
  if (n > 0) t = time - (m.key(n).time - d);
}
t

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Yes, this works. Thanks.

There is an issue that I'm encountering, though. Every time it repeats, there's a tiny click noise that wasn't there before. Is there any way to address this?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Screenshot 2022-11-08 105333.jpg

 It looks like it's distorting the first frame or so of audio.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Yeah, what happens with time remapped audio is that when you reset it back to the start, you get an audible rewind over a 1-frame period, so somethines you need to add a 1-frame audio squelch to the Audio Levels property. Try this:

m = thisComp.marker;
f = 2; // start 2 frames before marker
d = framesToTime(f);
val = value;
t = 0;
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time - d) n--;
  if (n > 0){
    t = time - (m.key(n).time - d);
    if (t < thisComp.frameDuration*.9) val = [-192,-192];
  }
}
val

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

How odd. I guess that makes sense.

That code didn't work. I got an error.

Screenshot 2022-11-08 111853.jpg

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

I was already experimenting with an audio squelch, actually. I'm just trying to figure out how to do it automatically before each marker.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

It looks like you applied to Time Remap instead of Audio Levels

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

LATEST

Oh! I'm a doof.

I had to do a little bit of adjusting on the offset and duration, but this works great. Thanks so much again!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Markers are markers and aside from the syntax differences in adressing them AE doesn't care. Your repeats can easily be achieved by enabling time-remapping on your pre-comp. It would simply reset the time to zero every time you reach a marker and then play as normal.

 

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Alright, cool.

So, in the old code, I can just replace

m = marker;

with

m = thisComp.marker;

and I should be good to go then. Thanks!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines