Hello,

Max Kellermann schrieb:
> On 2010/05/17 12:15, Daniel Seuthe <daniel+...@seuthe.org>
> wrote:
>> The first allows to choose whether clipping prevention is used
>> while applying ReplayGain tags or not.
> 
> That changes the default behavior.  Is that a good idea?  I
> don't use replay gain myself, but there are lots of users
> caring about it.

I was not sure if this is a good idea too. You’re right the
default behaviour should not be changed.

> Since I don't use replay gain, I don't understand why this
> option is needed, could you explain?  I'd like to include the
> explanation in the commit message.

It’s not unusual that compressed formats like MP3 contain peak
>1. Now imagine a song with gain of 0 dB and peak of 2.0. So the
volume level should not be touched. The current implementation
scales the volume down by 2 (level reduced by 6 dB!) although
there is no reason for clipping prevention.

Clipping is possible of course but it depends on both the gain
and peak. So the clipping prevention should be configurable.
Foobar2000 and RockBox did have such an option too.

I’m using ReplayGain without clipping prevention for years now
with success.

>> The second pay attention to the ReplayGain mode ???auto??? and
>> the replay_gain_missing_preamp parameter inside of
>> decoder_replay_gain().
> 
> That includes an unrelated change - you moved the
> replay_gain_tuple_defined() check into
> replay_gain_tuple_scale().  I wouldn't do that, because that
> makes replay_gain_info.c depend on a global variable from
> replay_gain_config.c.  Right now, replay_gain_info.c doesn't
> depend on anything.

I see. So please take a look at the attached patch. I think
it’s a solution.

Daniel

diff --git a/doc/mpd.conf.5 b/doc/mpd.conf.5
index 78664f9..08b4053 100644
--- a/doc/mpd.conf.5
+++ b/doc/mpd.conf.5
@@ -174,9 +174,9 @@ documentation (available online at 
<\fBhttp://www.mega-nerd.com/SRC/\fP>).
 If specified, mpd will adjust the volume of songs played using ReplayGain tags
 (see <\fBhttp://www.replaygain.org/\fP>).  Setting this to "album" will adjust
 volume using the album's ReplayGain tags, while setting it to "track" will
-adjust it using the track ReplayGain tags.  "auto" uses the track ReplayGain
-tags if random play is activated otherwise the album ReplayGain tags. Currently
-only FLAC, Ogg Vorbis, Musepack, and MP3 (through ID3v2 ReplayGain tags, not
+adjust it using the track ReplayGain tags.  "auto" uses the track ReplayGain 
+tags if random play is activated otherwise the album ReplayGain tags. 
Currently 
+only FLAC, Ogg Vorbis, Musepack, and MP3 (through ID3v2 ReplayGain tags, not 
 APEv2) are supported.
 .TP
 .B replaygain_preamp <-15 to 15>
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 60d2830..6d3cd80 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -420,7 +420,7 @@ decoder_replay_gain(struct decoder *decoder,
                        return_db = 20.0 * log10f(
                                replay_gain_tuple_scale(
                                        
&replay_gain_info->tuples[replay_gain_get_real_mode()],
-                                       replay_gain_preamp));
+                                       replay_gain_preamp, 
replay_gain_missing_preamp, replay_gain_limit));
                }
 
                decoder->replay_gain_info = *replay_gain_info;
diff --git a/src/filter/replay_gain_filter_plugin.c 
b/src/filter/replay_gain_filter_plugin.c
index 9405aca..944d7fe 100644
--- a/src/filter/replay_gain_filter_plugin.c
+++ b/src/filter/replay_gain_filter_plugin.c
@@ -80,7 +80,8 @@ replay_gain_filter_update(struct replay_gain_filter *filter)
        if (filter->mode != REPLAY_GAIN_OFF) {
                const struct replay_gain_tuple *tuple =
                        &filter->info.tuples[filter->mode];
-               float scale = replay_gain_tuple_scale(tuple, 
replay_gain_preamp);
+               float scale = replay_gain_tuple_scale(tuple, 
replay_gain_preamp, 
+                   replay_gain_missing_preamp, replay_gain_limit);
 
                filter->volume = pcm_float_to_volume(scale);
        } else
diff --git a/src/replay_gain_config.c b/src/replay_gain_config.c
index 753c79d..4acdc36 100644
--- a/src/replay_gain_config.c
+++ b/src/replay_gain_config.c
@@ -37,7 +37,7 @@ static const char *const replay_gain_mode_names[] = {
 
 enum replay_gain_mode replay_gain_mode = REPLAY_GAIN_OFF;
 
-const bool DEFAULT_REPLAYGAIN_LIMIT = false;
+const bool DEFAULT_REPLAYGAIN_LIMIT = true;
 
 float replay_gain_preamp = 1.0;
 float replay_gain_missing_preamp = 1.0;
diff --git a/src/replay_gain_info.c b/src/replay_gain_info.c
index adab267..4df15aa 100644
--- a/src/replay_gain_info.c
+++ b/src/replay_gain_info.c
@@ -19,12 +19,9 @@
 
 #include "config.h"
 #include "replay_gain_info.h"
-#include "replay_gain_config.h"
-
-#include <glib.h>
 
 float
-replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp)
+replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, 
float rg_missing_preamp, bool peak_limit)
 {
        float scale;
 
@@ -35,16 +32,14 @@ replay_gain_tuple_scale(const struct replay_gain_tuple 
*tuple, float preamp)
                if (scale > 15.0)
                        scale = 15.0;
 
-               if (replay_gain_limit)
+               if (peak_limit)
                        if (scale * tuple->peak > 1.0)
                                scale = 1.0 / tuple->peak;
 
        } else {
-               scale = replay_gain_missing_preamp;
+               scale = rg_missing_preamp;
        }

-       g_debug("replay_gain_tuple_scale: %f", scale);
-
        return scale;
 }
 
diff --git a/src/replay_gain_info.h b/src/replay_gain_info.h
index 49f375b..c30f8bd 100644
--- a/src/replay_gain_info.h
+++ b/src/replay_gain_info.h
@@ -62,7 +62,7 @@ replay_gain_tuple_defined(const struct replay_gain_tuple 
*tuple)
 }
 
 float
-replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp);
+replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, 
float rg_missing_preamp, bool peak_limit);
 
 /**
  * Attempt to auto-complete missing data.  In particular, if album
------------------------------------------------------------------------------

_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to