Commit graph

223 commits

Author SHA1 Message Date
Andrew Rogl
ee4268dabb Remove unused imports
Fix imports
Fix formatting
2021-08-26 20:59:48 +10:00
Andrew Rogl
1ec87a3bdd pyupgrade beetsplug and tests
All tests working
More tidy up to be done
2021-08-26 19:12:51 +10:00
Benedikt
e5f1cca8a3
Merge pull request #3890 from wisp3rwind/pr_rg_import_fixes
replaygain: fix write/force flags on import
2021-03-18 22:42:42 +01:00
Benedikt
c8c73cc789
Merge pull request #3891 from wisp3rwind/pr_rg_de-nest
replaygain: don't nest functions when there's no need to
2021-03-18 22:41:13 +01:00
wisp3rwind
d3ec2106cd replaygain: fix write/force flags on import
This restores old behaviour.
2021-03-18 18:37:15 +01:00
wisp3rwind
0125fdf415 replaygain: don't nest functions when there's no need to 2021-03-18 18:31:00 +01:00
wisp3rwind
feb5041f57 replaygain: remove debugging leftovers 2021-03-18 14:29:28 +01:00
Aksh Gupta
79858975a9 chore: refactor code quality issues 2021-03-11 08:45:42 +05:30
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
ybnd
eb8ba838e5 Check 'auto' on import_begin 2020-12-22 12:45:28 +01:00
ybnd
93101e7ea6 Disable replaygain parallelism during import 2020-12-21 19:19:20 +01:00
ybnd
12db40fa67 Remove .get() when checking config values 2020-12-21 08:50:39 +01:00
ybnd
1dfd79e658 Fix logic for replaygain auto-compute on import 2020-12-20 19:38:21 +01:00
ybnd
363f71af2e Move OperationalError handler to test_replaygain.py 2020-12-14 22:10:54 +01:00
ybnd
e1876590ba Fix replaygain.py to pass test_replaygain.py 2020-08-12 12:49:16 +02:00
ybnd
72710cd8c7 Merge branch 'master' into parallel-replaygain 2020-08-12 11:59:32 +02:00
ybnd
50757d34ad Fix conflicts 2020-08-12 11:42:18 +02:00
Adrian Sampson
5db2b4ccaa Fix new flake8 warnings 2020-05-13 08:20:50 -04:00
Adrian Sampson
47deb2f084 Switch log level for #3563, fix #3533 2020-04-23 08:03:51 -04:00
Michal Koutenský
5143e630d8 Fix #3533 - crash when calculating RG/R128 mix 2020-04-23 11:05:33 +02:00
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
9bd78424c1 Handle keyboard interrupts more cleanly 2020-02-04 19:16:33 +01:00
ybnd
4970585b0a Remove temporary workaround for silent exceptions 2020-01-31 14:08:28 +01:00
ybnd
4a427182cd Handle exceptions in pooled threads
* ExceptionWatcher instance running in parallel to the pool, monitoring a queue for exceptions
* Pooled threads push exceptions to this queue, log non-fatal exceptions
* Application exits on fatal exception in pooled thread

* More front end info logs in the CLI
2020-01-31 13:50:38 +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
f51a68c7e1 Implement comments 2020-01-30 19:53:05 +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
65ffca215a Exception handling in main & worker threads
* With `bs1770gain` installed the `Bs1770gainBackend` tests fail, but this should be fixed by https://github.com/beetbox/beets/pull/3480.
2020-01-30 18:04:20 +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
ybnd
b903584163 Fix --threads argument handling 2020-01-30 13:31:14 +01:00
ybnd
b126ecafdd Clean up single/multithreaded execution selection logic
As suggested in https://github.com/beetbox/beets/pull/3478#discussion_r372467445
2020-01-30 12:38:20 +01:00
ybnd
0fede91bbd Workaround to pass ReplayGainLdnsCliMalformedTest.test_malformed_output ~ Python 3.8 2020-01-30 12:07:42 +01:00
ybnd
79c5535cf6 Open/close pool at begin/end of import session 2020-01-30 09:35:22 +01:00
ybnd
388d2d2c0d Consolidate ThreadPool checking, opening and closing into methods 2020-01-30 09:35:22 +01:00
ybnd
42e895c239 Match --jobs default & signature to that of convert plugin (--threads)
And change local function `func` to `ReplayGainPlugin` method `replaygain_func` so that `self` is passed explicitly
2020-01-30 09:35:22 +01:00
ybnd
d95bb5683b Analyze replaygain in parallel with multiprocessing.pool.ThreadPool
* Add `--jobs` or `-j` to `replaygain`-> set the pool size
* Single-threaded execution by default, if `--jobs` is unset

* If multithreaded, calls `Backend.compute_album_gain` or `Backend.compute_track_gain` asynchronously with metadata storing/writing in the callback
2020-01-28 21:20:21 +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