AE Extendscript - 音频的指数自动淡入淡出表达式

AE Extendscript - exponential autofade expression for audio

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

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];

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

指数可能不是完全正确的词 - 所以由于不知道正确的词,我在下面张贴一张图片来说明我的意思:

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

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

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]