From b0c87b956c81e30a9f3b3d393d1442f63c2dbfc3 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 17 Sep 2002 20:55:57 +0000 Subject: Remove the SGI demos. These were all ancient and nobody cared enough. --- Demo/sgi/README | 22 ----- Demo/sgi/al/README | 15 ---- Demo/sgi/al/alwatch.py | 33 ------- Demo/sgi/al/broadcast.py | 27 ------ Demo/sgi/al/cmpaf.py | 64 -------------- Demo/sgi/al/cmpaf_form.fd | 90 ------------------- Demo/sgi/al/intercom.py | 212 --------------------------------------------- Demo/sgi/al/listen.py | 34 -------- Demo/sgi/al/names.py | 14 --- Demo/sgi/al/playaiff.py | 54 ------------ Demo/sgi/al/playback.py | 23 ----- Demo/sgi/al/playold.py | 51 ----------- Demo/sgi/al/radio.py | 21 ----- Demo/sgi/al/rec_play.py | 28 ------ Demo/sgi/al/record.py | 23 ----- Demo/sgi/al/unicast.py | 26 ------ Demo/sgi/al/x.py | 12 --- Demo/sgi/audio/README | 8 -- Demo/sgi/audio/play.py | 75 ---------------- Demo/sgi/sv/README | 23 ----- Demo/sgi/sv/burstcapt.py | 52 ----------- Demo/sgi/sv/contcapt.py | 107 ----------------------- Demo/sgi/sv/rgbgrab.py | 81 ----------------- Demo/sgi/sv/simpleinput.py | 22 ----- 24 files changed, 1117 deletions(-) delete mode 100644 Demo/sgi/README delete mode 100644 Demo/sgi/al/README delete mode 100755 Demo/sgi/al/alwatch.py delete mode 100755 Demo/sgi/al/broadcast.py delete mode 100755 Demo/sgi/al/cmpaf.py delete mode 100755 Demo/sgi/al/cmpaf_form.fd delete mode 100755 Demo/sgi/al/intercom.py delete mode 100755 Demo/sgi/al/listen.py delete mode 100755 Demo/sgi/al/names.py delete mode 100755 Demo/sgi/al/playaiff.py delete mode 100755 Demo/sgi/al/playback.py delete mode 100755 Demo/sgi/al/playold.py delete mode 100755 Demo/sgi/al/radio.py delete mode 100755 Demo/sgi/al/rec_play.py delete mode 100755 Demo/sgi/al/record.py delete mode 100755 Demo/sgi/al/unicast.py delete mode 100755 Demo/sgi/al/x.py delete mode 100644 Demo/sgi/audio/README delete mode 100755 Demo/sgi/audio/play.py delete mode 100644 Demo/sgi/sv/README delete mode 100755 Demo/sgi/sv/burstcapt.py delete mode 100755 Demo/sgi/sv/contcapt.py delete mode 100755 Demo/sgi/sv/rgbgrab.py delete mode 100755 Demo/sgi/sv/simpleinput.py diff --git a/Demo/sgi/README b/Demo/sgi/README deleted file mode 100644 index 3ef80d2..0000000 --- a/Demo/sgi/README +++ /dev/null @@ -1,22 +0,0 @@ -Demonstrations of Python that use various features of the Silicon -Graphics IRIS machines. - -al Demonstrations of the audio capabilities of the - Indigo. Require the built-in module 'al'. One program - also needs the build-in module 'fl' (the FORMS - library by Mark Overmars.) - -cd Demonstrations of the CD-ROM player's audio interface, - built-in module 'cd'. - -flp Demonstrations of using the 'flp' standard module, - which enables you to quickly create forms using the - 'fl' built-in module (available if you use the FORMS - library by Mark Overmars). - -gl Demonstrations of the Graphics Library (GL). - Require the built-in module 'gl'. - -sv Demonstrations of the Indigo Video module. - Requires the built-in module 'sv'. See also the - following directory. diff --git a/Demo/sgi/al/README b/Demo/sgi/al/README deleted file mode 100644 index fba67b7..0000000 --- a/Demo/sgi/al/README +++ /dev/null @@ -1,15 +0,0 @@ -This directory contains programs using the "al" interface, which gives -access to the most important parts of the SGI Audio Library for the -Indigo and 4D/35. - -alwatch.py Watch changes in device settings -broadcast.py Broadcast audio using UDP packets -cmpaf.py Compare different audio compression schemes (uses fl) -intercom.py 2-way communication with another host (uses fl) -playaiff.py Play an AIFF file (as output by recordaiff) -playback.py Play raw audio data read from stdin -playold.py Play an audio file recorded by the old 4D/25 audio -radio.py Listen to UDP packets sent by broadcast.py -rec_play.py Repeatedly record and play back a sample -record.py Record raw audio data to stdout -unicast.py Like broadcast but sends to one host diff --git a/Demo/sgi/al/alwatch.py b/Demo/sgi/al/alwatch.py deleted file mode 100755 index da747d4..0000000 --- a/Demo/sgi/al/alwatch.py +++ /dev/null @@ -1,33 +0,0 @@ -import time -import al, AL -import string - -dev = AL.DEFAULT_DEVICE - -source_name = ['line', 'microphone', 'digital'] - -params = al.queryparams(dev) -for i in range(1, len(params), 2): - params[i] = -1 -while 1: - time.sleep(0.1) - old = params[:] - al.getparams(dev, params) - if params <> old: - for i in range(0, len(params), 2): - if params[i+1] <> old[i+1]: - name = al.getname(dev, params[i]) - if params[i] == AL.INPUT_SOURCE: - if 0 <= old[i+1] < len(source_name): - oldval = source_name[old[i+1]] - else: - oldval = '' - newval = source_name[params[i+1]] - else: - oldval = `old[i+1]` - newval = `params[i+1]` - print string.ljust(name, 25), - print '(' + string.rjust(oldval, 10) + ')', - print '-->', - print string.rjust(newval, 10) - print diff --git a/Demo/sgi/al/broadcast.py b/Demo/sgi/al/broadcast.py deleted file mode 100755 index 9d88dac..0000000 --- a/Demo/sgi/al/broadcast.py +++ /dev/null @@ -1,27 +0,0 @@ -#! /usr/bin/env python - -# broadcast [port] -# -# Broadcast audio input on the network as UDP packets; -# they can be received on any SGI machine with "radio.py". -# This uses the input sampling rate, input source etc. set by apanel. -# It uses the default sample width and #channels (16 bit/sample stereo). -# (This is 192,000 Bytes at a sampling speed of 48 kHz, or ~137 -# packets/second -- use with caution!!!) - -import sys, al -from socket import * - -port = 5555 -if sys.argv[1:]: port = eval(sys.argv[1]) - -s = socket(AF_INET, SOCK_DGRAM) -s.allowbroadcast(1) - -p = al.openport('broadcast', 'r') - -address = '', port -while 1: - # 700 samples equals 1400 bytes, or about the max packet size! - data = p.readsamps(700) - s.sendto(data, address) diff --git a/Demo/sgi/al/cmpaf.py b/Demo/sgi/al/cmpaf.py deleted file mode 100755 index 6b91e30..0000000 --- a/Demo/sgi/al/cmpaf.py +++ /dev/null @@ -1,64 +0,0 @@ -# Compare different audio compression schemes. -# -# This copies mono audio data from the input port to the output port, -# and puts up a window with 4 toggle buttons: -# -# uLAW : convert the data to uLAW and back -# ADPCM : convert the data to ADPCM and back -# Difference : make only the difference between the converted and the -# original data audible -# Exit : quit from the program - -import fl -import FL -import flp -import al -import AL -import audioop -import sys - -class Cmpaf: - def __init__(self): - parsetree = flp.parse_form('cmpaf_form','form') - flp.create_full_form(self, parsetree) - c = al.newconfig() - c.setchannels(AL.MONO) - c.setqueuesize(1800) - self.iport = al.openport('cmpaf','r', c) - self.oport = al.openport('cmpaf','w', c) - self.do_adpcm = self.do_ulaw = self.do_diff = 0 - self.acstate = None - self.form.show_form(FL.PLACE_SIZE, 1, 'compare audio formats') - - def run(self): - while 1: - olddata = data = self.iport.readsamps(600) - if self.do_ulaw: - data = audioop.lin2ulaw(data, 2) - data = audioop.ulaw2lin(data, 2) - if self.do_adpcm: - data, nacstate = audioop.lin2adpcm(data, 2, \ - self.acstate) - data, dummy = audioop.adpcm2lin(data, 2, \ - self.acstate) - self.acstate = nacstate - if self.do_diff: - olddata = audioop.mul(olddata, 2, -1) - data = audioop.add(olddata, data, 2) - self.oport.writesamps(data) - fl.check_forms() - - def cb_exit(self, *args): - sys.exit(0) - - def cb_adpcm(self, obj, val): - self.do_adpcm = obj.get_button() - - def cb_ulaw(self, obj, val): - self.do_ulaw = obj.get_button() - - def cb_diff(self, obj, val): - self.do_diff = obj.get_button() - -cmpaf = Cmpaf() -cmpaf.run() diff --git a/Demo/sgi/al/cmpaf_form.fd b/Demo/sgi/al/cmpaf_form.fd deleted file mode 100755 index 6667405..0000000 --- a/Demo/sgi/al/cmpaf_form.fd +++ /dev/null @@ -1,90 +0,0 @@ -Magic: 12321 - -Internal Form Definition File - (do not change) - -Number of forms: 1 - -=============== FORM =============== -Name: form -Width: 230.000000 -Height: 80.000000 -Number of Objects: 5 - --------------------- -class: 1 -type: 1 -box: 0.000000 0.000000 230.000000 80.000000 -boxtype: 1 -colors: 47 47 -alignment: 4 -style: 0 -size: 11.000000 -lcol: 0 -label: -name: -callback: -argument: - --------------------- -class: 12 -type: 1 -box: 10.000000 40.000000 100.000000 30.000000 -boxtype: 1 -colors: 39 3 -alignment: 4 -style: 0 -size: 11.000000 -lcol: 0 -label: uLAW -name: ulawbutton -callback: cb_ulaw -argument: 0 - --------------------- -class: 12 -type: 1 -box: 10.000000 10.000000 100.000000 30.000000 -boxtype: 1 -colors: 39 3 -alignment: 4 -style: 0 -size: 11.000000 -lcol: 0 -label: ADPCM -name: adpcm_button -callback: cb_adpcm -argument: 0 - --------------------- -class: 11 -type: 0 -box: 170.000000 10.000000 50.000000 20.000000 -boxtype: 1 -colors: 47 47 -alignment: 4 -style: 0 -size: 11.000000 -lcol: 0 -label: EXIT -name: exit_button -callback: cb_exit -argument: 0 - --------------------- -class: 12 -type: 1 -box: 120.000000 40.000000 100.000000 30.000000 -boxtype: 1 -colors: 39 3 -alignment: 4 -style: 0 -size: 11.000000 -lcol: 0 -label: Difference -name: diffbutton -callback: cb_diff -argument: 0 - -============================== -create_the_forms diff --git a/Demo/sgi/al/intercom.py b/Demo/sgi/al/intercom.py deleted file mode 100755 index fd983d3..0000000 --- a/Demo/sgi/al/intercom.py +++ /dev/null @@ -1,212 +0,0 @@ -# intercom -- use mike and headset to *talk* to a person on another host. -# For SGI 4D/35 or Indigo running IRIX 4.0. -# Uses 16 bit sampling at 16000 samples/sec, or 32000 bytes/sec, -# tranmitted in 32 1000-byte UDP packets. (In each direction!) -# -# usage: -# intercom hostname - start talking to person on other host -# intercom -r hostname - called remotely to do the setup - -from names import * -import sys, time, posix, gl, fl, FL, al, AL, getopt, rand -from socket import * - -# UDP port numbers used (one for each direction!) -PORT1 = 51042 -PORT2 = PORT1+1 - -# Figure out the user name -try: - user = posix.environ['LOGNAME'] -except: - user = posix.environ['USER'] - -# Debug flags (Implemented as a list; non-empty means debugging is on) -debug = [] - -def main(): - remote = 0 - opts, args = getopt.getopt(sys.argv[1:], 'rd') - for opt, arg in opts: - if opt == '-r': remote = 1 - elif opt == '-d': debug.append(opt) - if len(args) <> 1: - msg = 'usage: intercom [-d] [-r] hostname' - msg = msg + ' (-r is for internal use only!)\n' - sys.stderr.write(msg) - sys.exit(2) - if remote: - server(args[0]) - else: - client(args[0]) - -def client(hostname): - print 'client starting' - cmd = 'rsh ' + hostname + ' "cd ' + AUDIODIR - cmd = cmd + '; DISPLAY=:0; export DISPLAY' - cmd = cmd + '; ' + PYTHON + ' intercom.py -r ' - for flag in debug: cmd = cmd + flag + ' ' - cmd = cmd + gethostname() - cmd = cmd + '"' - if debug: print cmd - pipe = posix.popen(cmd, 'r') - ack = 0 - nak = 0 - while 1: - line = pipe.readline() - if not line: break - sys.stdout.write('remote: ' + line) - if line == 'NAK\n': - nak = 1 - break - elif line == 'ACK\n': - ack = 1 - break - if nak: - print 'Remote user doesn\'t want to talk to you.' - return - if not ack: - print 'No acknowledgement (remote side crashed?).' - return - # - print 'Ready...' - # - s = socket(AF_INET, SOCK_DGRAM) - s.bind('', PORT2) - # - otheraddr = gethostbyname(hostname), PORT1 - try: - try: - ioloop(s, otheraddr) - except KeyboardInterrupt: - log('client got intr') - except error: - log('client got error') - finally: - s.sendto('', otheraddr) - log('client finished sending empty packet to server') - # - log('client exit') - print 'Done.' - -def server(hostname): - print 'server starting' - sys.stdout.flush() - # - if not remotedialog(): - print 'NAK' - return - # - print 'ACK' - # - s = socket(AF_INET, SOCK_DGRAM) - s.bind('', PORT1) - # - # Close std{in,out,err} so rsh will exit; reopen them as dummies - # - sys.stdin.close() - sys.stdin = open('/dev/null', 'r') - sys.stdout.close() - sys.stdout = open('/dev/null', 'w') - sys.stderr.close() - if debug: - sys.stderr = open('/tmp/intercom.err', 'a') - else: - sys.stderr = open('/dev/null', 'w') - # - ioloop(s, (gethostbyname(hostname), PORT2)) - log('server exit') - sys.exit(0) - -def remotedialog(): - gl.foreground() - gl.ringbell() - m1 = user + ' wants to talk to you over the audio channel.' - m2 = 'If it\'s OK, put on your headset and click Yes.' - m3 = 'If you\'re too busy, click No.' - return fl.show_question(m1, m2, m3) - -def ioloop(s, otheraddr): - # - dev = AL.DEFAULT_DEVICE - params = al.queryparams(dev) - al.getparams(dev, params) - time.sleep(1) - saveparams = params[:] - for i in range(0, len(params), 2): - if params[i] in (AL.INPUT_RATE, AL.OUTPUT_RATE): - params[i+1] = AL.RATE_16000 - elif params[i] == AL.INPUT_SOURCE: - params[i+1] = AL.INPUT_MIC - try: - al.setparams(dev, params) - ioloop1(s, otheraddr) - finally: - al.setparams(dev, saveparams) - -def ioloop1(s, otheraddr): - # - # Watch out! data is in bytes, but the port counts in samples, - # which are two bytes each (for 16-bit samples). - # Luckily, we use mono, else it would be worse (2 samples/frame...) - # - SAMPSPERBUF = 500 - BYTESPERSAMP = 2 # AL.SAMPLE_16 - BUFSIZE = BYTESPERSAMP*SAMPSPERBUF - QSIZE = 4*SAMPSPERBUF - # - config = al.newconfig() - config.setqueuesize(QSIZE) - config.setwidth(AL.SAMPLE_16) - config.setchannels(AL.MONO) - # - pid = posix.fork() - if pid: - # Parent -- speaker/headphones handler - log('parent started') - spkr = al.openport('spkr', 'w', config) - while 1: - data = s.recv(BUFSIZE) - if len(data) == 0: - # EOF packet - log('parent got empty packet; killing child') - posix.kill(pid, 15) - return - # Discard whole packet if we are too much behind - if spkr.getfillable() > len(data) / BYTESPERSAMP: - if len(debug) >= 2: - log('parent Q full; dropping packet') - spkr.writesamps(data) - else: - # Child -- microphone handler - log('child started') - try: - try: - mike = al.openport('mike', 'r', config) - # Sleep a while to let the other side get started - time.sleep(1) - # Drain the queue before starting to read - data = mike.readsamps(mike.getfilled()) - # Loop, sending packets from the mike to the net - while 1: - data = mike.readsamps(SAMPSPERBUF) - s.sendto(data, otheraddr) - except KeyboardInterrupt: - log('child got interrupt; exiting') - posix._exit(0) - except error: - log('child got error; exiting') - posix._exit(1) - finally: - log('child got unexpected error; leaving w/ traceback') - -def log(msg): - if not debug: return - if type(msg) <> type(''): - msg = `msg` - - f = open('/tmp/intercom.log', 'a') - f.write(`sys.argv` + ' ' + `posix.getpid()` + ': ' + msg + '\n') - f.close() - -main() diff --git a/Demo/sgi/al/listen.py b/Demo/sgi/al/listen.py deleted file mode 100755 index 83f850a..0000000 --- a/Demo/sgi/al/listen.py +++ /dev/null @@ -1,34 +0,0 @@ -# Listen to the input on host argv[1]. - -import sys, al, AL, posix - -BUFSIZE = 2000 -QSIZE = 4000 - -def main(): - if len(sys.argv) <> 2: - sys.stderr.write('usage: ' + sys.argv[0] + ' hostname\n') - sys.exit(2) - hostname = sys.argv[1] - cmd = 'exec rsh 'FORM': - raise aiff.Error, 'FORM chunk expected at start of file' - aiff.read_form_chunk(f) - while 1: - try: - type, size = aiff.read_chunk_header(f) - except EOFError: - break - if v: print 'header:', `type`, size - if type == 'COMM': - nchannels, nsampframes, sampwidth, samprate = \ - aiff.read_comm_chunk(f) - if v: print nchannels, nsampframes, sampwidth, samprate - elif type == 'SSND': - offset, blocksize = aiff.read_ssnd_chunk(f) - if v: print offset, blocksize - data = f.read(size-8) - if size%2: void = f.read(1) - p = makeport(nchannels, sampwidth, samprate) - play(p, data, offset, blocksize) - elif type in aiff.skiplist: - aiff.skip_chunk(f, size) - else: - raise aiff.Error, 'bad chunk type ' + type - -def makeport(nchannels, sampwidth, samprate): - c = al.newconfig() - c.setchannels(nchannels) - c.setwidth(sampwidth/8) - # can't set the rate... - p = al.openport('', 'w', c) - return p - -def play(p, data, offset, blocksize): - data = data[offset:] - p.writesamps(data) - while p.getfilled() > 0: time.sleep(0.01) - -main() diff --git a/Demo/sgi/al/playback.py b/Demo/sgi/al/playback.py deleted file mode 100755 index 967f746..0000000 --- a/Demo/sgi/al/playback.py +++ /dev/null @@ -1,23 +0,0 @@ -# Read mono 16bit samples from stdin and write them to the audio device. -# Assume the sampling rate is compatible. -# Use a small queue size to minimize delays. - -import al, sys -import AL - -BUFSIZE = 2000 -QSIZE = 4000 - -def main(): - c = al.newconfig() - c.setchannels(AL.MONO) - c.setqueuesize(QSIZE) - p = al.openport('', 'w', c) - while 1: - data = sys.stdin.read(BUFSIZE) - p.writesamps(data) - -try: - main() -except KeyboardInterrupt: - sys.exit(1) diff --git a/Demo/sgi/al/playold.py b/Demo/sgi/al/playold.py deleted file mode 100755 index 9792c16..0000000 --- a/Demo/sgi/al/playold.py +++ /dev/null @@ -1,51 +0,0 @@ -# Play old style sound files (Guido's private format) - -import al, sys, time -import AL - -BUFSIZE = 8000 - -def main(): - if len(sys.argv) < 2: - f = sys.stdin - filename = sys.argv[0] - else: - if len(sys.argv) <> 2: - sys.stderr.write('usage: ' + \ - sys.argv[0] + ' filename\n') - sys.exit(2) - filename = sys.argv[1] - f = open(filename, 'r') - # - magic = f.read(4) - extra = '' - if magic == '0008': - rate = 8000 - elif magic == '0016': - rate = 16000 - elif magic == '0032': - rate = 32000 - else: - sys.stderr.write('no magic header; assuming 8k samples/sec.\n') - rate = 8000 - extra = magic - # - pv = [AL.OUTPUT_RATE, rate] - al.setparams(AL.DEFAULT_DEVICE, pv) - c = al.newconfig() - c.setchannels(AL.MONO) - c.setwidth(AL.SAMPLE_8) - port = al.openport(filename, 'w', c) - if extra: - port.writesamps(extra) - while 1: - buf = f.read(BUFSIZE) - if not buf: break - port.writesamps(buf) - while port.getfilled() > 0: - time.sleep(0.1) - -try: - main() -except KeyboardInterrupt: - sys.exit(1) diff --git a/Demo/sgi/al/radio.py b/Demo/sgi/al/radio.py deleted file mode 100755 index b9d30d2..0000000 --- a/Demo/sgi/al/radio.py +++ /dev/null @@ -1,21 +0,0 @@ -#! /usr/bin/env python - -# radio [port] -# -# Receive audio packets broadcast by "broadcast.py" on another SGI machine. -# Use apanel to set the output sampling rate to match that of the broadcast. - -import sys, al -from socket import * - -port = 5555 -if sys.argv[1:]: port = eval(sys.argv[1]) - -s = socket(AF_INET, SOCK_DGRAM) -s.bind('', port) - -p = al.openport('radio', 'w') - -while 1: - data = s.recv(1400) - p.writesamps(data) diff --git a/Demo/sgi/al/rec_play.py b/Demo/sgi/al/rec_play.py deleted file mode 100755 index 693c96e..0000000 --- a/Demo/sgi/al/rec_play.py +++ /dev/null @@ -1,28 +0,0 @@ -# -# records an AIFF sample and plays it -# infinity number of times. -# - -import time -import al - -def recordit () : - p = al.openport('hello', 'r') - print 'recording...' - buf = p.readsamps(500000) - print 'done.' - p.closeport() - - return buf - -def playit (buf) : - p = al.openport('hello', 'w') - print 'playing...' - p.writesamps(buf) - while p.getfilled() > 0: - time.sleep(0.01) - print 'done.' - p.closeport() - -while 1 : - playit (recordit ()) diff --git a/Demo/sgi/al/record.py b/Demo/sgi/al/record.py deleted file mode 100755 index e5c0f5b..0000000 --- a/Demo/sgi/al/record.py +++ /dev/null @@ -1,23 +0,0 @@ -# Record mono 16bits samples from the audio device and send them to stdout. -# Assume the sampling rate is compatible. -# Use a small queue size to minimize delays. - -import al, sys -import AL - -BUFSIZE = 2000 -QSIZE = 4000 - -def main(): - c = al.newconfig() - c.setchannels(AL.MONO) - c.setqueuesize(QSIZE) - p = al.openport('', 'r', c) - while 1: - data = p.readsamps(BUFSIZE) - sys.stdout.write(data) - -try: - main() -except KeyboardInterrupt: - sys.exit(1) diff --git a/Demo/sgi/al/unicast.py b/Demo/sgi/al/unicast.py deleted file mode 100755 index 0d537b1..0000000 --- a/Demo/sgi/al/unicast.py +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env python - -# unicast host [port] -# -# Similar to "broadcast.py" but sends to a specific host only; -# use "radio.py" on the designated host to receive. -# This is less stressful on other hosts on the same ethernet segment -# if you need to send to one host only. - -import sys, al -from socket import * - -host = sys.argv[1] - -port = 5555 -if sys.argv[2:]: port = eval(sys.argv[1]) - -s = socket(AF_INET, SOCK_DGRAM) - -p = al.openport('unicast', 'r') - -address = host, port -while 1: - # 700 samples equals 1400 bytes, or about the max packet size! - data = p.readsamps(700) - s.sendto(data, address) diff --git a/Demo/sgi/al/x.py b/Demo/sgi/al/x.py deleted file mode 100755 index ecc12d8..0000000 --- a/Demo/sgi/al/x.py +++ /dev/null @@ -1,12 +0,0 @@ -# Demonstrate that rsh exits when the remote end closes std{in,out,err}. -# rsh voorn exec /ufs/guido/bin/sgi/python /ufs/guido/mm/demo/audio/x.py - -print 'hoi!' -import sys -sys.stdin.close() -sys.stdout.close() -sys.stderr.close() -import time -time.sleep(5) -sys.stdout = open('@', 'w') -sys.stdout.write('Hello\n') diff --git a/Demo/sgi/audio/README b/Demo/sgi/audio/README deleted file mode 100644 index 02a3701..0000000 --- a/Demo/sgi/audio/README +++ /dev/null @@ -1,8 +0,0 @@ -Programs that demonstrate the use of the audio device on the SGI 4D/25. -These require the built-in module 'audio'. - -XXX This hardware is already obsolete; see ../al for examples of audio -XXX on the Indigo and 4D/35. - -play Read a sound sample from a file and play it through the - speaker. Options to set volume, sampling rate etc. diff --git a/Demo/sgi/audio/play.py b/Demo/sgi/audio/play.py deleted file mode 100755 index 68a6a31..0000000 --- a/Demo/sgi/audio/play.py +++ /dev/null @@ -1,75 +0,0 @@ -#! /usr/bin/env python - -import sys -import audio - -import string -import getopt -import auds - -debug = [] - -DEF_RATE = 3 - -def main(): - # - gain = 100 - rate = 0 - starter = audio.write - stopper = 0 - # - optlist, args = getopt.getopt(sys.argv[1:], 'adg:r:') - # - for optname, optarg in optlist: - if 0: - pass - elif optname == '-d': - debug.append(1) - elif optname == '-g': - gain = string.atoi(optarg) - if not (0 < gain < 256): - raise optarg.error, '-g gain out of range' - elif optname == '-r': - rate = string.atoi(optarg) - if not (1 <= rate <= 3): - raise optarg.error, '-r rate out of range' - elif optname == '-a': - starter = audio.start_playing - stopper = audio.wait_playing - # - audio.setoutgain(gain) - audio.setrate(rate) - # - if not args: - play(starter, rate, auds.loadfp(sys.stdin)) - else: - real_stopper = 0 - for file in args: - if real_stopper: - real_stopper() - play(starter, rate, auds.load(file)) - real_stopper = stopper - -def play(starter, rate, data): - magic = data[:4] - if magic == '0008': - mrate = 3 - elif magic == '0016': - mrate = 2 - elif magic == '0032': - mrate = 1 - else: - mrate = 0 - if mrate: - data = data[4:] - else: - mrate = DEF_RATE - if not rate: rate = mrate - audio.setrate(rate) - starter(data) - -try: - main() -finally: - audio.setoutgain(0) - audio.done() diff --git a/Demo/sgi/sv/README b/Demo/sgi/sv/README deleted file mode 100644 index 38e5140..0000000 --- a/Demo/sgi/sv/README +++ /dev/null @@ -1,23 +0,0 @@ -Demo programs for the SGI Video library for the Indigo (IRIX 4.0.5). - -These are more-or-less literal translations of the C programs from the -Indigo Video Programming Guide, by Sjoerd Mullender, with some changes -by Guido. - -Note that none of the example programs save any data to a file, -although this would be easy to do (e.g. individual grabbed frames -could be written as SGI image files using the imgfile module). - -We have written a Python program to record live video to file (within -the limits of the Indigo video board), and a suite of programs to -manipulate and display such files. At the moment we don't distribute -these programs, since the file format is, eh..., weird, to say the -least. However, if you are really interested we can mail you the -source. - -Also note that we haven't tried using video *output* yet. - -simpleinput.py Live video in a resizable window -rgbgrab.py Grab still frames -contcapt.py Continuous capturing -burstcapt.py Burst capturing diff --git a/Demo/sgi/sv/burstcapt.py b/Demo/sgi/sv/burstcapt.py deleted file mode 100755 index ce1e579..0000000 --- a/Demo/sgi/sv/burstcapt.py +++ /dev/null @@ -1,52 +0,0 @@ -import sys -import sv, SV -import gl, GL, DEVICE - -def main(): - format = SV.RGB8_FRAMES - requestedwidth = SV.PAL_XMAX - queuesize = 30 - if sys.argv[1:]: - queuesize = eval(sys.argv[1]) - - v = sv.OpenVideo() - svci = (format, requestedwidth, 0, queuesize, 0) - - go = raw_input('Press return to capture ' + `queuesize` + ' frames: ') - result = v.CaptureBurst(svci) - svci, buffer, bitvec = result -## svci, buffer = result # XXX If bit vector not yet implemented - - print 'Captured', svci[3], 'frames, i.e.', len(buffer)/1024, 'K bytes' - - w, h = svci[1:3] - framesize = w * h - - gl.prefposition(300, 300+w-1, 100, 100+h-1) - gl.foreground() - win = gl.winopen('Burst Capture') - gl.RGBmode() - gl.gconfig() - gl.qdevice(DEVICE.LEFTMOUSE) - gl.qdevice(DEVICE.ESCKEY) - - print 'Click left mouse for next frame' - - for i in range(svci[3]): - inverted_frame = sv.RGB8toRGB32(1, \ - buffer[i*framesize:(i+1)*framesize], w, h) - gl.lrectwrite(0, 0, w-1, h-1, inverted_frame) - while 1: - dev, val = gl.qread() - if dev == DEVICE.LEFTMOUSE and val == 1: - break - if dev == DEVICE.REDRAW: - gl.lrectwrite(0, 0, w-1, h-1, inverted_frame) - if dev == DEVICE.ESCKEY: - v.CloseVideo() - gl.winclose(win) - return - v.CloseVideo() - gl.winclose(win) - -main() diff --git a/Demo/sgi/sv/contcapt.py b/Demo/sgi/sv/contcapt.py deleted file mode 100755 index 6c0a000..0000000 --- a/Demo/sgi/sv/contcapt.py +++ /dev/null @@ -1,107 +0,0 @@ -import sys -import sv, SV -import gl, GL, DEVICE - -def main(): - format = SV.RGB8_FRAMES - framerate = 25 - queuesize = 16 - samplingrate = 2 - - v = sv.OpenVideo() - # Determine maximum window size based on signal standard - param = [SV.BROADCAST, 0] - v.GetParam(param) - if param[1] == SV.PAL: - width = SV.PAL_XMAX - height = SV.PAL_YMAX - framefreq = 25 - else: - width = SV.NTSC_XMAX - height = SV.NTSC_YMAX - framefreq = 30 - - # Allow resizing window if capturing RGB frames, which can be scaled - if format == SV.RGB8_FRAMES: - gl.keepaspect(width, height) - gl.maxsize(width, height) - gl.stepunit(8, 6) - gl.minsize(120, 90) - else: - if format == SV.YUV411_FRAMES_AND_BLANKING_BUFFER: - height = height + SV.BLANKING_BUFFER_SIZE - gl.prefposition(300, 300+width-1, 100, 100+height-1) - - # Open the window - gl.foreground() - win = gl.winopen('Continuous Capture') - gl.RGBmode() - gl.gconfig() - if format == SV.RGB8_FRAMES: - width, height = gl.getsize() - gl.pixmode(GL.PM_SIZE, 8) - else: - gl.pixmode(GL.PM_SIZE, 32) - - svci = (format, width, height, queuesize, samplingrate) - [svci] - - svci = v.InitContinuousCapture(svci) - width, height = svci[1:3] - [svci] - - hz = gl.getgdesc(GL.GD_TIMERHZ) - gl.noise(DEVICE.TIMER0, hz / framerate) - gl.qdevice(DEVICE.TIMER0) - gl.qdevice(DEVICE.WINQUIT) - gl.qdevice(DEVICE.WINSHUT) - gl.qdevice(DEVICE.ESCKEY) - - ndisplayed = 0 - lastfieldID = 0 - - while 1: - dev, val = gl.qread() - if dev == DEVICE.REDRAW: - oldw = width - oldh = height - width, height = gl.getsize() - if oldw != width or oldh != height: - v.EndContinuousCapture() - gl.viewport(0, width-1, 0, height-1) - svci = (svci[0], width, height) + svci[3:] - svci = v.InitContinuousCapture(svci) - width, height = svci[1:3] - [svci] - if ndisplayed: - print 'lost', - print fieldID/(svci[4]*2) - ndisplayed, - print 'frames' - ndisplayed = 0 - elif dev == DEVICE.TIMER0: - try: - captureData, fieldID = v.GetCaptureData() - except sv.error, val: - if val <> 'no data available': - print val - continue - if fieldID - lastfieldID <> 2*samplingrate: - print lastfieldID, fieldID - lastfieldID = fieldID - if svci[0] == SV.RGB8_FRAMES: - rgbbuf = captureData.InterleaveFields(1) - else: - rgbbuf = captureData.YUVtoRGB(1) - captureData.UnlockCaptureData() - gl.lrectwrite(0, 0, width-1, height-1, rgbbuf) - ndisplayed = ndisplayed + 1 - elif dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT): - v.EndContinuousCapture() - v.CloseVideo() - gl.winclose(win) - print fieldID, ndisplayed, svci[4] - print 'lost', fieldID/(svci[4]*2) - ndisplayed, - print 'frames' - return - -main() diff --git a/Demo/sgi/sv/rgbgrab.py b/Demo/sgi/sv/rgbgrab.py deleted file mode 100755 index 8013a53..0000000 --- a/Demo/sgi/sv/rgbgrab.py +++ /dev/null @@ -1,81 +0,0 @@ -import sys -import sv, SV -import gl, GL, DEVICE -import time - -def main(): - v = sv.OpenVideo() - # Determine maximum window size based on signal standard - param = [SV.BROADCAST, 0] - v.GetParam(param) - if param[1] == SV.PAL: - width = SV.PAL_XMAX - height = SV.PAL_YMAX - elif param[1] == SV.NTSC: - width = SV.NTSC_XMAX - height = SV.NTSC_YMAX - else: - print 'Unknown video standard', param[1] - sys.exit(1) - - # Initially all windows are half size - grabwidth, grabheight = width/2, height/2 - - # Open still window - gl.foreground() - gl.prefsize(grabwidth, grabheight) - still_win = gl.winopen('Grabbed frame') - gl.keepaspect(width, height) - gl.maxsize(width, height) - gl.winconstraints() - gl.RGBmode() - gl.gconfig() - gl.clear() - gl.pixmode(GL.PM_SIZE, 8) - - # Open live window - gl.foreground() - gl.prefsize(grabwidth, grabheight) - live_win = gl.winopen('Live video') - gl.keepaspect(width, height) - gl.maxsize(width, height) - gl.winconstraints() - - # Bind live video - v.SetSize(gl.getsize()) - v.BindGLWindow(live_win, SV.IN_REPLACE) - - print 'Use leftmouse to grab frame' - - gl.qdevice(DEVICE.LEFTMOUSE) - gl.qdevice(DEVICE.WINQUIT) - gl.qdevice(DEVICE.WINSHUT) - gl.qdevice(DEVICE.ESCKEY) - frame = None - while 1: - dev, val = gl.qread() - if dev == DEVICE.LEFTMOUSE and val == 0: - w, h, fields = v.CaptureOneFrame(SV.RGB8_FRAMES, \ - grabwidth, grabheight) - frame = sv.InterleaveFields(1, fields, w, h) - gl.winset(still_win) - gl.lrectwrite(0, 0, w - 1, h - 1, frame) - gl.winset(live_win) - if dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT): - v.CloseVideo() - gl.winclose(live_win) - gl.winclose(still_win) - break - if dev == DEVICE.REDRAW and val == still_win: - gl.winset(still_win) - gl.reshapeviewport() - gl.clear() - grabwidth, grabheight = gl.getsize() - if frame: - gl.lrectwrite(0, 0, w - 1, h - 1, frame) - gl.winset(live_win) - if dev == DEVICE.REDRAW and val == live_win: - v.SetSize(gl.getsize()) - v.BindGLWindow(live_win, SV.IN_REPLACE) - -main() diff --git a/Demo/sgi/sv/simpleinput.py b/Demo/sgi/sv/simpleinput.py deleted file mode 100755 index 97b75fa..0000000 --- a/Demo/sgi/sv/simpleinput.py +++ /dev/null @@ -1,22 +0,0 @@ -import sv, SV -import gl, DEVICE - -def main(): - gl.foreground() - gl.prefsize(SV.PAL_XMAX, SV.PAL_YMAX) - win = gl.winopen('video test') - v = sv.OpenVideo() - params = [SV.VIDEO_MODE, SV.COMP, SV.BROADCAST, SV.PAL] - v.SetParam(params) - v.BindGLWindow(win, SV.IN_REPLACE) - gl.qdevice(DEVICE.ESCKEY) - gl.qdevice(DEVICE.WINQUIT) - gl.qdevice(DEVICE.WINSHUT) - while 1: - dev, val = gl.qread() - if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT): - v.CloseVideo() - gl.winclose(win) - return - -main() -- cgit v0.12