From 219e6f509ffaac6faaa6b65bf98a28278c71fd86 Mon Sep 17 00:00:00 2001 From: Chad Bergeron Date: Tue, 2 Feb 2016 13:39:54 -0500 Subject: [PATCH 1/3] Cast peak into a float for cases where it isn't (e.g. when HTOA generates a peak of 0) --- morituri/rip/cd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index 09b5803..02c14b2 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -431,7 +431,7 @@ Install pycdio and run 'rip offset find' to detect your drive's offset. raise self.stdout.write('Peak level: %.2f %%\n' % ( - math.sqrt(trackResult.peak) * 100.0, )) + float(math.sqrt(trackResult.peak) * 100.0, ))) self.stdout.write('Rip quality: %.2f %%\n' % ( trackResult.quality * 100.0, )) From 0da064fe97a101663da02e76a97949f745cb2ef1 Mon Sep 17 00:00:00 2001 From: Chad Bergeron Date: Tue, 2 Feb 2016 16:14:26 -0500 Subject: [PATCH 2/3] Modified str outputs and ensured that tracks with no peakdB set trackResult.peak to a float. --- morituri/common/encode.py | 4 +++- morituri/rip/cd.py | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/morituri/common/encode.py b/morituri/common/encode.py index 7e4e0ee..f0d8b14 100644 --- a/morituri/common/encode.py +++ b/morituri/common/encode.py @@ -329,13 +329,15 @@ class EncodeTask(ctask.GstPipelineTask): self.warning('No peak found.') + self.peak = 0.0 + if self._duration: self.warning('GStreamer level element did not send messages.') # workaround for when the file is too short to have volume ? if self._length == common.SAMPLES_PER_FRAME: self.warning('only one frame of audio, setting peak to 0.0') self.peak = 0.0 - + return class TagReadTask(ctask.GstPipelineTask): """ diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index 02c14b2..b75894c 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -430,10 +430,9 @@ Install pycdio and run 'rip offset find' to detect your drive's offset. number) raise - self.stdout.write('Peak level: %.2f %%\n' % ( - float(math.sqrt(trackResult.peak) * 100.0, ))) - self.stdout.write('Rip quality: %.2f %%\n' % ( - trackResult.quality * 100.0, )) + self.stdout.write('Peak level: {:.2%} \n'.format(math.sqrt(trackResult.peak))) + + self.stdout.write('Rip quality: {:.2%}\n'.format(trackResult.quality)) # overlay this rip onto the Table if number == 0: From 8ff28da4fcb8558fbf526de4e7cf77ce9283e319 Mon Sep 17 00:00:00 2001 From: Chad Bergeron Date: Tue, 2 Feb 2016 16:24:24 -0500 Subject: [PATCH 3/3] clean up unnecessary return. --- morituri/common/encode.py | 1 - 1 file changed, 1 deletion(-) diff --git a/morituri/common/encode.py b/morituri/common/encode.py index f0d8b14..fc3bc8f 100644 --- a/morituri/common/encode.py +++ b/morituri/common/encode.py @@ -337,7 +337,6 @@ class EncodeTask(ctask.GstPipelineTask): if self._length == common.SAMPLES_PER_FRAME: self.warning('only one frame of audio, setting peak to 0.0') self.peak = 0.0 - return class TagReadTask(ctask.GstPipelineTask): """