blob: 9d88dac5f60065e891fbcd8a678b94023d1f4038 [file] [log] [blame]
Guido van Rossumf06ee5f1996-11-27 19:52:01 +00001#! /usr/bin/env python
Guido van Rossum50692d61991-09-15 21:05:15 +00002
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
12import sys, al
13from socket import *
14
Guido van Rossuma8413b21992-12-14 15:05:53 +000015port = 5555
Guido van Rossum50692d61991-09-15 21:05:15 +000016if sys.argv[1:]: port = eval(sys.argv[1])
17
18s = socket(AF_INET, SOCK_DGRAM)
19s.allowbroadcast(1)
20
21p = al.openport('broadcast', 'r')
22
23address = '<broadcast>', port
24while 1:
25 # 700 samples equals 1400 bytes, or about the max packet size!
26 data = p.readsamps(700)
27 s.sendto(data, address)