Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 715a653

Browse files
committed
Initial revision
1 parent 4a5ab81 commit 715a653

10 files changed

Lines changed: 983 additions & 0 deletions

File tree

Demo/sgi/audio/README

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Programs that demonstrate the use of the audio device on the SGI 4D/25.
2+
These require the built-in module 'audio'.
3+
4+
XXX This hardware is already obsolete; see ../al for examples of audio
5+
XXX on the Indigo and 4D/35.
6+
7+
play Read a sound sample from a file and play it through the
8+
speaker. Options to set volume, sampling rate etc.

Demo/sgi/audio/play.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#! /usr/local/python
2+
3+
import sys
4+
import audio
5+
6+
import string
7+
import getopt
8+
import auds
9+
10+
debug = []
11+
12+
DEF_RATE = 3
13+
14+
def main():
15+
#
16+
gain = 100
17+
rate = 0
18+
starter = audio.write
19+
stopper = 0
20+
#
21+
optlist, args = getopt.getopt(sys.argv[1:], 'adg:r:')
22+
#
23+
for optname, optarg in optlist:
24+
if 0:
25+
pass
26+
elif optname == '-d':
27+
debug.append(1)
28+
elif optname == '-g':
29+
gain = string.atoi(optarg)
30+
if not (0 < gain < 256):
31+
raise optarg.error, '-g gain out of range'
32+
elif optname == '-r':
33+
rate = string.atoi(optarg)
34+
if not (1 <= rate <= 3):
35+
raise optarg.error, '-r rate out of range'
36+
elif optname == '-a':
37+
starter = audio.start_playing
38+
stopper = audio.wait_playing
39+
#
40+
audio.setoutgain(gain)
41+
audio.setrate(rate)
42+
#
43+
if not args:
44+
play(starter, rate, auds.loadfp(sys.stdin))
45+
else:
46+
real_stopper = 0
47+
for file in args:
48+
if real_stopper:
49+
real_stopper()
50+
play(starter, rate, auds.load(file))
51+
real_stopper = stopper
52+
53+
def play(starter, rate, data):
54+
magic = data[:4]
55+
if magic == '0008':
56+
mrate = 3
57+
elif magic == '0016':
58+
mrate = 2
59+
elif magic == '0032':
60+
mrate = 1
61+
else:
62+
mrate = 0
63+
if mrate:
64+
data = data[4:]
65+
else:
66+
mrate = DEF_RATE
67+
if not rate: rate = mrate
68+
audio.setrate(rate)
69+
starter(data)
70+
71+
try:
72+
main()
73+
finally:
74+
audio.setoutgain(0)
75+
audio.done()

Demo/sgi/audio_stdwin/README

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Three programs that provide a user interface based upon STDWIN to the
2+
audio device of the SGI 4D/25. These scripts also demonstrate the power
3+
of a set of window interface classes implemented in Python that simplify
4+
the construction of all sorts of buttons, etc.
5+
6+
XXX This hardware is already obsolete; see ../al for examples of audio
7+
XXX on the Indigo and 4D/35.
8+
9+
jukebox Browses a directory full of sound samples and lets you
10+
play selected ones. (Probably not fully functional, it
11+
requires a conversion program.)
12+
13+
rec A tape recorder that lets you record a sound sample,
14+
play it back, and save it to a file. Various options to
15+
set sampling rate, volume etc. When idle it doubles
16+
as a VU meter.
17+
18+
vumeter A VU meter that displays a history of the volume of
19+
sound recently sampled from the microphone.

0 commit comments

Comments
 (0)