home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Python 1.3 / source code / Demo / sgi / al / playback.py < prev    next >
Encoding:
Text File  |  1995-12-17  |  441 b   |  24 lines  |  [TEXT/R*ch]

  1. # Read mono 16bit samples from stdin and write them to the audio device.
  2. # Assume the sampling rate is compatible.
  3. # Use a small queue size to minimize delays.
  4.  
  5. import al, sys
  6. import AL
  7.  
  8. BUFSIZE = 2000
  9. QSIZE = 4000
  10.  
  11. def main():
  12.     c = al.newconfig()
  13.     c.setchannels(AL.MONO)
  14.     c.setqueuesize(QSIZE)
  15.     p = al.openport('', 'w', c)
  16.     while 1:
  17.         data = sys.stdin.read(BUFSIZE)
  18.         p.writesamps(data)
  19.  
  20. try:
  21.     main()
  22. except KeyboardInterrupt:
  23.     sys.exit(1)
  24.