diff --git a/NEWS b/NEWS index 7ed269fc06..a9f1d07e19 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ ver 0.25 (not yet released) - vgmstream: new plugin * output - pipewire: add option "reconnect_stream" +* player + - support replay gain parameter in stream URI * switch to C++23 * require Meson 1.2 diff --git a/doc/user.rst b/doc/user.rst index cbe0bd8027..425896c108 100644 --- a/doc/user.rst +++ b/doc/user.rst @@ -678,6 +678,14 @@ prevents `Bit-perfect playback`_). To use a hardware mixer, set ``replay_gain_handler`` to ``mixer`` in the ``audio_output`` section (see :ref:`config_audio_output` for details). +The ``gain`` URL fragment can be used to apply ReplayGain tags to +Internet radios, which helps to normalize volume across different +radios, e.g.:: + + mpc add 'http://radio.example.com/stream#gain=-3.5' + +This will set "track" and "album" ReplayGain tags for the stream to -3.5 dB. + Simple Volume Normalization ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/decoder/Thread.cxx b/src/decoder/Thread.cxx index 60ff299f51..450072133c 100644 --- a/src/decoder/Thread.cxx +++ b/src/decoder/Thread.cxx @@ -21,8 +21,10 @@ #include "util/Domain.hxx" #include "util/ScopeExit.hxx" #include "util/StringCompare.hxx" +#include "util/UriQueryParser.hxx" #include "thread/Name.hxx" #include "tag/ApeReplayGain.hxx" +#include "tag/ReplayGainParser.hxx" #include "Log.hxx" #include @@ -277,6 +279,19 @@ LoadReplayGain(DecoderClient &client, InputStream &is) ReplayGainInfo info; if (replay_gain_ape_read(is, info)) client.SubmitReplayGain(&info); + + const char *fragment = uri_get_fragment(is.GetURI()); + if (fragment != nullptr) { + const auto gain = UriFindRawQueryParameter(fragment, "gain"); + if (gain.data() != nullptr) { + if (ParseReplayGainTag(info, "replaygain_track_gain", + std::string(gain).c_str())) { + info.album.gain = info.track.gain; + info.album.peak = info.track.peak = 0.0; + client.SubmitReplayGain(&info); + } + } + } } /**