From ea6f5e2aba4f82fd38037c6ac622d41e357d451e Mon Sep 17 00:00:00 2001 From: Saminwa Date: Tue, 17 Sep 2013 18:10:32 -0400 Subject: [PATCH 1/3] Ignore HTOA by default and add -H, --htoa switch. --- morituri/rip/cd.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index 1689ae0d..c3c9ea96 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -210,6 +210,9 @@ def addOptions(self): action="store", dest="working_directory", help="working directory; morituri will change to this directory " "and files will be created relative to it when not absolute ") + self.parser.add_option('-H', '--htoa', + action="store_true", dest="htoa", + help="rip HTOA") rcommon.addTemplate(self) @@ -418,9 +421,13 @@ def ripIfNotRipped(number): 'Found Hidden Track One Audio from frame %d to %d\n' % ( start, stop)) - # rip it - ripIfNotRipped(0) - htoapath = self.program.result.tracks[0].filename + if self.options.htoa: + # rip it + ripIfNotRipped(0) + htoapath = self.program.result.tracks[0].filename + else: + # treat PREGAP as SILENCE for .cue + self.itable.setFile(1, 0, None, self.ittoc.getTrackStart(1), 0) for i, track in enumerate(self.itable.tracks): # FIXME: rip data tracks differently From d75c02ebacf74f0c83de41e50210abf703fc7c80 Mon Sep 17 00:00:00 2001 From: Saminwa Date: Sat, 17 May 2014 14:23:03 -0400 Subject: [PATCH 2/3] Ignore SILENT HTOA. --- TODO | 2 -- morituri/rip/cd.py | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index 3afb241b..a682f3ba 100644 --- a/TODO +++ b/TODO @@ -23,8 +23,6 @@ TODO: - write moovida/xbmc plugin - cache results of MusicBrainz lookups - on ana, Goldfrapp tells me I have offset 0! -- don't keep short HTOA's if their peak level is low - (see Pixies Planet of Sound single) - lossy encoding - consider basing ripping progress not only on read (reaches 100% before writes are done) or writes (very bursty in cdparanoia) but a combo of the diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index 3ab62760..ed432e7b 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -39,6 +39,7 @@ MAX_TRIES = 5 +SILENT = 1e-10 class _CD(logcommand.LogCommand): @@ -210,9 +211,6 @@ def addOptions(self): action="store", dest="working_directory", help="working directory; morituri will change to this directory " "and files will be created relative to it when not absolute ") - self.parser.add_option('-H', '--htoa', - action="store_true", dest="htoa", - help="rip HTOA") rcommon.addTemplate(self) @@ -405,8 +403,15 @@ 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.itable.setFile(1, 0, None, + self.ittoc.getTrackStart(1), number) + os.unlink(trackResult.filename) + del self.program.result.tracks[0] + 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) @@ -423,13 +428,9 @@ def ripIfNotRipped(number): 'Found Hidden Track One Audio from frame %d to %d\n' % ( start, stop)) - if self.options.htoa: - # rip it - ripIfNotRipped(0) - htoapath = self.program.result.tracks[0].filename - else: - # treat PREGAP as SILENCE for .cue - self.itable.setFile(1, 0, None, self.ittoc.getTrackStart(1), 0) + # rip it + ripIfNotRipped(0) + htoapath = self.program.result.tracks[0].filename for i, track in enumerate(self.itable.tracks): # FIXME: rip data tracks differently From d38fb713fc7edefdba57a2c724c72b9b5f2ccb65 Mon Sep 17 00:00:00 2001 From: Saminwa Date: Sat, 24 May 2014 03:05:14 -0400 Subject: [PATCH 3/3] Ignore SILENT HTOA more gracefully... --- morituri/rip/cd.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index 0183764b..b58fb018 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 @@ -402,8 +403,17 @@ 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) + 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)