mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			437 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			437 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
#
 | 
						|
# 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.millisleep(10)
 | 
						|
	print 'done.'
 | 
						|
	p.closeport()
 | 
						|
 | 
						|
while 1 :
 | 
						|
	playit (recordit ())
 |