def main(): G.synchronous = 0 # If set, use synchronous audio.write() G.debug = 0 # If set, print debug messages G.gain = 75 # Output gain G.rate = 3 # Sampling rate G.busy = 0 # Set while asynchronous playing is active G.windows = [] # List of open windows (except control) G.mode = 'mac' # Macintosh mode G.tempprefix = '/usr/tmp/@j' + `rand.rand()` + '-' # optlist, args = getopt.getopt(sys.argv[1:], 'dg:r:sSa') for optname, optarg in optlist: if optname == '-d': G.debug = 1 elif optname == '-g': G.gain = string.atoi(optarg) if not (0 < G.gain < 256): raise optarg.error, '-g gain out of range' elif optname == '-r': G.rate = string.atoi(optarg) if not (1 <= G.rate <= 3): raise optarg.error, '-r rate out of range' elif optname == '-s': G.synchronous = 1 elif optname == '-S': G.mode = 'sgi' elif optname == '-a': G.mode = 'sun' # if not args: args = [DEF_DB] # G.cw = opencontrolwindow() for dirname in args: G.windows.append(openlistwindow(dirname)) # # savegain = audio.getoutgain() try: # Initialize stdaudio audio.setoutgain(0) audio.start_playing('') dummy = audio.wait_playing() audio.setoutgain(0) maineventloop() finally: audio.setoutgain(savegain) audio.done() clearcache()
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()
#! /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):
#! /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'