Copy link to clipboard
Copied
Ok, I've taken an epxression for automactically fading opacity (which worked wonderfully) and tried to modify it to fade audio the same way. Now, I get an error that says "After Effects warning: Expression Disabled. Error at line 0 in property.... expression result must be of dimension 2 not 1."
Here is the tweaked expression:
fadeTime = 30;
audio.audioLevelsMin = -50;
audio.audioLevelsMax = 0;
layerDuration = outPoint - inPoint;
singleFrame = thisComp.frameDuration;
animateIn = linear(time, inPoint, (inPoint + framesToTime(fadeTime)), audio.audioLevelsMin, audio.audioLevelsMax);
animateOut = linear(time, (outPoint - framesToTime(fadeTime+1)), (outPoint-singleFrame), audio.audioLevelsMax, audio.audioLevelsMin);
if(time < (layerDuration/2+inPoint)){
animateIn;
}else{
animateOut;
}
Now, opacity is a linear, 1 dimensional characteristic. Why did that work and the updated expression for audio cause an error?
Try it this way:
fadeTime = 30;
audio.audioLevelsMin = -50;
audio.audioLevelsMax = 0;
layerDuration = outPoint - inPoint;
singleFrame = thisComp.frameDuration;
animateIn = linear(time, inPoint, (inPoint + framesToTime(fadeTime)), audio.audioLevelsMin, audio.audioLevelsMax);
animateOut = linear(time, (outPoint - framesToTime(fadeTime+1)), (outPoint-singleFrame), audio.audioLevelsMax, audio.audioLevelsMin);
if(time < (layerDuration/2+inPoint)){
[animateIn,animateIn];
}else{
[animateOut,animateOut];
}
Dan
Copy link to clipboard
Copied
Try it this way:
fadeTime = 30;
audio.audioLevelsMin = -50;
audio.audioLevelsMax = 0;
layerDuration = outPoint - inPoint;
singleFrame = thisComp.frameDuration;
animateIn = linear(time, inPoint, (inPoint + framesToTime(fadeTime)), audio.audioLevelsMin, audio.audioLevelsMax);
animateOut = linear(time, (outPoint - framesToTime(fadeTime+1)), (outPoint-singleFrame), audio.audioLevelsMax, audio.audioLevelsMin);
if(time < (layerDuration/2+inPoint)){
[animateIn,animateIn];
}else{
[animateOut,animateOut];
}
Dan
Copy link to clipboard
Copied
It worked!! I see the small change that you made at the end with [animateIn,animateIn]; How did that effect the process? Was it like giving it an extra coordinate??
Copy link to clipboard
Copied
Yes, stereo audio level is a two-dimensional property, so you need to provide two values, in array notation.
Dan
Copy link to clipboard
Copied
I have a similar question (I think)... where I have several pre comps that have different lengths, but use the same .wav file for the background music. The end of the .wav file has a chime timed to the motion at the end of the pre-comp. I'd like to be able to copy/paste the .wav file into my pre-comps, align the chime with the animation at the end, and let an expression handle the fade-up at the beginning of the pre-comp, so I don't have to go in and manually adjust keyframes.
UPDATE:
It works, but only if I trim the layer to the beginning of the comp. If I just slide the layer and don't trim the inPoint of the layer... it doesn't work. Could the above expression be modified to use the comp's In and Out instead?
Copy link to clipboard
Copied
Something like this maybe:
fadeTime = 30;
audio.audioLevelsMin = -50;
audio.audioLevelsMax = 0;
animateIn = linear(time,0,framesToTime(fadeTime), audio.audioLevelsMin, audio.audioLevelsMax);
[animateIn,animateIn];
Dan
Copy link to clipboard
Copied
Mr. Ebberts... I don't ask for help on here very often. And when I do, I'm always expecting someone to say, "Read the manual." or "Let me Google that for you." But, usually what happens is that—within 24 hours, usually—I get a response from a Dan Ebberts (and a few other regulars) that absolutely sets me on the right path, if not solve my problem directly.
This is another home run. Thank you sir!
Consider the next beer/tab/round that someone else picks up on your behalf as "inspired" by my gratitude! Thank you!
Copy link to clipboard
Copied
fadeTime = 30;
audio.audioLevelsMin = -50;
audio.audioLevelsMax = 0;
animateIn = linear(time,0,framesToTime(fadeTime), audio.audioLevelsMin, audio.audioLevelsMax);
[animateIn,animateIn];
This expression solved my problem, but then I created another one:
I want to move this expression onto a controller in my main comp so I only have to edit values for audioLevelsMin/Max in one place and have it propagate across all instances of the music track in a variety of pre-comps.
Am I thinking about this correctly?
Copy link to clipboard
Copied
You could try this on your slider:
fadeTime = 30;
audioLevelsMin = -50;
audioLevelsMax = 0;
linear(time,0,framesToTime(fadeTime), audioLevelsMin, audioLevelsMax);
and then link each audio level to it with something like this:
animateIn = comp("Main Comp").layer("Null 1").effect("Slider Control")("Slider");
[animateIn,animateIn]
Dan
Copy link to clipboard
Copied
thanks Dan (again)!
I think what was breaking my previous attempt was that I was looking for audio.audioLevelsMin/Max where no audio property existed.
I appreciate the help!
Copy link to clipboard
Copied
Replying to an ollllld post for posterity:
This expression – specifically the part that creates new properties on the property group 'audio' (audio.audioLevelsMax and audio.audioLevelsMin) – will fail on a royalty-free render-only node (with 2020, at least). It *appears* that the audio property group disallows creation of new properties when in render-only mode. The expression works perfectly fine in the fully-licensed UI but will effectively be ignored during render (leading to Very Loud Audio).
The fix is simple: use top-level variables instead, eg. use 'audioLevelsMin = -50' instead of 'audio.audioLevelsMin = -50'