本文整理匯總了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