Guido van Rossum | f06ee5f | 1996-11-27 19:52:01 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
Guido van Rossum | 50692d6 | 1991-09-15 21:05:15 +0000 | [diff] [blame] | 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 | |
Guido van Rossum | a8413b2 | 1992-12-14 15:05:53 +0000 | [diff] [blame] | 15 | port = 5555 |
Guido van Rossum | 50692d6 | 1991-09-15 21:05:15 +0000 | [diff] [blame] | 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) |