AE Extendscript - 音频的指数自动增长表达式

时间:2017-10-23 13:32:23

标签: extendscript after-effects

我一直在使用线性自动渐变表达式来自动淡化背景音乐的结尾,只需添加以下表达式:

fadeTime = 9; 
audio.audioLevelsMin = -50; 
audio.audioLevelsMax = 0; 
layerDuration = outPoint - inPoint; 
singleFrame = thisComp.frameDuration; 
animateOut = linear(time, (outPoint - fadeTime+1), (outPoint-singleFrame), audio.audioLevelsMax, audio.audioLevelsMin); 
[animateOut,animateOut];

然而,这只是一个线性淡化。我想创建一个指数淡入淡出。这甚至可以用于表达式吗?

指数可能不是完全正确的单词 - 因此,由于缺乏正确的单词,我在下方发布图片以显示我的意思:

enter image description here

1 个答案:

答案 0 :(得分:0)

你想要的淡入淡出在x = -1和x = 1的值之间看起来像y = 0 - (x ^ 3)。

enter image description here 因此,我们通过创建一个从-1到1的规范化变量t将淡入淡出映射到该范围,然后将其立方体化,然后将其映射回1-0范围

enter image description here

fadeTime = 9; 
levelsMin = -50; 
levelsMax = 0; 

//not sure why you want to add an extra second to the fade time, but I included the + 1
fadeStart =  outPoint - fadeTime+1; 

t = linear(time, fadeStart, outPoint, 1, -1); //t goes from 1 to -1 over the fade
fade = 0.5 + Math.pow(t, 3)/2; // goes from 1 to 0, but with the curve you want
// map 1 → 0 ⇒ levelsMax → levelsMin
finalLevel = levelsMin + fade * (levelsMax - audio.audioLevelsMin);
[finalLevel, finalLevel]