[SCM] morituri/master: * morituri/program/cdparanoia.py: Add table to __init__, so we can correctly calculate cdparanoia's strange ripping regions. * examples/ARcalibrate.py: When we found a positive match on a first track, match all the other tracks too for confirmation.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:08:53 UTC 2014
The following commit has been merged in the master branch:
commit d8e288d848d19120beab8e26a0f98430ab320e04
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Sun May 3 12:59:37 2009 +0000
* morituri/program/cdparanoia.py:
Add table to __init__, so we can correctly calculate cdparanoia's
strange ripping regions.
* examples/ARcalibrate.py:
When we found a positive match on a first track, match all the other
tracks too for confirmation.
diff --git a/ChangeLog b/ChangeLog
index 30d0ac8..daa3cd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2009-05-03 Thomas Vander Stichele <thomas at apestaart dot org>
+ * morituri/program/cdparanoia.py:
+ Add table to __init__, so we can correctly calculate cdparanoia's
+ strange ripping regions.
+ * examples/ARcalibrate.py:
+ When we found a positive match on a first track, match all the other
+ tracks too for confirmation.
+
+2009-05-03 Thomas Vander Stichele <thomas at apestaart dot org>
+
* morituri/common/taskgtk.py:
Bug fix.
diff --git a/examples/ARcalibrate.py b/examples/ARcalibrate.py
index 45bc49c..76a597e 100644
--- a/examples/ARcalibrate.py
+++ b/examples/ARcalibrate.py
@@ -55,6 +55,26 @@ def climain(runner, taskk):
runner.run(taskk)
+def arcs(runner, function, table, track, offset):
+ # rips the track with the given offset, return the arcs checksum
+ print 'ripping track %r with offset %d' % (track, offset)
+
+ fd, path = tempfile.mkstemp(suffix='.track%02d.offset%d.morituri.wav' % (
+ track, offset))
+ os.close(fd)
+
+ track = table.tracks[track - 1]
+ t = cdparanoia.ReadTrackTask(path, table, track.start, track.end, offset)
+ t.description = 'Ripping with offset %d' % offset
+ function(runner, t)
+
+ t = checksum.AccurateRipChecksumTask(path, trackNumber=track,
+ trackCount=len(table.tracks))
+ function(runner, t)
+
+ # os.unlink(path)
+ return "%08x" % t.checksum
+
def main(argv):
parser = optparse.OptionParser()
@@ -122,30 +142,43 @@ def main(argv):
print "AccurateRip response discid different: %s" % \
responses[0].cddbDiscId
- response = None
-
# now rip the first track at various offsets, calculating AccurateRip
# CRC, and matching it against the retrieved ones
- for offset in offsets:
- fd, path = tempfile.mkstemp(suffix='.morituri')
- os.close(fd)
-
- print 'ripping track 1 with offset', offset
- track = table.tracks[0]
- t = cdparanoia.ReadTrackTask(path, track.start, track.end, offset)
- t.description = 'Ripping with offset %d' % offset
- function(runner, t)
+
+ def match(archecksum, track, responses):
+ for i, r in enumerate(responses):
+ if archecksum == r.checksums[track - 1]:
+ return archecksum, i
- t = checksum.AccurateRipChecksumTask(path, trackNumber=1,
- trackCount = len(table.tracks))
- function(runner, t)
- arcs = "%08x" % t.checksum
- print 'AR checksum calculated: %s' % arcs
+ return None, None
- for i, r in enumerate(responses):
- if arcs == r.checksums[0]:
- print 'MATCHED against response %d' % i
- print 'offset of device is', offset
+ for offset in offsets:
+ archecksum = arcs(runner, function, table, 1, offset)
+
+ print 'AR checksum calculated: %s' % archecksum
+
+ c, i = match(archecksum, 1, responses)
+ if c:
+ count = 1
+ print 'MATCHED against response %d' % i
+ print 'offset of device is likely', offset
+ # now try and rip all other tracks as well
+ for track in range(2, len(table.tracks) + 1):
+ archecksum = arcs(runner, function, table, track, offset)
+ c, i = match(archecksum, track, responses)
+ if c:
+ print 'MATCHED track %d against response %d' % (track, i)
+ count += 1
+
+ if count == len(table.tracks):
+ print 'OFFSET of device is', offset
+ return
+ else:
+ print 'not all tracks matched, continuing'
+
+ print 'no matching offset found.'
+
+
main(sys.argv)
diff --git a/morituri/program/cdparanoia.py b/morituri/program/cdparanoia.py
index dbcd302..e84bc0d 100644
--- a/morituri/program/cdparanoia.py
+++ b/morituri/program/cdparanoia.py
@@ -62,20 +62,23 @@ class ReadTrackTask(task.Task):
description = "Reading Track..."
- def __init__(self, path, start, stop, offset=0):
+ def __init__(self, path, table, start, stop, offset=0):
"""
Read the given track.
@param path: where to store the ripped track
@type path: str
- @param start: first frame to rip
- @type start: int
+ @param table: table of contents of CD
+ @type table: L{table.Table}
+ @param start: first frame to rip, in cdparanoia notation
+ @type start: str
@param stop: last frame to rip (inclusive)
@type stop: int
@param offset: read offset, in samples
@type offset: int
"""
self.path = path
+ self._table = table
self._start = start
self._stop = stop
self._offset = offset
@@ -87,13 +90,32 @@ class ReadTrackTask(task.Task):
def start(self, runner):
task.Task.start(self, runner)
+ # find on which track the range starts and stops
+ startTrack = 0
+ startOffset = 0
+ stopTrack = 0
+ stopOffset = 0
+
+ for i, t in enumerate(self._table.tracks):
+ if t.start <= self._start:
+ startTrack = i + 1
+ startOffset = self._start - t.start
+ if t.end <= self._stop:
+ stopTrack = i + 1
+ stopOffset = self._stop - t.start
+
+ self.debug('Ripping from %d to %d (inclusive)', self._start, self._stop)
+ self.debug('Starting at track %d, offset %d', startTrack, startOffset)
+ self.debug('Stopping at track %d, offset %d', stopTrack, stopOffset)
+
bufsize = 1024
argv = ["cdparanoia",
"--sample-offset=%d" % self._offset,
"--stderr-progress",
- "[%s]-[%s]" % (
- common.framesToHMSF(self._start),
- common.framesToHMSF(self._stop)), self.path]
+ "%d[%s]-%d[%s]" % (
+ startTrack, common.framesToHMSF(startOffset),
+ stopTrack, common.framesToHMSF(stopOffset)),
+ self.path]
self.debug('Running %s' % (" ".join(argv), ))
self._popen = asyncsub.Popen(argv,
bufsize=bufsize,
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list