Add a MetaflacBackend that computes ReplayGain for FLAC files with metaflac --add-replay-gain and reads the values back with --show-tag. Only FLAC is supported. Includes docs, a changelog entry, and tests.
There are two ways to store replay gain data on music files: RG_ and
R128_ (opus). before this change the beets replaygain plugin simply set
the right tag based on file format and r128 config value.
there are case, however, when for example an opus files comes with RG_
tags already set. After beet write its replaingain tags the files will
contain both RG_ and R128_ tags with possibly conflicting values.
For example, Navidrome currently always prefers RG_ tags over R128_
regardless of format, leading tags set by beets to be ignored.
https://github.com/navidrome/navidrome/blob/23f3556371321faf199866989b906f2ef06a8034/model/metadata/map_mediafile.go#L111
As per RFC 7845: Ogg Encapsulation for the Opus Audio Codec
https://datatracker.ietf.org/doc/html/rfc7845#section-5.2.1
> To avoid confusion with multiple normalization schemes, an Opus
> comment header SHOULD NOT contain any of the REPLAYGAIN_TRACK_GAIN,
> REPLAYGAIN_TRACK_PEAK, REPLAYGAIN_ALBUM_GAIN, or
> REPLAYGAIN_ALBUM_PEAK tags, unless they are only to be used in some
> context where there is guaranteed to be no such confusion.
Since the replaygain plugin does not support setting both RG_ and R128_
at the same time it doesn't make much sense to keep conflicting tags
when writing. These tags are also easy to recalculate if needed either
with beets itself (with a different configuration), or by running
replaygain commands by hand. no valuable information is lost.
This change makes it so the replagain plugin now deletes conflicting
tags when processing library items:
* RG_ are deleted if we set R128_
* R128_ are deleted if we set RG_
A constant `preload_plugin` is used to disable loading the plugin in the
`setUp` initialisation, allowing the plugin to be loaded manually by the
tests.
Also added a cleanup instruction to remove listeners from configured
plugins, and removed this logic from several tests.
External Python packages interfacing beets may want to use an in-memory
beets library instance for testing beets-related code.
The `TestHelper` class is very helpful for this purpose.
Previously `TestHelper` was located in the `test/` directory.
Now it is part of `beets` itself (`beets.test.helper.TestHelper`) and
can be easily imported.