home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Demo / sgi / cd / cdaiff.py < prev    next >
Text File  |  1995-04-06  |  589b  |  34 lines

  1. import sys
  2. import readcd
  3. import aifc
  4. import AL
  5. import cd
  6.  
  7. Error = 'cdaiff.Error'
  8.  
  9. def writeaudio(a, type, data):
  10.     a.writeframesraw(data)
  11.  
  12. def main():
  13.     if len(sys.argv) > 1:
  14.         a = aifc.open(sys.argv[1], 'w')
  15.     else:
  16.         a = aifc.open('@', 'w')
  17.     a.setsampwidth(AL.SAMPLE_16)
  18.     a.setnchannels(AL.STEREO)
  19.     a.setframerate(AL.RATE_44100)
  20.     r = readcd.Readcd()
  21.     for arg in sys.argv[2:]:
  22.         x = eval(arg)
  23.         try:
  24.             if len(x) <> 2:
  25.                 raise Error, 'bad argument'
  26.             r.appendstretch(x[0], x[1])
  27.         except TypeError:
  28.             r.appendtrack(x)
  29.     r.setcallback(cd.audio, writeaudio, a)
  30.     r.play()
  31.     a.close()
  32.  
  33. main()
  34.