Improvements by Sjoerd

This commit is contained in:
Guido van Rossum 1992-06-03 16:49:44 +00:00
parent 6c6b6094fc
commit b1ccc6afe0
1 changed files with 9 additions and 20 deletions

View File

@ -1,44 +1,33 @@
# Dump CD audio on disk (in AIFF format; stereo, 16 bit samples, 44.1 kHz).
#
# Each argument is either a track to play or a quoted 7-tuple:
# '(track, min1, sec1, frame1, min2, sec2, frame2)'
# to play the track from min1:sec1:frame1 to min2:sec2:frame2.
# If track is zero, times are absolute instead.
import sys import sys
import string
import readcd import readcd
import aiff import aiff
import AL import AL
import CD import CD
Error = 'cdaiff.Error'
def writeaudio(a, type, data): def writeaudio(a, type, data):
a.writesampsraw(data) a.writesampsraw(data)
def ptimecallback(a, type, (min, sec, frame)):
if frame == 0:
print 'T =', min, ':', sec
def main(): def main():
a = aiff.Aiff().init(sys.argv[1], 'w') if len(sys.argv) > 1:
a = aiff.Aiff().init(sys.argv[1], 'w')
else:
a = aiff.Aiff().init('@', 'w')
a.sampwidth = AL.SAMPLE_16 a.sampwidth = AL.SAMPLE_16
a.nchannels = AL.STEREO a.nchannels = AL.STEREO
a.samprate = AL.RATE_44100 a.samprate = AL.RATE_44100
r = readcd.Readcd().init() r = readcd.Readcd().init()
l = []
for arg in sys.argv[2:]: for arg in sys.argv[2:]:
x = eval(arg) x = eval(arg)
try: try:
l = len(x) if len(x) <> 2:
raise Error, 'bad argument'
r.appendstretch(x[0], x[1]) r.appendstretch(x[0], x[1])
except TypeError: except TypeError:
r.appendtrack(x) r.appendtrack(x)
r.setcallback(CD.AUDIO, writeaudio, a) r.setcallback(CD.AUDIO, writeaudio, a)
r.setcallback(CD.PTIME, ptimecallback, None) r.play()
try:
r.play()
except KeyboardInterrupt:
pass
a.destroy() a.destroy()
main() main()