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 / rec_play.py < prev    next >
Encoding:
Text File  |  1995-12-17  |  434 b   |  29 lines  |  [TEXT/R*ch]

  1. #
  2. # records an AIFF sample and plays it
  3. # infinity number of times.
  4. #
  5.  
  6. import time
  7. import al
  8.  
  9. def recordit () :
  10.     p = al.openport('hello', 'r')
  11.     print 'recording...'
  12.     buf = p.readsamps(500000)
  13.     print 'done.'
  14.     p.closeport()
  15.     
  16.     return buf
  17.  
  18. def playit (buf) :
  19.     p = al.openport('hello', 'w')
  20.     print 'playing...'
  21.     p.writesamps(buf)
  22.     while p.getfilled() > 0:
  23.         time.sleep(0.01)
  24.     print 'done.'
  25.     p.closeport()
  26.  
  27. while 1 :
  28.     playit (recordit ())
  29.