Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions doc/user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
15 changes: 15 additions & 0 deletions src/decoder/Thread.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdexcept>
Expand Down Expand Up @@ -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);
}
}
}
}

/**
Expand Down
Loading