home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Demo / sgi / al / rec_play.py < prev    next >
Text File  |  1994-10-07  |  434b  |  29 lines

  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.