diff options
-rw-r--r-- | DOCS/man/af.rst | 4 | ||||
-rw-r--r-- | audio/filter/af_volume.c | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/DOCS/man/af.rst b/DOCS/man/af.rst index 9c6fd9aad7..15bc3050e6 100644 --- a/DOCS/man/af.rst +++ b/DOCS/man/af.rst @@ -287,6 +287,10 @@ Available filters are: ``replaygain-clip=yes|no`` Prevent clipping caused by replaygain by automatically lowering the gain (default). Use ``replaygain-clip=no`` to disable this. + ``replaygain-fallback`` + Gain in dB to apply if the file has no replay gain tags. This option + is always applied if the replaygain logic is somehow inactive. If this + is applied, no other replaygain options are applied. ``softclip`` Turns soft clipping on. Soft-clipping can make the sound more smooth if very high volume levels are used. Enable this diff --git a/audio/filter/af_volume.c b/audio/filter/af_volume.c index dfdf586690..8de9d8dfa9 100644 --- a/audio/filter/af_volume.c +++ b/audio/filter/af_volume.c @@ -37,6 +37,7 @@ struct priv { int rgain_album; // Enable/disable album based replaygain float rgain_preamp; // Set replaygain pre-amplification int rgain_clip; // Enable/disable clipping prevention + float replaygain_fallback; int soft; // Enable/disable soft clipping int fast; // Use fix-point volume control int detach; // Detach if gain volume is neutral @@ -82,6 +83,9 @@ static int control(struct af_instance *af, int cmd, void *arg) s->rgain = MPMIN(s->rgain, 1.0 / peak); MP_VERBOSE(af, "...with clipping prevention: %f\n", s->rgain); } + } else if (s->replaygain_fallback) { + af_from_dB(1, &s->replaygain_fallback, &s->rgain, 20.0, -200.0, 60.0); + MP_VERBOSE(af, "Applying fallback gain: %f\n", s->rgain); } if (s->detach && fabs(s->level * s->rgain - 1.0) < 0.00001) return AF_DETACH; @@ -165,6 +169,7 @@ const struct af_info af_info_volume = { OPT_FLAG("replaygain-album", rgain_album, 0), OPT_FLOATRANGE("replaygain-preamp", rgain_preamp, 0, -15, 15), OPT_FLAG("replaygain-clip", rgain_clip, 0), + OPT_FLOATRANGE("replaygain-fallback", replaygain_fallback, 0, -200, 60), OPT_FLAG("softclip", soft, 0), OPT_FLAG("s16", fast, 0), OPT_FLAG("detach", detach, 0), |