home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Demo / sgi / al / broadcast.py < prev    next >
Text File  |  1996-11-27  |  741b  |  28 lines

  1. #! /usr/bin/env python
  2.  
  3. # broadcast [port]
  4. #
  5. # Broadcast audio input on the network as UDP packets;
  6. # they can be received on any SGI machine with "radio.py".
  7. # This uses the input sampling rate, input source etc. set by apanel.
  8. # It uses the default sample width and #channels (16 bit/sample stereo).
  9. # (This is 192,000 Bytes at a sampling speed of 48 kHz, or ~137
  10. # packets/second -- use with caution!!!)
  11.  
  12. import sys, al
  13. from socket import *
  14.  
  15. port = 5555
  16. if sys.argv[1:]: port = eval(sys.argv[1])
  17.  
  18. s = socket(AF_INET, SOCK_DGRAM)
  19. s.allowbroadcast(1)
  20.  
  21. p = al.openport('broadcast', 'r')
  22.  
  23. address = '<broadcast>', port
  24. while 1:
  25.     # 700 samples equals 1400 bytes, or about the max packet size!
  26.     data = p.readsamps(700)
  27.     s.sendto(data, address)
  28.