From f58f03dbfd990dbad69e0e24fb52aeccd7a9f125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haa=C3=9F?= Date: Mon, 20 Aug 2018 22:59:52 +0200 Subject: [PATCH 1/2] replaygain: albumpeak on large collections is calculated as average, not maximum (bug 3008) --- beetsplug/replaygain.py | 2 +- docs/changelog.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 35229281dc..75f1714aa7 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -181,7 +181,7 @@ def compute_gain(self, items, is_album): i += 1 returnchunk = self.compute_chunk_gain(chunk, is_album) albumgaintot += returnchunk[-1].gain - albumpeaktot += returnchunk[-1].peak + albumpeaktot = max(albumpeaktot, returnchunk[-1].peak) returnchunks = returnchunks + returnchunk[0:-1] returnchunks.append(Gain(albumgaintot / i, albumpeaktot / i)) return returnchunks diff --git a/docs/changelog.rst b/docs/changelog.rst index 45d8220feb..4091f6b909 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,8 @@ New features: * The `absubmit` plugin now works in parallel (on Python 3 only). Thanks to :user:`bemeurer`. :bug:`2442` +* replaygain: albumpeak on large collections is calculated as average, not maximum + :bug:`3008` Fixes: From a3770686b4987bf8b50001caa8438a4bbca96284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haa=C3=9F?= Date: Mon, 20 Aug 2018 23:38:12 +0200 Subject: [PATCH 2/2] to fix the peak calculation also delete the division --- beetsplug/replaygain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 75f1714aa7..ac45aa4f83 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -183,7 +183,7 @@ def compute_gain(self, items, is_album): albumgaintot += returnchunk[-1].gain albumpeaktot = max(albumpeaktot, returnchunk[-1].peak) returnchunks = returnchunks + returnchunk[0:-1] - returnchunks.append(Gain(albumgaintot / i, albumpeaktot / i)) + returnchunks.append(Gain(albumgaintot / i, albumpeaktot)) return returnchunks else: return self.compute_chunk_gain(items, is_album)