More Audio Transitions & Fades

Currently, Shotcut only has one audio transition available but considering the different scenarios that present themselves in editing, more audio transitions are needed. I first mentioned it in this thread here almost a year ago.

Premiere and Resolve both have 3 kinds of audio transitions. Premiere has Constant Gain, Constant Power and Exponential Fade. Resolve has a +3dB Cross Fade, a -3 dB Cross Fade and a 0dB Cross Fade.

So Shotcut could at least add two more but if more could be added that’d be great. I think Shotcut’s only audio transition is the equivalent of Premiere’s Constant Gain. Shotcut definitely should have Constant Power as it’s very useful and common. From there Exponential Fade could also be added to match the same options that Premiere has. There’s other kinds of transitions/fades available like Logarithmic Fade. Here is a list from Audacity. It’d be nice if these can also be added as more options for the Fade In/Out audio filters.

Interestingly enough, Audacity has two Constant Power transitions. Here is the page on that.

2 Likes

I’d like to 2nd this request as strongly as I possibly can. It’s the one feature that’s preventing me from using Shotcut as my main video editor.

While there is a way to achieve equal power fades (Keyframe volume/gain filter automation) It’s pretty time consuming and doesn’t play terribly well with crossfading between multiple audio tracks.

I’d suggest looking at the fade behavior in REAPER (reaper.fm to download) as a model (selectable default and selectable curves on right click of the fade handle)

I’ve seen some discussion on the merits of different fade types. I’m happy to provide audio examples so folks can hear the difference themselves. I’m certain that folks will find equal power fades more closely match their expectations for what a fade sounds like.

1 Like

Please do.

Sure thing: Here goes. I decided to go with 5 second fade durations:

UPDATE: Looks like I can’t embed the audio here, and am limited in the number of replies I can post here. Will wait for someone to reply here before adding the rest of the audio

This is Track 1 from the Image. A “linear” fade (I don’t want to get too caught up on names, because that can be distracting)

I use this shape for longer gradual fadeouts.

Here’s Track 2, an Equal Power fade:
This fade shape is VITAL for smooth crossfades that maintain a constant loudness and creating seamless audio loops

Thank you. I’m on my phone right now so it’s hard to judge, but it feels like your second example sounds like the actual audio fade-out filter in Shotcut. What do you think?

Thanks for replying. On with the examples! (Track4 is the same shape as the audio fade out in Shotcut. We’ll get to that last)
Here’s Track 3, an inverse Equal power fade, which is another common fade type, it’s quick, but not TOO quick.

Here’s the 4th track in the image, a logarithmic fade, which is what shotcut uses for its audio fades. (Linear gain change = logarithmic perceived volume change)

I’m not an expect in this but maybe we could look through the Code or ask a Developer and find where the current logarithmic fade is implemented.

I found a code example in Javascript of a Linear fade : How to playback HTML audio with fade in and fade out with JavaScript? - The Web Dev

At the moment, I don’t have enough skills to make this work in SC but later I might.

Also, I know that it’s not Qt C++ code but there’s an argument to say that having the ability to code various effects and filters in Javascript or Python would broaden SC to make it more accessible to Artistic types.

The “Fade Out” filter uses the volume service from MLT:

The “Fade Out” filter animates the gain from 0dB to -60dB over the duration of the filter:

The volume service calculates the dB gain for each frame using DBFSTOAMP()

The DBFSTOAMP() calculates the full scale gain factor from the decibel value using inverse log

The value of each sample is scaled according to the full scale gain factor:

2 Likes

Thanks Brian. That’s my question answered.

Thank you for taking the time to find the code so quickly. I understand what it’s saying now.

I think that the revised Fade In/Out Audio filters might look something like this.

mockup

and that implementation would mainly comprise of going away and finding the appropriate mathematical formula and modifying the DBFSTOAMP() function or just the surrounding code.

Then, I just noticed this:

Which means that changing the algorithm could actually be relatively straightforward if we knew what Trigonometrical function we need to change it to.

I asked the audio engineer on my team for his opinion, he came back with this:
So for equal power crossfade, a common solution I’ve seen (and used) is to use a cosine curve for fading out:

and a sine for fading in

Which would look something like:

#include <math.h>

float equalPowerFadeOut(float position) { // Position goes from 0-1
    return cos(position * M_PI * 0.5f);
}

float equalPowerFadeIn(float position) {
    return sin(position * M_PI * 0.5f);
}

Or actually
sin(position * M_PI * 0.5f)
is the same as
cos((1.f-position) * M_PI * 0.5f)
so you could also just use the single cosine function and just pass position for the fade-out and
1.f - position
for the fade-in (or vice versa, using the sine function)

1 Like