1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# Test audioop.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import audioop
							 | 
						
					
						
							
								
									
										
										
										
											2002-07-23 19:04:11 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from test.test_support import verbose
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def gendata1():
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return '\0\1\2'
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def gendata2():
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('getsample')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.getsample('\0\1', 2, 0) == 1:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return '\0\0\0\1\0\2'
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return '\0\0\1\0\2\0'
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def gendata4():
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('getsample')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.getsample('\0\0\0\1', 4, 0) == 1:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return '\0\0\0\0\0\0\0\1\0\0\0\2'
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return '\0\0\0\0\1\0\0\0\2\0\0\0'
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testmax(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('max')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.max(data[0], 1) != 2 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.max(data[1], 2) != 2 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.max(data[2], 4) != 2:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1996-12-20 03:13:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def testminmax(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('minmax')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.minmax(data[0], 1) != (0, 2) or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.minmax(data[1], 2) != (0, 2) or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.minmax(data[2], 4) != (0, 2):
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1996-12-20 03:13:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testmaxpp(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('maxpp')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.maxpp(data[0], 1) != 0 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.maxpp(data[1], 2) != 0 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.maxpp(data[2], 4) != 0:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testavg(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('avg')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.avg(data[0], 1) != 1 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.avg(data[1], 2) != 1 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.avg(data[2], 4) != 1:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testavgpp(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('avgpp')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.avgpp(data[0], 1) != 0 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.avgpp(data[1], 2) != 0 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.avgpp(data[2], 4) != 0:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testrms(data):
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.rms(data[0], 1) != 1 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.rms(data[1], 2) != 1 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.rms(data[2], 4) != 1:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testcross(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('cross')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.cross(data[0], 1) != 0 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.cross(data[1], 2) != 0 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.cross(data[2], 4) != 0:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testadd(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('add')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    data2 = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for d in data:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        str = ''
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for s in d:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            str = str + chr(ord(s)*2)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        data2.append(str)
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.add(data[0], data[0], 1) != data2[0] or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.add(data[1], data[1], 2) != data2[1] or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.add(data[2], data[2], 4) != data2[2]:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testbias(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('bias')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Note: this test assumes that avg() works
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    d1 = audioop.bias(data[0], 1, 100)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    d2 = audioop.bias(data[1], 2, 100)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    d4 = audioop.bias(data[2], 4, 100)
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.avg(d1, 1) != 101 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.avg(d2, 2) != 101 or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.avg(d4, 4) != 101:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testlin2lin(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('lin2lin')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # too simple: we test only the size
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for d1 in data:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for d2 in data:
							 | 
						
					
						
							
								
									
										
										
										
											2001-09-04 19:14:14 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            got = len(d1)//3
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            wtd = len(d2)//3
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if len(audioop.lin2lin(d1, got, wtd)) != len(d2):
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testadpcm2lin(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Very cursory test
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.adpcm2lin('\0\0', 1, None) != ('\0\0\0\0', (0,0)):
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testlin2adpcm(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('lin2adpcm')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Very cursory test
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.lin2adpcm('\0\0\0\0', 1, None) != ('\0\0', (0,0)):
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2006-04-21 10:40:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def testlin2alaw(data):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('lin2alaw')
							 | 
						
					
						
							
								
									
										
										
										
											2006-04-21 10:40:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.lin2alaw(data[0], 1) != '\xd5\xc5\xf5' or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.lin2alaw(data[1], 2) != '\xd5\xd5\xd5' or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.lin2alaw(data[2], 4) != '\xd5\xd5\xd5':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testalaw2lin(data):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('alaw2lin')
							 | 
						
					
						
							
								
									
										
										
										
											2006-04-21 10:40:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Cursory
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    d = audioop.lin2alaw(data[0], 1)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if audioop.alaw2lin(d, 1) != data[0]:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testlin2ulaw(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('lin2ulaw')
							 | 
						
					
						
							
								
									
										
										
										
											2006-04-21 10:40:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.lin2ulaw(data[0], 1) != '\xff\xe7\xdb' or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.lin2ulaw(data[1], 2) != '\xff\xff\xff' or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.lin2ulaw(data[2], 4) != '\xff\xff\xff':
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testulaw2lin(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('ulaw2lin')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Cursory
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    d = audioop.lin2ulaw(data[0], 1)
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.ulaw2lin(d, 1) != data[0]:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testmul(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('mul')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    data2 = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for d in data:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        str = ''
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for s in d:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            str = str + chr(ord(s)*2)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        data2.append(str)
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.mul(data[0], 1, 2) != data2[0] or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.mul(data[1],2, 2) != data2[1] or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              audioop.mul(data[2], 4, 2) != data2[2]:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1997-02-14 15:58:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def testratecv(data):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('ratecv')
							 | 
						
					
						
							
								
									
										
										
										
											1997-05-21 14:27:20 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    state = None
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    d1, state = audioop.ratecv(data[0], 1, 1, 8000, 16000, state)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    d2, state = audioop.ratecv(data[0], 1, 1, 8000, 16000, state)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if d1 + d2 != '\000\000\001\001\002\001\000\000\001\001\002':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-02-14 15:58:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testreverse(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('reverse')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.reverse(data[0], 1) != '\2\1\0':
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testtomono(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('tomono')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    data2 = ''
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for d in data[0]:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        data2 = data2 + d + d
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.tomono(data2, 1, 0.5, 0.5) != data[0]:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testtostereo(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('tostereo')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    data2 = ''
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for d in data[0]:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        data2 = data2 + d + d
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.tostereo(data[0], 1, 1, 1) != data2:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testfindfactor(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('findfactor')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.findfactor(data[1], data[1]) != 1.0:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testfindfit(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('findfit')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.findfit(data[1], data[1]) != (0, 1.0):
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testfindmax(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('findmax')
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if audioop.findmax(data[1], 1) != 2:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testgetsample(data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if verbose:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('getsample')
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    for i in range(3):
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-12 23:11:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if audioop.getsample(data[0], 1, i) != i or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                  audioop.getsample(data[1], 2, i) != i or \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                  audioop.getsample(data[2], 4, i) != i:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            return 0
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return 1
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testone(name, data):
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        func = eval('test'+name)
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    except NameError:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('No test found for audioop.'+name+'()')
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        rv = func(data)
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    except 'xx':
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('Test FAILED for audioop.'+name+'() (with an exception)')
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if not rv:
							 | 
						
					
						
							
								
									
										
										
										
											2007-02-09 05:37:30 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print('Test FAILED for audioop.'+name+'()')
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def testall():
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    data = [gendata1(), gendata2(), gendata4()]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    names = dir(audioop)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # We know there is a routine 'add'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    routines = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for n in names:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if type(eval('audioop.'+n)) == type(audioop.add):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            routines.append(n)
							 | 
						
					
						
							
								
									
										
										
										
											1997-01-03 19:20:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    for n in routines:
							 | 
						
					
						
							
								
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        testone(n, data)
							 | 
						
					
						
							
								
									
										
										
										
											1994-01-12 09:55:11 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								testall()
							 |