From 468d6cbaf65acf15bcf92a2d7aadf61fa983cece Mon Sep 17 00:00:00 2001 From: JoeLametta Date: Sun, 29 Nov 2015 16:18:24 +0100 Subject: [PATCH] don't keep short HTOA's if their peak level is low thomasvs/morituri#79 --- morituri/rip/cd.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index c787d3fe..64ba7717 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -38,6 +38,7 @@ from morituri.extern.command import command +SILENT = 1e-10 MAX_TRIES = 5 @@ -405,8 +406,18 @@ def ripIfNotRipped(number): # overlay this rip onto the Table if number == 0: # HTOA goes on index 0 of track 1 - self.itable.setFile(1, 0, trackResult.filename, - self.ittoc.getTrackStart(1), number) + # ignore silence in PREGAP + if trackResult.peak <= SILENT: + self.debug('HTOA peak %r is below SILENT threshold, disregarding', trackResult.peak) + self.itable.setFile(1, 0, None, + self.ittoc.getTrackStart(1), number) + self.debug('Unlinking %r', trackResult.filename) + os.unlink(trackResult.filename) + trackResult.filename = None + self.stdout.write('HTOA discarded, contains digital silence\n') + else: + self.itable.setFile(1, 0, trackResult.filename, + self.ittoc.getTrackStart(1), number) else: self.itable.setFile(number, 1, trackResult.filename, self.ittoc.getTrackLength(number), number)