Ejemplo n.º 1
0
def main():
    import sys, readcd, al, AL, CD, cdplayer
    verbose = 0
    r = readcd.Readcd().init()
    prstatus(r.getstatus())
    prtrackinfo(r.gettrackinfo())
    cdinfo = cdplayer.Cdplayer().init(r.gettrackinfo())
    if cdinfo.title <> '':
        print 'Title: "' + cdinfo.title + '"'
    if cdinfo.artist <> '':
        print 'Artist: ' + cdinfo.artist
    for arg in sys.argv[1:]:
        if arg == '-v':
            verbose = 1
            continue
        x = eval(arg)
        try:
            l = len(x)
            r.appendstretch(x[0], x[1])
        except TypeError:
            r.appendtrack(x)
    try:
        oldparams = [AL.OUTPUT_RATE, 0]
        params = oldparams[:]
        al.getparams(AL.DEFAULT_DEVICE, oldparams)
        params[1] = AL.RATE_44100
        al.setparams(AL.DEFAULT_DEVICE, params)
        config = al.newconfig()
        config.setwidth(AL.SAMPLE_16)
        config.setchannels(AL.STEREO)
        port = al.openport('CD Player', 'w', config)

        for i in range(8):
            r.setcallback(i, callback, None)
        if verbose:
            r.setcallback(CD.PTIME, tcallback, None)
            r.setcallback(CD.ATIME, tcallback, None)
        else:
            r.removecallback(CD.PTIME)
            r.removecallback(CD.ATIME)
        r.setcallback(CD.PNUM, prtrack, cdinfo)
        r.setcallback(CD.AUDIO, playaudio, port)

        data = r.play()
    except KeyboardInterrupt:
        status = r.getstatus()
        print 'Interrupted at '+triple(status[2])+' into track '+ \
           `status[1]`+' (absolute time '+triple(status[3])+')'
    al.setparams(AL.DEFAULT_DEVICE, oldparams)
Ejemplo n.º 2
0
def main():
    if len(sys.argv) > 1:
        a = aifc.open(sys.argv[1], 'w')
    else:
        a = aifc.open('@', 'w')
    a.setsampwidth(AL.SAMPLE_16)
    a.setnchannels(AL.STEREO)
    a.setframerate(AL.RATE_44100)
    r = readcd.Readcd().init()
    for arg in sys.argv[2:]:
        x = eval(arg)
        try:
            if len(x) <> 2:
                raise Error, 'bad argument'
            r.appendstretch(x[0], x[1])
        except TypeError:
            r.appendtrack(x)
    r.setcallback(CD.AUDIO, writeaudio, a)
    r.play()
    a.close()
Ejemplo n.º 3
0
# Play CD audio on speaker or headphones.
Ejemplo n.º 4
0
import sys