mirror of
https://github.com/beetbox/beets.git
synced 2026-01-10 01:50:34 +01:00
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.
This commit is contained in:
parent
5adb3ecad2
commit
7a7314ee3f
1 changed files with 14 additions and 2 deletions
|
|
@ -88,6 +88,10 @@ class Backend(object):
|
|||
# individual tracks which can be used for any backend.
|
||||
raise NotImplementedError()
|
||||
|
||||
def use_ebu_r128(self):
|
||||
"""Set this Backend up to use EBU R128."""
|
||||
pass
|
||||
|
||||
|
||||
# bsg1770gain backend
|
||||
class Bs1770gainBackend(Backend):
|
||||
|
|
@ -277,6 +281,10 @@ class Bs1770gainBackend(Backend):
|
|||
out.append(album_gain["album"])
|
||||
return out
|
||||
|
||||
def use_ebu_r128(self):
|
||||
"""Set this Backend up to use EBU R128."""
|
||||
self.method = '--ebu'
|
||||
|
||||
|
||||
# mpgain/aacgain CLI tool backend.
|
||||
class CommandBackend(Backend):
|
||||
|
|
@ -830,6 +838,8 @@ class ReplayGainPlugin(BeetsPlugin):
|
|||
"bs1770gain": Bs1770gainBackend,
|
||||
}
|
||||
|
||||
r128_backend_names = ["bs1770gain"]
|
||||
|
||||
def __init__(self):
|
||||
super(ReplayGainPlugin, self).__init__()
|
||||
|
||||
|
|
@ -1024,7 +1034,9 @@ class ReplayGainPlugin(BeetsPlugin):
|
|||
u"Fatal replay gain error: {0}".format(e))
|
||||
|
||||
def init_r128_backend(self):
|
||||
backend_name = 'bs1770gain'
|
||||
backend_name = self.config["backend"].as_str()
|
||||
if backend_name not in self.r128_backend_names:
|
||||
backend_name = "bs1770gain"
|
||||
|
||||
try:
|
||||
self.r128_backend_instance = self.backends[backend_name](
|
||||
|
|
@ -1034,7 +1046,7 @@ class ReplayGainPlugin(BeetsPlugin):
|
|||
raise ui.UserError(
|
||||
u'replaygain initialization failed: {0}'.format(e))
|
||||
|
||||
self.r128_backend_instance.method = '--ebu'
|
||||
self.r128_backend_instance.use_ebu_r128()
|
||||
|
||||
def imported(self, session, task):
|
||||
"""Add replay gain info to items or albums of ``task``.
|
||||
|
|
|
|||
Loading…
Reference in a new issue