Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 2a9b0a93091b9ef7350a94bb3d3f1c43725b7a8c authored by Georg Brandl on 05 March 2011, 13:54:19 UTC
Close 2.0 branch.
Tip revision: 2a9b0a9
rec_play.py
#
# 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 ())
back to top