本文整理汇总了Python中audioop.alaw2lin方法的典型用法代码示例。如果您正苦于以下问题:Python audioop.alaw2lin方法的具体用法?Python audioop.alaw2lin怎么用?Python audioop.alaw2lin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类audioop
的用法示例。
在下文中一共展示了audioop.alaw2lin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_alaw2lin
# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import alaw2lin [as 别名]
def test_alaw2lin(self):
encoded = b'\x00\x03\x24\x2a\x51\x54\x55\x58\x6b\x71\x7f'\
b'\x80\x83\xa4\xaa\xd1\xd4\xd5\xd8\xeb\xf1\xff'
src = [-688, -720, -2240, -4032, -9, -3, -1, -27, -244, -82, -106,
688, 720, 2240, 4032, 9, 3, 1, 27, 244, 82, 106]
for w in 1, 2, 4:
self.assertEqual(audioop.alaw2lin(encoded, w),
packs[w](*(x << (w * 8) >> 13 for x in src)))
encoded = ''.join(chr(x) for x in xrange(256))
for w in 2, 4:
decoded = audioop.alaw2lin(encoded, w)
self.assertEqual(audioop.lin2alaw(decoded, w), encoded)
示例2: test_wrongsize
# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import alaw2lin [as 别名]
def test_wrongsize(self):
data = b'abcdefgh'
state = None
for size in (-1, 0, 3, 5, 1024):
self.assertRaises(audioop.error, audioop.ulaw2lin, data, size)
self.assertRaises(audioop.error, audioop.alaw2lin, data, size)
self.assertRaises(audioop.error, audioop.adpcm2lin, data, size, state)
示例3: _alaw2lin
# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import alaw2lin [as 别名]
def _alaw2lin(self, data):
import audioop
return audioop.alaw2lin(data, 2)
示例4: test_alaw2lin
# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import alaw2lin [as 别名]
def test_alaw2lin(self):
encoded = b'\x00\x03\x24\x2a\x51\x54\x55\x58\x6b\x71\x7f'\
b'\x80\x83\xa4\xaa\xd1\xd4\xd5\xd8\xeb\xf1\xff'
src = [-688, -720, -2240, -4032, -9, -3, -1, -27, -244, -82, -106,
688, 720, 2240, 4032, 9, 3, 1, 27, 244, 82, 106]
for w in 1, 2, 3, 4:
decoded = packs[w](*(x << (w * 8) >> 13 for x in src))
self.assertEqual(audioop.alaw2lin(encoded, w), decoded)
self.assertEqual(audioop.alaw2lin(bytearray(encoded), w), decoded)
self.assertEqual(audioop.alaw2lin(memoryview(encoded), w), decoded)
encoded = bytes(range(256))
for w in 2, 3, 4:
decoded = audioop.alaw2lin(encoded, w)
self.assertEqual(audioop.lin2alaw(decoded, w), encoded)
示例5: test_wrongsize
# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import alaw2lin [as 别名]
def test_wrongsize(self):
data = b'abcdefgh'
state = None
for size in (-1, 0, 5, 1024):
self.assertRaises(audioop.error, audioop.ulaw2lin, data, size)
self.assertRaises(audioop.error, audioop.alaw2lin, data, size)
self.assertRaises(audioop.error, audioop.adpcm2lin, data, size, state)
示例6: testalaw2lin
# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import alaw2lin [as 别名]
def testalaw2lin(data):
if verbose:
print 'alaw2lin'
# Cursory
d = audioop.lin2alaw(data[0], 1)
if audioop.alaw2lin(d, 1) != data[0]:
return 0
return 1