fix so first FILE goes before TRACK 01 and possible PREGAP
This commit is contained in:
@@ -523,11 +523,15 @@ class Table(object, log.Loggable):
|
||||
|
||||
@rtype: C{unicode}
|
||||
"""
|
||||
self.debug('generating .cue for cuePath %r', cuePath)
|
||||
|
||||
lines = []
|
||||
|
||||
def writeFile(path):
|
||||
targetPath = common.getRelativePath(path, cuePath)
|
||||
lines.append('FILE "%s" WAVE' % targetPath)
|
||||
line = 'FILE "%s" WAVE' % targetPath
|
||||
lines.append(line)
|
||||
self.debug('writeFile: %r' % line)
|
||||
|
||||
# header
|
||||
main = ['PERFORMER', 'TITLE']
|
||||
@@ -547,57 +551,91 @@ class Table(object, log.Loggable):
|
||||
if key in self.cdtext:
|
||||
lines.append('%s "%s"' % (key, self.cdtext[key]))
|
||||
|
||||
# FIXME:
|
||||
# - the first FILE statement goes before the first TRACK, even if
|
||||
# there is a non-file-using PREGAP
|
||||
# - the following FILE statements come after the last INDEX that
|
||||
# use that FILE; so before a next TRACK, PREGAP silence, ...
|
||||
|
||||
# add the first FILE line; EAC always puts the first FILE
|
||||
# statement before TRACK 01
|
||||
# statement before TRACK 01 and any possible PRE-GAP
|
||||
firstTrack = self.tracks[0]
|
||||
index = firstTrack.getFirstIndex()
|
||||
indexOne = firstTrack.getIndex(1)
|
||||
counter = index.counter
|
||||
track = firstTrack
|
||||
|
||||
firstIndex = firstTrack.getFirstIndex()
|
||||
path = indexOne.path
|
||||
counter = indexOne.counter
|
||||
|
||||
assert path, "No path on TRACK 01 INDEX 01"
|
||||
writeFile(path)
|
||||
while not index.path:
|
||||
t, i = self.getNextTrackIndex(track.number, index.number)
|
||||
track = self.tracks[t - 1]
|
||||
index = track.getIndex(i)
|
||||
counter = index.counter
|
||||
|
||||
if index.path:
|
||||
self.debug('counter %d, writeFile' % counter)
|
||||
writeFile(index.path)
|
||||
|
||||
for i, track in enumerate(self.tracks):
|
||||
self.debug('track i %r, track %r' % (i, track))
|
||||
# FIXME: skip data tracks for now
|
||||
if not track.audio:
|
||||
continue
|
||||
|
||||
# if there is no index 0, but there is a new file, advance
|
||||
# FILE line here
|
||||
if not 0 in track.indexes:
|
||||
index = track.indexes[1]
|
||||
if index.counter != counter:
|
||||
writeFile(index.path)
|
||||
counter = index.counter
|
||||
lines.append(" TRACK %02d %s" % (i + 1, 'AUDIO'))
|
||||
for key in CDTEXT_FIELDS:
|
||||
if key in track.cdtext:
|
||||
lines.append(' %s "%s"' % (key, track.cdtext[key]))
|
||||
|
||||
if track.isrc is not None:
|
||||
lines.append(" ISRC %s" % track.isrc)
|
||||
|
||||
indexes = track.indexes.keys()
|
||||
indexes.sort()
|
||||
|
||||
wroteTrack = False
|
||||
|
||||
for number in indexes:
|
||||
index = track.indexes[number]
|
||||
# handle TRACK 01 INDEX 00 specially
|
||||
if i == 0 and number == 0:
|
||||
# if we have a silent pre-gap, output it
|
||||
if not index.path:
|
||||
length = indexOne.absolute - index.absolute
|
||||
lines.append(" PREGAP %s" % common.framesToMSF(length))
|
||||
continue
|
||||
self.debug('index %r, %r' % (number, index))
|
||||
|
||||
if index.counter != counter:
|
||||
writeFile(index.path)
|
||||
# any time the source counter changes to a higher value,
|
||||
# write a FILE statement
|
||||
# it has to be higher, because we can run into the HTOA
|
||||
# at counter 0 here
|
||||
if index.counter > counter:
|
||||
if index.path:
|
||||
self.debug('counter %d, writeFile' % counter)
|
||||
writeFile(index.path)
|
||||
self.debug('setting counter to index.counter %r' %
|
||||
index.counter)
|
||||
counter = index.counter
|
||||
lines.append(" INDEX %02d %s" % (number,
|
||||
common.framesToMSF(index.relative)))
|
||||
|
||||
# any time we hit the first index, write a TRACK statement
|
||||
if not wroteTrack:
|
||||
wroteTrack = True
|
||||
line = " TRACK %02d %s" % (i + 1, 'AUDIO')
|
||||
lines.append(line)
|
||||
self.debug('%r' % line)
|
||||
|
||||
for key in CDTEXT_FIELDS:
|
||||
if key in track.cdtext:
|
||||
lines.append(' %s "%s"' % (
|
||||
key, track.cdtext[key]))
|
||||
|
||||
if track.isrc is not None:
|
||||
lines.append(" ISRC %s" % track.isrc)
|
||||
|
||||
# handle TRACK 01 INDEX 00 specially
|
||||
if 0 in indexes:
|
||||
index00 = track.indexes[0]
|
||||
if i == 0:
|
||||
# if we have a silent pre-gap, output it
|
||||
if not index00.path:
|
||||
length = indexOne.absolute - index00.absolute
|
||||
lines.append(" PREGAP %s" %
|
||||
common.framesToMSF(length))
|
||||
continue
|
||||
|
||||
# handle any other INDEX 00 after its TRACK
|
||||
lines.append(" INDEX %02d %s" % (0,
|
||||
common.framesToMSF(index00.relative)))
|
||||
|
||||
if number > 0:
|
||||
# index 00 is output after TRACK up above
|
||||
lines.append(" INDEX %02d %s" % (number,
|
||||
common.framesToMSF(index.relative)))
|
||||
|
||||
lines.append("")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user