Example #1
0
	def open_audio(self):
		if self.aformat == A_OFF:
			return
		import aifc
		import al
		import AL
		import thread
		self.close_audio()
		params = [AL.INPUT_RATE, 0]
		al.getparams(AL.DEFAULT_DEVICE, params)
		rate = params[1]
		self.aout = aifc.open(self.afile, 'w')
		if self.aformat in (A_16_STEREO, A_8_STEREO):
			nch = AL.STEREO
		else:
			nch = AL.MONO
		if self.aformat in (A_16_STEREO, A_16_MONO):
			width = AL.SAMPLE_16
		else:
			width = AL.SAMPLE_8
		self.aout.setnchannels(nch)
		self.aout.setsampwidth(width)
		self.aout.setframerate(rate)
		c = al.newconfig()
		c.setqueuesize(8000)
		c.setchannels(nch)
		c.setwidth(width)
		self.aport = al.openport('Vb audio record', 'r', c)
		self.audio_stop = 0
		self.audio_ok = 0
		self.audio_busy = 1
		thread.start_new_thread(self.record_audio, ())
Example #2
0
	def handle_11(self): # openport
		name, mode, config_flat = self.unpacker.unpack_openport()
		self.turn_around()
##		print 'openport:', name, mode, config_flat
		queuesize, width, channels, sampfmt, floatmax = config_flat
		try:
			c = al.newconfig()
			c.setqueuesize(queuesize)
			c.setwidth(width)
			c.setchannels(channels)
			c.setsampfmt(sampfmt)
			c.setfloatmax(floatmax)
			p = al.openport(name, mode, c)
		except RuntimeError:
			self.packer.pack_int(-1) # Should get error code?
			return
		for i in range(len(self.all_ports)):
			if self.all_ports[i] is None:
				self.all_ports[i] = p
				break
		else:
			i = len(self.all_ports)
			self.all_ports.append(p)
##		print 'openport ->', i
		self.packer.pack_int(i)
Example #3
0
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
Example #4
0
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
Example #5
0
File: Vb.py Project: carol8421/gosh
	def open_audio(self):
		if self.aformat == A_OFF:
			return
		import aifc
		import al
		import AL
		import thread
		self.close_audio()
		params = [AL.INPUT_RATE, 0]
		al.getparams(AL.DEFAULT_DEVICE, params)
		rate = params[1]
		self.aout = aifc.open(self.afile, 'w')
		if self.aformat in (A_16_STEREO, A_8_STEREO):
			nch = AL.STEREO
		else:
			nch = AL.MONO
		if self.aformat in (A_16_STEREO, A_16_MONO):
			width = AL.SAMPLE_16
		else:
			width = AL.SAMPLE_8
		self.aout.setnchannels(nch)
		self.aout.setsampwidth(width)
		self.aout.setframerate(rate)
		c = al.newconfig()
		c.setqueuesize(8000)
		c.setchannels(nch)
		c.setwidth(width)
		self.aport = al.openport('Vb audio record', 'r', c)
		self.audio_stop = 0
		self.audio_ok = 0
		self.audio_busy = 1
		thread.start_new_thread(self.record_audio, ())
Example #6
0
def main():
    v = 1
    c = al.newconfig()
    nchannels = c.getchannels()
    nsampframes = 0  # ???
    sampwidth = c.getwidth()
    samprate = 0.0  # unknown
    filename = sys.argv[1]
    f = open(filename, 'r')
    type, totalsize = aiff.read_chunk_header(f)
    if type <> '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
Example #7
0
def main():
	v = 1
	c = al.newconfig()
	nchannels = c.getchannels()
	nsampframes = 0 # ???
	sampwidth = c.getwidth()
	samprate = 0.0 # unknown
	filename = sys.argv[1]
	f = open(filename, 'r')
	type, totalsize = aiff.read_chunk_header(f)
	if type <> '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
Example #8
0
def main():
    s = socket(AF_INET, SOCK_DGRAM)
    s.bind('', PORT)

    oldparams = [AL.OUTPUT_RATE, 0]
    params = oldparams[:]
    al.getparams(AL.DEFAULT_DEVICE, oldparams)
    params[1] = AL.RATE_44100
    try:
        al.setparams(AL.DEFAULT_DEVICE, params)
        config = al.newconfig()
        config.setwidth(AL.SAMPLE_16)
        config.setchannels(AL.STEREO)
        port = al.openport('CD Player', 'w', config)

        while 1:
            data = s.recv(CDDA_DATASIZE)
            if not data:
                print 'EOF'
                break
            port.writesamps(data)
    except KeyboardInterrupt:
        pass

    al.setparams(AL.DEFAULT_DEVICE, oldparams)
Example #9
0
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)
Example #10
0
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)
Example #11
0
	def getconfig(self):
		config_flat = self.conn.call_19(self.index)
		queuesize, width, channels, sampfmt, floatmax = config_flat
		c = al.newconfig()
		c.setqueuesize(queuesize)
		c.setwidth(width)
		c.setchannels(channels)
		c.setsampfmt(sampfmt)
		c.setfloatmax(floatmax)
		return c
Example #12
0
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')
Example #13
0
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')
Example #14
0
	def __init__(self):
		import al
		self.oldparams = []
		self.params = [AL.OUTPUT_RATE, 0]
		self.config = al.newconfig()
		self.inited_outrate = 0
		self.inited_width = 0
		self.inited_nchannels = 0
		self.converter = None
		self.port = None
		return
Example #15
0
	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')
Example #16
0
 def __init__(self, fmt = None, qsize = None):
     self.__format = None
     self.__framerate = 0
     self.__params = [al.OUTPUT_RATE, 0]
     self.__oldparams = []
     self.__port = None
     self.__config = al.newconfig()
     if fmt:
         self.setformat(fmt)
     if qsize and hasattr(al, 'OpenPort'):
         # only set queuesize on modern systems :-(
         self.__config.setqueuesize(qsize)
Example #17
0
 def __init__(self):
     import al, AL
     if not self.classinited:
         self.initclass()
     self.oldparams = []
     self.params = [AL.OUTPUT_RATE, 0]
     self.config = al.newconfig()
     self.inited_outrate = 0
     self.inited_width = 0
     self.inited_nchannels = 0
     self.converter = None
     self.port = None
     return
Example #18
0
def main():
	import sys, readcd, al, AL, CD, cdplayer
	verbose = 0
	r = readcd.Readcd()
	prstatus(r.getstatus())
	prtrackinfo(r.gettrackinfo())
	cdinfo = cdplayer.Cdplayer(r.gettrackinfo())
	if cdinfo.title <> '':
		print 'Title: "' + cdinfo.title + '"'
	if cdinfo.artist <> '':
		print 'Artist: ' + cdinfo.artist
	for arg in sys.argv[1:]:
		if arg == '-v':
			verbose = 1
			continue
		x = eval(arg)
		try:
			l = len(x)
			r.appendstretch(x[0], x[1])
		except TypeError:
			r.appendtrack(x)
	try:
		oldparams = [AL.OUTPUT_RATE, 0]
		params = oldparams[:]
		al.getparams(AL.DEFAULT_DEVICE, oldparams)
		params[1] = AL.RATE_44100
		al.setparams(AL.DEFAULT_DEVICE, params)
		config = al.newconfig()
		config.setwidth(AL.SAMPLE_16)
		config.setchannels(AL.STEREO)
		port = al.openport('CD Player', 'w', config)

		for i in range(8):
			r.setcallback(i, callback, None)
		if verbose:
			r.setcallback(CD.PTIME, tcallback, None)
			r.setcallback(CD.ATIME, tcallback, None)
		else:
			r.removecallback(CD.PTIME)
			r.removecallback(CD.ATIME)
		r.setcallback(CD.PNUM, prtrack, cdinfo)
		r.setcallback(CD.AUDIO, playaudio, port)

		data = r.play()
	except KeyboardInterrupt:
		status = r.getstatus()
		print 'Interrupted at '+triple(status[2])+' into track '+ \
			  `status[1]`+' (absolute time '+triple(status[3])+')'
	al.setparams(AL.DEFAULT_DEVICE, oldparams)
Example #19
0
def main():
    import sys, readcd, al, AL, CD, cdplayer
    verbose = 0
    r = readcd.Readcd().init()
    prstatus(r.getstatus())
    prtrackinfo(r.gettrackinfo())
    cdinfo = cdplayer.Cdplayer().init(r.gettrackinfo())
    if cdinfo.title <> '':
        print 'Title: "' + cdinfo.title + '"'
    if cdinfo.artist <> '':
        print 'Artist: ' + cdinfo.artist
    for arg in sys.argv[1:]:
        if arg == '-v':
            verbose = 1
            continue
        x = eval(arg)
        try:
            l = len(x)
            r.appendstretch(x[0], x[1])
        except TypeError:
            r.appendtrack(x)
    try:
        oldparams = [AL.OUTPUT_RATE, 0]
        params = oldparams[:]
        al.getparams(AL.DEFAULT_DEVICE, oldparams)
        params[1] = AL.RATE_44100
        al.setparams(AL.DEFAULT_DEVICE, params)
        config = al.newconfig()
        config.setwidth(AL.SAMPLE_16)
        config.setchannels(AL.STEREO)
        port = al.openport('CD Player', 'w', config)

        for i in range(8):
            r.setcallback(i, callback, None)
        if verbose:
            r.setcallback(CD.PTIME, tcallback, None)
            r.setcallback(CD.ATIME, tcallback, None)
        else:
            r.removecallback(CD.PTIME)
            r.removecallback(CD.ATIME)
        r.setcallback(CD.PNUM, prtrack, cdinfo)
        r.setcallback(CD.AUDIO, playaudio, port)

        data = r.play()
    except KeyboardInterrupt:
        status = r.getstatus()
        print 'Interrupted at '+triple(status[2])+' into track '+ \
           `status[1]`+' (absolute time '+triple(status[3])+')'
    al.setparams(AL.DEFAULT_DEVICE, oldparams)
Example #20
0
def initaudio(filename, stop, start, done):
    import thread, aifc
    afile = aifc.open(filename, 'w')
    afile.setnchannels(AL.MONO)
    afile.setsampwidth(AL.SAMPLE_8)
    params = [AL.INPUT_RATE, 0]
    al.getparams(AL.DEFAULT_DEVICE, params)
    print 'audio sampling rate =', params[1]
    afile.setframerate(params[1])
    c = al.newconfig()
    c.setchannels(AL.MONO)
    c.setqueuesize(AQSIZE)
    c.setwidth(AL.SAMPLE_8)
    aport = al.openport(filename, 'r', c)
    thread.start_new_thread(audiorecord, (afile, aport, stop, start, done))
Example #21
0
def initaudio(filename, stop, done):
	import thread, aifc
	afile = aifc.open(filename, 'w')
	afile.setnchannels(AL.MONO)
	afile.setsampwidth(AL.SAMPLE_8)
	params = [AL.INPUT_RATE, 0]
	al.getparams(AL.DEFAULT_DEVICE, params)
	print 'audio sampling rate =', params[1]
	afile.setframerate(params[1])
	c = al.newconfig()
	c.setchannels(AL.MONO)
	c.setqueuesize(AQSIZE)
	c.setwidth(AL.SAMPLE_8)
	aport = al.openport(filename, 'r', c)
	thread.start_new_thread(audiorecord, (afile, aport, stop, done))
Example #22
0
	def handle_20(self): # setconfig
		i = self.unpacker.unpack_int()
		config_flat = self.unpacker.unpack_config()
		self.turn_around()
##		print 'setconfig:', i, config_flat
		p = self.getport(i)
		if p is None:
			return
		queuesize, width, channels, sampfmt, floatmax = config_flat
		c = al.newconfig()
		# (You can't change queuesize and channels of an open port)
		# c.setqueuesize(queuesize)
		c.setwidth(width)
		# c.setchannels(channels)
		c.setsampfmt(sampfmt)
		c.setfloatmax(floatmax)
		p.setconfig(c)
Example #23
0
def initaudio(filename):
	import thread, aiff
	global recording, stop_recording
	afile = aiff.Aiff().init(filename, 'w')
	afile.nchannels = AL.MONO
	afile.sampwidth = AL.SAMPLE_8
	params = [AL.INPUT_RATE, 0]
	al.getparams(AL.DEFAULT_DEVICE, params)
	print 'rate =', params[1]
	afile.samprate = params[1]
	c = al.newconfig()
	c.setchannels(AL.MONO)
	c.setqueuesize(AQSIZE)
	c.setwidth(AL.SAMPLE_8)
	aport = al.openport(filename, 'r', c)
	recording = thread.allocate_lock()
	recording.acquire()
	stop_recording = 0
	thread.start_new_thread(recorder, (afile, aport))
	return afile
Example #24
0
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 </dev/null ' + hostname + \
		' "cd /ufs/guido/mm/demo/audio; ' + \
		'exec /ufs/guido/bin/sgi/python record.py"'
	pipe = posix.popen(cmd, 'r')
	config = al.newconfig()
	config.setchannels(AL.MONO)
	config.setqueuesize(QSIZE)
	port = al.openport('', 'w', config)
	while 1:
		data = pipe.read(BUFSIZE)
		if not data:
			sts = pipe.close()
			sys.stderr.write(sys.argv[0] + ': end of data\n')
			if sts: sys.stderr.write('rsh exit status '+`sts`+'\n')
			sys.exit(1)
		port.writesamps(data)
		del data
Example #25
0
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.millisleep(100)
Example #26
0
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 </dev/null ' + hostname + \
     ' "cd /ufs/guido/mm/demo/audio; ' + \
     'exec /ufs/guido/bin/sgi/python record.py"'
    pipe = posix.popen(cmd, 'r')
    config = al.newconfig()
    config.setchannels(AL.MONO)
    config.setqueuesize(QSIZE)
    port = al.openport('', 'w', config)
    while 1:
        data = pipe.read(BUFSIZE)
        if not data:
            sts = pipe.close()
            sys.stderr.write(sys.argv[0] + ': end of data\n')
            if sts: sys.stderr.write('rsh exit status ' + ` sts ` + '\n')
            sys.exit(1)
        port.writesamps(data)
        del data
Example #27
0
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.millisleep(100)
Example #28
0
#! /usr/bin/env python
Example #29
0
"""Classes for manipulating audio devices (currently only for Sun and SGI)"""
Example #30
0
#! /usr/bin/env python
Example #31
0
		videofile = videofile + '.video'

	print 'Opening video input file..'
	vin = VFile.VinFile(videofile)

	print 'Opening audio input file..'
	ain = aifc.open(audiofile, 'r')
	print 'rate    :', ain.getframerate()
	print 'channels:', ain.getnchannels()
	print 'frames  :', ain.getnframes()
	print 'width   :', ain.getsampwidth()
	print 'kbytes  :', \
		  ain.getnframes() * ain.getnchannels() * ain.getsampwidth()

	print 'Opening audio output port..'
	c = al.newconfig()
	c.setchannels(ain.getnchannels())
	c.setwidth(ain.getsampwidth())
	nullsample = '\0' * ain.getsampwidth()
	samples_per_second = ain.getnchannels() * ain.getframerate()
	if qsize <= 0: qsize = samples_per_second / 10
	qsize = max(qsize, 512)
	c.setqueuesize(qsize)
	saveparams = [AL.OUTPUT_RATE, 0]
	al.getparams(AL.DEFAULT_DEVICE, saveparams)
	newparams = [AL.OUTPUT_RATE, ain.getframerate()]
	al.setparams(AL.DEFAULT_DEVICE, newparams)
	aport = al.openport(audiofile, 'w', c)

	print 'Opening video output window..'
	gl.foreground()
Example #32
0
import aiff
Example #33
0
# Receive UDP packets from sendcd.py and play them on the speaker or
Example #34
0
def openspkr():
    conf = al.newconfig()
    conf.setqueuesize(BUFFERSIZE)
    conf.setwidth(AL.SAMPLE_16)
    conf.setchannels(AL.MONO)
    return al.openport('spkr', 'w', conf)
Example #35
0
# Compare different audio compression schemes.
Example #36
0
# Compare different audio compression schemes.
Example #37
0
#! /usr/bin/env python
# Play synchronous video and audio.
# Highly experimental!
import sys
import getopt
import string
import os
import VFile
import aifc
import gl, GL, DEVICE
import al, AL

def usage():
	sys.stderr.write( \
		'usage: aplay [-o offset] [-q qsize] videofile audiofile\n')
	sys.exit(2)
def main():
	offset = 0
	qsize = 0 # This defaults to 1/10 second of sound
	videofile = 'film.video'
	audiofile = 'film.aiff'
	try:
		opts, args = getopt.getopt(sys.argv[1:], 'o:q:')
	except getopt.error, msg:
		sys.stderr.write(msg + '\n')
		usage()
	try:
		for o, a in opts:
			if o == '-o':
				offset = string.atoi(a)
Example #38
0
# Play old style sound files (Guido's private format)
Example #39
0
"""Classes for manipulating audio devices (currently only for Sun and SGI)"""
Example #40
0
# Record mono 16bits samples from the audio device and send them to stdout.
Example #41
0
# intercom -- use mike and headset to *talk* to a person on another host.
Example #42
0
        videofile = videofile + '.video'

    print 'Opening video input file..'
    vin = VFile.VinFile(videofile)

    print 'Opening audio input file..'
    ain = aifc.open(audiofile, 'r')
    print 'rate    :', ain.getframerate()
    print 'channels:', ain.getnchannels()
    print 'frames  :', ain.getnframes()
    print 'width   :', ain.getsampwidth()
    print 'kbytes  :', \
       ain.getnframes() * ain.getnchannels() * ain.getsampwidth()

    print 'Opening audio output port..'
    c = al.newconfig()
    c.setchannels(ain.getnchannels())
    c.setwidth(ain.getsampwidth())
    nullsample = '\0' * ain.getsampwidth()
    samples_per_second = ain.getnchannels() * ain.getframerate()
    if qsize <= 0: qsize = samples_per_second / 10
    qsize = max(qsize, 512)
    c.setqueuesize(qsize)
    saveparams = [AL.OUTPUT_RATE, 0]
    al.getparams(AL.DEFAULT_DEVICE, saveparams)
    newparams = [AL.OUTPUT_RATE, ain.getframerate()]
    al.setparams(AL.DEFAULT_DEVICE, newparams)
    aport = al.openport(audiofile, 'w', c)

    print 'Opening video output window..'
    gl.foreground()
Example #43
0
#! /usr/bin/env python
Example #44
0
# Play old style sound files (Guido's private format)
Example #45
0
# Play CD audio on speaker or headphones.
Example #46
0
import aiff
Example #47
0
# Record mono 16bits samples from the audio device and send them to stdout.
Example #48
0
#! /usr/bin/env python
Example #49
0
#! /usr/bin/env python