home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyth_os2.zip / python-1.0.2 / Demo / sgi / al / alwatch.py next >
Text File  |  1994-02-17  |  779b  |  34 lines

  1. import time
  2. import al, AL
  3. import string
  4.  
  5. dev = AL.DEFAULT_DEVICE
  6.  
  7. source_name = ['line', 'microphone', 'digital']
  8.  
  9. params = al.queryparams(dev)
  10. for i in range(1, len(params), 2):
  11.     params[i] = -1
  12. while 1:
  13.     time.sleep(0.1)
  14.     old = params[:]
  15.     al.getparams(dev, params)
  16.     if params <> old:
  17.         for i in range(0, len(params), 2):
  18.             if params[i+1] <> old[i+1]:
  19.                 name = al.getname(dev, params[i])
  20.                 if params[i] == AL.INPUT_SOURCE:
  21.                     if 0 <= old[i+1] < len(source_name):
  22.                         oldval = source_name[old[i+1]]
  23.                     else:
  24.                         oldval = ''
  25.                     newval = source_name[params[i+1]]
  26.                 else:
  27.                     oldval = `old[i+1]`
  28.                     newval = `params[i+1]`
  29.                 print string.ljust(name, 25),
  30.                 print '(' + string.rjust(oldval, 10) + ')',
  31.                 print '-->',
  32.                 print string.rjust(newval, 10)
  33.         print
  34.