Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaygain: target level refactor #3065

Open
wants to merge 7 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@zsinskri
Copy link
Contributor

commented Oct 28, 2018

Remove REPLAYGAIN_* vs R128_* tag handling from the Backends, restrict it to the main plugin logic. That is archieved by passing the target loudness level to the backend with every album/track. It also necessitates that all Backends properly implement the target level.
As the different tag formats call for different default target levels this also seperates the configuration of those levels.

@zsinskri

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

The latest push merges master (or rather #3056, from which this branch was forked), resolving conflicts. It also fixes the ReplayGainLdnsCliMalformedTest, which caused unrelated tests to fail, due to missing cleanup.

@zsinskri

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

Is there any guideline on when to merge and when to rebase for this project? I will rework this branch's structure if a rebase is preferred.

@zsinskri zsinskri force-pushed the zsinskri:r128-targetlevel-config branch from 29418b9 to 26b83b0 Jun 19, 2019

zsinskri added a commit to zsinskri/beets that referenced this pull request Jun 19, 2019

replaygain: ffmpeg: set targetlevel for R128_*_GAIN tags
When using the ffmpeg replaygain backend to create R128_*_GAIN tags,
automatically set the targetlevel to -23 LUFS.

Note: This will be made configurable by GitHub PullRequest beetbox#3065

zsinskri added a commit to zsinskri/beets that referenced this pull request Jul 14, 2019

replaygain: add ffmpeg backend
Add replaygain backend using ffmpeg's ebur128 filter.

The album gain is calculated as the mean of all BS.1770 gating block powers.
Besides differences in gating block offset, this should be equivalent to a
BS.1770 analysis of a proper concatenation of all tracks.

Just calculating the mean of all track gains (as implemented by the bs1770gain
backend) yields incorrect results as that would:
- completely ignore track lengths
  - just using length in seconds won't work either (e.g. BS.1770 ignores
    passages below a threshold)
- take the mean of track loudness, not power

When using the ffmpeg replaygain backend to create R128_*_GAIN tags, the
targetlevel will be set to -23 LUFS. GitHub PullRequest beetbox#3065 will make this
configurable.
It will also skip peak calculation, as there is no R128_*_PEAK tag.

It is checked if the libavfilter library supports replaygain calculation. Before
version 6.67.100 that did require the `--enable-libebur128` compile-time-option,
after that the ebur128 library is included in libavfilter itself. Thus we
require either a recent enough libavfilter version or the `--enable-libebur128`
option.

zsinskri added a commit to zsinskri/beets that referenced this pull request Jul 19, 2019

replaygain: add ffmpeg backend
Add replaygain backend using ffmpeg's ebur128 filter.

The album gain is calculated as the mean of all BS.1770 gating block powers.
Besides differences in gating block offset, this should be equivalent to a
BS.1770 analysis of a proper concatenation of all tracks.

Just calculating the mean of all track gains (as implemented by the bs1770gain
backend) yields incorrect results as that would:
- completely ignore track lengths
  - just using length in seconds won't work either (e.g. BS.1770 ignores
    passages below a threshold)
- take the mean of track loudness, not power

When using the ffmpeg replaygain backend to create R128_*_GAIN tags, the
targetlevel will be set to -23 LUFS. GitHub PullRequest beetbox#3065 will make this
configurable.
It will also skip peak calculation, as there is no R128_*_PEAK tag.

It is checked if the libavfilter library supports replaygain calculation. Before
version 6.67.100 that did require the `--enable-libebur128` compile-time-option,
after that the ebur128 library is included in libavfilter itself. Thus we
require either a recent enough libavfilter version or the `--enable-libebur128`
option.

zsinskri added some commits Jul 22, 2019

fix bs1770gain test
This test caused other tests to fail due to missing cleanup.
replaygain: pass target_level and peak to backends
Configure the replaygain analysis by passing arguments to the Backends. This
avoids the difference between ReplayGain and EBU r128 backends; every Backend
can now fulfil both tasks. Additionally it eases Backend development as the
difference between the two tag formats is now completely handled in the main
Plugin, not in the Backends.
replaygain: targetlevel and peak_method depends on tag format
Allow to configure the target level for R128_* tags separately from REPLAYGAIN_*
tags and skip peak calculation for R128_* tags if possible.
update replaygain target level documentation
- document `r128_targetlevel`
- explain difference between `targetlevel` and `r128_targetlevel`
- deprecate `method` option: use `targetlevel` instead.
replaygain: add target_level test
Assert that analysing the same track with different target levels yields
different gain adjustments.
replaygain: add R128_* tag test
Assert that the replaygain plugin does not write REPLAYGAIN_* tags but R128_*
tags, when instructed to do so.

This test is skipped for the `command` backend as it does not support OPUS.
changelog: new `r128_targetlevel` option
Add changelog entries for the introduction of the `r128_targetlevel`
configuration option, superseding the `method` option.

@zsinskri zsinskri force-pushed the zsinskri:r128-targetlevel-config branch from d0b9749 to da602d7 Jul 22, 2019

@zsinskri

This comment has been minimized.

Copy link
Contributor Author

commented Jul 22, 2019

Rebased onto master.

@zsinskri

This comment has been minimized.

Copy link
Contributor Author

commented Jul 22, 2019

#3056 is merged. This is now ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.