Commit graph

50 commits

Author SHA1 Message Date
Samuel Cook
ff4cec2e69
Removes support for bs1770gain.
References in the documentation to this plugin were removed in
beetbox/beets#3127 (beetbox/beets#3130) but no actual code
changes were made.

This PR removes support for this dependency entirely.
2021-01-27 17:42:18 -08:00
wisp3rwind
30baf22e77 replaygain: Use on-disk database
there can only be a single connection to an in-memory database, but the
parallel replaygain code accesses the db from different threads
2020-12-21 11:13:45 +01:00
ybnd
363f71af2e Move OperationalError handler to test_replaygain.py 2020-12-14 22:10:54 +01:00
ybnd
63ea17365a Modify patched stdout in test_malformed_output 2020-02-05 09:04:24 +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
Zsin Skri
88ab5474c5 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.
2019-07-22 13:42:26 +02:00
Zsin Skri
5a8bdb67f7 replaygain: add target_level test
Assert that analysing the same track with different target levels yields
different gain adjustments.
2019-07-22 13:42:26 +02:00
Zsin Skri
b9063a0240 fix bs1770gain test
This test caused other tests to fail due to missing cleanup.
2019-07-22 12:49:50 +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
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
Carl Suster
546bf3af7e mediafile: import from standalone module 2019-05-29 09:35:14 +10:00
Adrian Sampson
8bef21a4d5 More permissive log check for #3247 2019-05-02 09:38:11 -04:00
Jack Wilsdon
f09088df43
replaygain: Handle invalid XML output from bs1770gain 2019-05-02 01:24:19 +01:00
Jack Wilsdon
f622e42a88 Replace blind excepts with generic Exception excepts in tests 2017-04-29 00:12:14 +02:00
Adrian Sampson
a88682e7bb Undo from _common import unittest indirection
This was a vestige from when we used to need the unittest2 library for pre-2.7
compatibility. Now that we require Python 2.7, we aren't using that library
and this indirection wasn't doing any good.
2016-11-26 18:46:44 -05:00
Johnny Robeson
36ed75cd01 use reraise from six 2016-06-24 05:53:55 -04:00
Adrian Sampson
71b9fd785c Revert "Do __name__ comparison with bytes and not unicode"
This reverts commit 9c41c39913.
That commit used byte strings for the `if __name__ == '__main__'` pattern,
which was necessary when we were doing unicode_literals. But it is wrong on
Python 3, and now that we're liberated from unicode_literals, we need to go
back to native strings for this comparison.
2016-05-29 19:19:59 -07:00
Adrian Sampson
e54c7eec3d Standardize __future__ imports without parentheses
Since the list is short enough now, we don't need parentheses for the line
wrap. This is a little less ugly.
2016-02-28 15:03:51 -08:00
Peter Kessen
27c6c3d6da Removed unicode_literals from test_replaygain 2016-02-25 07:38:38 +01:00
Diego Moreda
76d7c65c1b replaygain: refine test by subclassing exception
* Subclass FatalReplayGainError into FatalGstreamerPluginReplayGainError
in order to handle gstreamer plugin errors more cleanly on
test_replaygain.
2016-01-26 22:20:42 +01:00
Diego Moreda
d2cec48c65 Skip GStreamer tests if plugins are missing
* Add a check to ReplayGainGstCliTest that ensures that the required
initial gstreamer plugins can be loaded, skipping the test if it is not
the case instead of running it.
* Add a check to ReplayGainGstCliTest.test_cli_saves_track_gain for
checking if item.rg_track_peak and item.rg_track_gain is not None. If
they are None, it is assumed that the decoder plugins could not be
found, and the tests is skipped, as discussed on #1830.
2016-01-26 17:59:51 +01:00
Adrian Sampson
5f8e710e07 Fix configuration in ReplayGain tests (#1830) 2016-01-25 10:27:36 -08:00
Jack Wilsdon
12cd5306b7 Update copyright dates to 2016 2015-12-30 15:42:06 +00:00
Peter Kessen
3eb8008b11 added encoding as comment in files
added line like
# -*- coding: utf-8 -*-
to all files with correct license in header
2015-11-19 18:41:01 +01:00
jean-marie winters
efb7370e04 Merge branch 'master' of https://github.com/sampsyo/beets into bs1770gainsupport 2015-03-06 22:02:48 +01:00
Bruno Cauet
5a355201d3 test_replaygain: fix except a, b: → except (a, b): 2015-03-04 15:29:19 +01:00
Bruno Cauet
f8e2ca2c94 Replaygain tests: more careful plugins unloading
When plugins loading as failed plugins unloading may fail in
consequence, swallowing the loading error. This fixes it.
2015-03-04 15:05:22 +01:00
jean-marie winters
5d9bb5059a corrected typo 2015-03-04 07:20:53 +01:00
jean-marie winters
614f8eda88 added tests for bs1770gain 2015-03-03 23:02:02 +01:00
Bruno Cauet
53c21330c2 All tests use unicode_literals 2015-01-20 15:58:02 +01:00
Bruno Cauet
9c41c39913 Do __name__ comparison with bytes and not unicode 2015-01-20 12:03:57 +01:00
Bruno Cauet
90b388b775 Use __future__ imports but unicode_literals everywhere
Include import of __future__ features division, absolute_imports and
print_function everywhere. Don't add unicode_literals yet for it is
harder to convert.

Goal is smoothing the transition to python 3.
2015-01-19 12:25:16 +01:00
Bruno Cauet
2902cda036 tests: use absolute imports everywhere 2015-01-19 12:25:15 +01:00
Frederik “Freso” S. Olesen
4b1f0cbf48 Happy 2015. ;)
See 7a410f636b

Command used:

    git grep -l 'Copyright 201'|xargs sed -i -E 's/Copyright 201./Copyright 2015/'`
2015-01-08 21:37:09 +01:00
Thomas Scholtes
98ae8cbbc9 Make tests conform to PEP8 2014-09-09 22:31:46 +02:00
Thomas Scholtes
ea04344560 Test and fix unicode issues in logs. Fixes #699
The helper functions for creating test fixtures now include unicode characters.
2014-04-17 12:12:49 +02:00
Thomas Scholtes
770bee3583 Extract check for thrird party programs in tests 2014-04-15 18:23:55 +02:00
Adrian Sampson
2f3ed3e450 avoid extra output in test mp3gain run 2014-04-13 20:41:58 -07:00
Adrian Sampson
5477a5d039 better tolerance in RG tests
The first fix avoids contaminating all future tests if the plugin fails to
load. The second skips the CLI backend tests when the appropriate tool is not
available (just as we do with the GStreamer tests).
2014-04-12 19:04:01 -07:00
Thomas Scholtes
65fcb8a28c Allow CLI tests to use :memory: db
This significantly increases performance
2014-04-12 16:08:57 +02:00
Thomas Scholtes
6705c123cf Use helper for replaygain tests 2014-04-11 15:14:13 +02:00
Thomas Scholtes
7b954d9999 Remove null normalization for replaygain.
A `None` value for replagain fields is different from a `0.0` value [1].

[1]: https://github.com/sampsyo/beets/issues/157#issuecomment-39521322
2014-04-10 22:02:24 +02:00
Thomas Scholtes
6286bc0b0f Include site-packages on travis and skip tests otherwise 2014-04-04 22:43:08 +02:00
Thomas Scholtes
5b277eedf8 Add replaygain test for command backend 2014-04-04 22:42:17 +02:00
Yevgeny Bezman
b47e6dd4d4 replaygain: added a test for skipping already calculated items 2014-04-04 22:01:59 +03:00
Thomas Scholtes
5d666fa4e7 Reset config and plugins after tests 2014-04-04 19:52:39 +02:00
Thomas Scholtes
81f53fb0d2 Add basic cli tests for replaygain 2014-04-04 19:44:16 +02:00