Added 'list_only' option (and modified 'run()' to respect it).
[python/dscho.git] / Demo / sgi / al / broadcast.py
blob9d88dac5f60065e891fbcd8a678b94023d1f4038
1 #! /usr/bin/env python
3 # broadcast [port]
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!!!)
12 import sys, al
13 from socket import *
15 port = 5555
16 if sys.argv[1:]: port = eval(sys.argv[1])
18 s = socket(AF_INET, SOCK_DGRAM)
19 s.allowbroadcast(1)
21 p = al.openport('broadcast', 'r')
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)