Commit graph

191 commits

Author SHA1 Message Date
ybnd
63ea17365a Modify patched stdout in test_malformed_output 2020-02-05 09:04:24 +01:00
ybnd
7005691410 Add comment to clarify unexpected AttributeError handling 2020-02-05 08:52:50 +01:00
ybnd
bef473c8e8 Remove spliced progress regex and add --suppress-progress flag 2020-01-31 07:42:50 +01:00
ybnd
506be02597 Remove packaging dependency 2020-01-30 20:11:09 +01:00
ybnd
c3817a4c06 Implement review comments
* safer version comparison

* regex bytes directly

* handle b'\x08 ...' case

* test_replaygain.py: injected command output should match the type of the actual output
2020-01-30 19:21:53 +01:00
ybnd
c1cb78c908 Small fixes in replaygain.Bs1770gainBackend and test_replaygain.py
* Fix unspecified `gain_adjustment` when method defined in config

* Fix difference between dB and LUFS values in case of mismatched `target_level`/`method`:

  ```
  db_to_lufs( target_level <dB> ) - lufs_to_dB( -23 <LUFS> )
  ```

* Ignore single assertion in case of bs1770gain

(cherry picked from commit 2395bf224032c44f1ea5d28e0c63af96a92b96df)
2020-01-30 17:59:57 +01:00
ybnd
c78afb1a97 Don't call bs1770gain outside of try statement 2020-01-30 17:02:28 +01:00
ybnd
53820c0a98 Handle bs1770gain v0.6.0 XML output
* Remove `0%\x08\x08` from output (backspace code doesn't resolve; progress percentages get spliced in)

* Handle changed attributes/fields:
  * `sample-peak` attribute `factor` is called `amplitude` instead
  * Album summary is not included in a `summary` tag now, but in two separate `integrated` and `sample-peak` tags

* Handle `lu` attribute

* Get bs1770gain version
  * If v0.6.0 or later, add `--unit=ebu` flag to convert `db` attributes to LUFS
  * May be useful later on

### Output examples

Track:
```
<!-- analyzing ... -->
<bs1770gain norm="-18.00">
  <track total="1" number="1" file="02 tïtle 0.mp3">
    <integrated lufs="-70.00" lu="52.00"/>
    <sample-peak spfs="-72.28" amplitude="0.00"/>
  </track>
  <integrated lufs="-70.00" lu="52.00"/>
  <sample-peak spfs="-72.28" amplitude="0.00"/>
</bs1770gain>
<!-- done. -->
```

Album:
```
<!-- analyzing ... -->
<bs1770gain norm="-18.00">
  <track total="2" number="1" file="02 tïtle 0.mp3">
    <integrated dbfs="-70.00" db="52.00"/>
    <sample-peak dbfs="-72.28" amplitude="0.00"/>
  </track>
  <track total="2" number="2" file="02 tïtle 1.mp3">
    <integrated dbfs="-70.00" db="52.00"/>
    <sample-peak dbfs="-72.28" amplitude="0.00"/>
  </track>
  <integrated dbfs="-70.00" db="52.00"/>
  <sample-peak dbfs="-72.28" amplitude="0.00"/>
</bs1770gain>
<!-- done. -->
```
2020-01-30 16:13:29 +01:00
Jack Wilsdon
d91da56745
Fix various typos 2019-10-10 08:50:09 +01:00
Samuel Nilsson
6e24669d61 Fix #3341 2019-08-03 22:51:40 +02:00
Samuel Nilsson
60c174101f ffmpeg replaygain backend: Only calculate replaygain for audio stream. Fixed documentation for backend option. 2019-07-29 10:32:19 +02:00
Zsin Skri
a9f70f8151 apply suggested improvements
Apply improvements suggested in GitHub PullRequest #3065:
- be idiomatic
  - 0 is falsy
  - check enum equality, not identity
  - mutate list by constructing a new one
- improve documentation
  - fix a typo
  - do not mention deprecation of a config option
2019-07-26 01:02:03 +02:00
Zsin Skri
e7e2c424e7 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.
2019-07-22 13:42:22 +02:00
Zsin Skri
0c8eead459 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.
2019-07-22 12:58:54 +02:00
Zsin Skri
e5f2fe6fd3 avoid test failure
Use the POSIX character class instead of `\s` to match all whitespace in a
regular expression describing the language of valid inputs, in order to avoid a
test failure for the invalid escape sequence `\s` in Python strings.
2019-07-21 01:28:16 +02:00
Zsin Skri
f9ff56f496 improve wording in the ffmpeg replaygain backend
This commit mostly addresses feedback:
- remove some unused parenthesis
- fix a typo
- expand some docstrings
- document that ffmpeg is usually easy to install
2019-07-21 01:18:49 +02:00
Zsin Skri
271a3c980c replaygain: ffmpeg: increase parser readability
Use keyword arguments to make the ffmpeg parser more readable.
2019-07-19 21:54:47 +02:00
Zsin Skri
c3af5b3763 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 #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.
2019-07-19 21:54:47 +02:00
Zsin Skri
7a7314ee3f Allow other ReplayGain backends to support R128.
Previously using EBU R128 forced the use of the bs1770gain backend.
This change adds a whitelist of backends supporting R128. When the configured
backend is in that list it will also be used for R128 calculations. Otherwise
bs1770gain is still used as a default.

This should not change the overall behaviour of the program at all, but allow
for further R128-supporting backends to be added.
2019-07-19 21:54:47 +02:00
Zsin Skri
30395911e2 util.command_output: return stderr, too
Return a namedtuple CommandOutput(stdout, stderr) instead of just stdout from
util.command_ouput, allowing separate access to stdout and stderr.

This change is required by the ffmpeg replaygain backend (GitHub
PullRequest #3056) as ffmpeg's ebur128 filter outputs only to stderr.
2019-07-14 18:32:59 +02:00
Zsin Skri
f645400c5e replaygain: adapt to mediafile commit 95e569a
Since commit 95e569a, mediafile takes care of the float -> Q7.8 conversion in
R128 GAIN tags by itself.

From `store_album_r128_gain` this conversion was already missing, remove it from
`store_track_r128_gain`, too.

fixes #3311
2019-06-18 23:17:38 +02:00
Adrian Sampson
f865fc00cd replaygain: Fix py3 crash in audiotools backend
Fixes #3305.
2019-06-08 16:23:49 -04:00
Samuel Nilsson
b8b99d9396 Merge branch 'master' into replaygain 2019-06-08 16:15:27 +02:00
Jack Wilsdon
f09088df43
replaygain: Handle invalid XML output from bs1770gain 2019-05-02 01:24:19 +01:00
Samuel Nilsson
93007bfdd5 ReplayGain: fixed error caused by per_disc option 2019-02-06 13:17:34 +01:00
Samuel Nilsson
24f02cb5cd ReplayGain refactoring 2019-02-06 10:12:06 +01:00
Samuel Nilsson
31326ebb20 Simplified album ReplayGain code 2019-02-06 10:06:48 +01:00
Samuel Nilsson
d910ed3ecf Merge branch 'master' of github.com:beetbox/beets into replaygain 2019-02-06 09:27:45 +01:00
Samuel Nilsson
3d842db8d8 Added per disc album_gain support 2019-02-06 09:27:24 +01:00
Jack Wilsdon
768770d561
Fix incorrect indentation 2019-01-31 00:15:42 +00:00
Martin Haaß
a3770686b4 to fix the peak calculation also delete the division 2018-08-20 23:39:34 +02:00
Martin Haaß
f58f03dbfd replaygain: albumpeak on large collections is calculated as average, not maximum (bug 3008) 2018-08-20 23:06:11 +02:00
Adrian Sampson
7d607b4c5d Merge pull request #2813 from autrimpo/issue2757
Use NullPaddedInt for R128 tags
2018-05-31 10:13:20 -04:00
Cédric Schieli
b9bac391a9
Really fix album replaygain calculation with gstreamer backend.
Fixes #2845
2018-03-19 21:09:35 +01:00
Michal Koutenský
8350ed6baf Unique debug messages for R128 functions 2018-02-18 20:09:58 +01:00
Adrian Sampson
b28e0b43ff Merge pull request #2778 from ylep/replaygain-options
Add --force, --write and --nowrite options to replaygain plugin
2018-01-02 14:50:27 -05:00
Yann Leprince
499cd378b7 fix the default write behaviour to the importer configuration 2018-01-02 12:11:47 +01:00
Yann Leprince
3ef4b70439 Fix coding style 2017-12-31 14:51:14 +01:00
Yann Leprince
1f6335581e Add --force, --write and --nowrite options to replaygain plugin 2017-12-31 12:00:02 +01:00
Yann Leprince
05775ccac6 Fix fragile parsing of bs1770gain output
bs1770gain is sorting the filenames internally, so in some corner cases it returns the results in a different order from the command-line arguments.

This patch uses the --xml option of bs1770gain (introduced in 0.4.6) in order to read the filenames reliably.
2017-12-31 11:27:42 +01:00
Heinz Wiesinger
bd6645d135 Fix album replaygain calculation with gstreamer backend.
Fixes #2636
2017-10-04 20:22:01 +02:00
Michal Koutenský
70a2ad354b fixes issue #2615 2017-07-04 15:53:02 +02:00
Michal Koutenský
2685f13315 replaygain: support r128 2017-05-17 21:48:01 +02:00
Adrian Sampson
998e6ac1c7 Remove unused import 2017-01-10 14:54:17 -05:00
Adrian Sampson
bc93a11141 Fix #2382: replaygain backend parsing on Python 3 2017-01-10 14:45:57 -05:00
Adrian Sampson
153b01e5a6 replaygain: Don't muck with logging level
This is now handled by the central logging infrastructure; no need to change
it here. I think this must be a leftover from the era when plugins had to
explicitly muck with their verbosity level, but even still it doesn't make
sense to do set the level to INFO unconditionally...
2017-01-10 14:24:18 -05:00
Johnny Robeson
3db656a685 use py3_path on gstreamer location prop setters
Location properties require strings, so we give them to them!
2016-09-24 01:16:56 -04:00
Johnny Robeson
7a2bdf502f s/utf8/utf-8/ in all encoding/decoding contexts
This matches up with the python documentation.
2016-09-06 23:10:24 -04:00
Johnny Robeson
6bedbd84df removebyte conversion/literals for command args
Paths are obviously untouched.

We definitely don't need these as they are entirely ascii.
2016-08-25 03:37:30 -04:00
Johnny Robeson
fb78830788 fix incorrect bytes() usages in replaygain
We encode the method and gain offset values to ascii.
2016-08-09 05:17:53 -04:00