Skip to content

Instantly share code, notes, and snippets.

@dokluch
Last active August 29, 2015 14:23
Show Gist options
  • Save dokluch/3472bc2bda064992d75c to your computer and use it in GitHub Desktop.
Save dokluch/3472bc2bda064992d75c to your computer and use it in GitHub Desktop.
Keyframe accumulator for After Effects
var audioSource = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
var step = 1; // step in frames
var accum = 0;
if(audioSource.numKeys > 0){
var k = 0;
if(time >= step*2){
while(k <= time){
if(audioSource.valueAtTime(k) > audioSource.valueAtTime(k - step*thisComp.frameDuration)){
accum+=audioSource.valueAtTime(k)-audioSource.valueAtTime(k - step*thisComp.frameDuration)
}
k+=step*thisComp.frameDuration;
};
};
};
value = accum;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment