Python audioop 模块,ulaw2lin() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用audioop.ulaw2lin()

项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_play_sound_file(self):
        path = findfile("audiotest.au")
        fp = open(path, 'r')
        size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
        data = fp.read()
        fp.close()

        if enc != SND_FORMAT_MULAW_8:
            self.fail("Expect .au file with 8-bit mu-law samples")

        # convert the data to 16-bit signed
        data = audioop.ulaw2lin(data, 2)

        # set the data format
        if sys.byteorder == 'little':
            fmt = linuxaudiodev.AFMT_S16_LE
        else:
            fmt = linuxaudiodev.AFMT_S16_BE

        # set parameters based on .au file headers
        self.dev.setparameters(rate, 16, nchannels, fmt)
        self.dev.write(data)
        self.dev.flush()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_play_sound_file(self):
        path = findfile("audiotest.au")
        fp = open(path, 'r')
        size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
        data = fp.read()
        fp.close()

        if enc != SND_FORMAT_MULAW_8:
            self.fail("Expect .au file with 8-bit mu-law samples")

        # convert the data to 16-bit signed
        data = audioop.ulaw2lin(data, 2)

        # set the data format
        if sys.byteorder == 'little':
            fmt = linuxaudiodev.AFMT_S16_LE
        else:
            fmt = linuxaudiodev.AFMT_S16_BE

        # set parameters based on .au file headers
        self.dev.setparameters(rate, 16, nchannels, fmt)
        self.dev.write(data)
        self.dev.flush()
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_play_sound_file(self):
        path = findfile("audiotest.au")
        fp = open(path, 'r')
        size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
        data = fp.read()
        fp.close()

        if enc != SND_FORMAT_MULAW_8:
            self.fail("Expect .au file with 8-bit mu-law samples")

        # convert the data to 16-bit signed
        data = audioop.ulaw2lin(data, 2)

        # set the data format
        if sys.byteorder == 'little':
            fmt = linuxaudiodev.AFMT_S16_LE
        else:
            fmt = linuxaudiodev.AFMT_S16_BE

        # set parameters based on .au file headers
        self.dev.setparameters(rate, 16, nchannels, fmt)
        self.dev.write(data)
        self.dev.flush()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_ulaw2lin(self):
        encoded = b'\x00\x0e\x28\x3f\x57\x6a\x76\x7c\x7e\x7f'\
                  b'\x80\x8e\xa8\xbf\xd7\xea\xf6\xfc\xfe\xff'
        src = [-8031, -4447, -1471, -495, -163, -53, -18, -6, -2, 0,
               8031, 4447, 1471, 495, 163, 53, 18, 6, 2, 0]
        for w in 1, 2, 3, 4:
            decoded = packs[w](*(x << (w * 8) >> 14 for x in src))
            self.assertEqual(audioop.ulaw2lin(encoded, w), decoded)
            self.assertEqual(audioop.ulaw2lin(bytearray(encoded), w), decoded)
            self.assertEqual(audioop.ulaw2lin(memoryview(encoded), w), decoded)

        # Current u-law implementation has two codes fo 0: 0x7f and 0xff.
        encoded = bytes(range(127)) + bytes(range(128, 256))
        for w in 2, 3, 4:
            decoded = audioop.ulaw2lin(encoded, w)
            self.assertEqual(audioop.lin2ulaw(decoded, w), encoded)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_play_sound_file(self):
        path = findfile("audiotest.au")
        fp = open(path, 'r')
        size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
        data = fp.read()
        fp.close()

        if enc != SND_FORMAT_MULAW_8:
            self.fail("Expect .au file with 8-bit mu-law samples")

        # convert the data to 16-bit signed
        data = audioop.ulaw2lin(data, 2)

        # set the data format
        if sys.byteorder == 'little':
            fmt = linuxaudiodev.AFMT_S16_LE
        else:
            fmt = linuxaudiodev.AFMT_S16_BE

        # set parameters based on .au file headers
        self.dev.setparameters(rate, 16, nchannels, fmt)
        self.dev.write(data)
        self.dev.flush()
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_ulaw2lin(self):
        encoded = b'\x00\x0e\x28\x3f\x57\x6a\x76\x7c\x7e\x7f'\
                  b'\x80\x8e\xa8\xbf\xd7\xea\xf6\xfc\xfe\xff'
        src = [-8031, -4447, -1471, -495, -163, -53, -18, -6, -2, 0,
               8031, 4447, 1471, 495, 163, 53, 18, 6, 2, 0]
        for w in 1, 2, 3, 4:
            decoded = packs[w](*(x << (w * 8) >> 14 for x in src))
            self.assertEqual(audioop.ulaw2lin(encoded, w), decoded)
            self.assertEqual(audioop.ulaw2lin(bytearray(encoded), w), decoded)
            self.assertEqual(audioop.ulaw2lin(memoryview(encoded), w), decoded)

        # Current u-law implementation has two codes fo 0: 0x7f and 0xff.
        encoded = bytes(range(127)) + bytes(range(128, 256))
        for w in 2, 3, 4:
            decoded = audioop.ulaw2lin(encoded, w)
            self.assertEqual(audioop.lin2ulaw(decoded, w), encoded)
项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:
                data = self._file.read()
            else:
                data = self._file.read(nframes * self._framesize * self._nchannels)
            if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
                import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet
项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
def setsampwidth(self, width):
        for (raw, cooked) in self.sampwidthlist:
            if width == raw:
                self.config.setwidth(cooked)
                self.inited_width = 1
                break
        else:
            if width == 0:
                import AL
                self.inited_width = 0
                self.config.setwidth(AL.SAMPLE_16)
                self.converter = self.ulaw2lin
            else:
                raise error, 'bad sample width'
项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
def ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:kinect-2-libras    作者:inessadl    | 项目源码 | 文件源码
def _ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:
                data = self._file.read()
            else:
                data = self._file.read(nframes * self._framesize)
            self._soundpos += len(data) // self._framesize
            if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
                import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def setsampwidth(self, width):
        for (raw, cooked) in self.sampwidthlist:
            if width == raw:
                self.config.setwidth(cooked)
                self.inited_width = 1
                break
        else:
            if width == 0:
                import AL
                self.inited_width = 0
                self.config.setwidth(AL.SAMPLE_16)
                self.converter = self.ulaw2lin
            else:
                raise error, 'bad sample width'
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def _ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:
                data = self._file.read()
            else:
                data = self._file.read(nframes * self._framesize * self._nchannels)
            if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
                import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_ulaw2lin(self):
        # Cursory
        d = audioop.lin2ulaw(data[0], 1)
        self.assertEqual(audioop.ulaw2lin(d, 1), data[0])
        if endian == 'big':
            self.assertEqual(audioop.ulaw2lin(d, 2),
                             b'\x00\x00\x01\x04\x02\x0c')
            self.assertEqual(audioop.ulaw2lin(d, 4),
                             b'\x00\x00\x00\x00\x01\x04\x00\x00\x02\x0c\x00\x00')
        else:
            self.assertEqual(audioop.ulaw2lin(d, 2),
                             b'\x00\x00\x04\x01\x0c\x02')
            self.assertEqual(audioop.ulaw2lin(d, 4),
                             b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x0c\x02')
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_wrongsize(self):
        data = b'abc'
        state = None
        for size in (-1, 3, 5):
            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)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def read_sound_file(path):
    with open(path, 'rb') as fp:
        au = sunau.open(fp)
        rate = au.getframerate()
        nchannels = au.getnchannels()
        encoding = au._encoding
        fp.seek(0)
        data = fp.read()

    if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
        raise RuntimeError("Expect .au file with 8-bit mu-law samples")

    # Convert the data to 16-bit signed.
    data = audioop.ulaw2lin(data, 2)
    return (data, rate, 16, nchannels)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def _ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:
                data = self._file.read()
            else:
                data = self._file.read(nframes * self._framesize)
            self._soundpos += len(data) // self._framesize
            if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
                import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_ulaw2lin(self):
        encoded = b'\x00\x0e\x28\x3f\x57\x6a\x76\x7c\x7e\x7f'\
                  b'\x80\x8e\xa8\xbf\xd7\xea\xf6\xfc\xfe\xff'
        src = [-8031, -4447, -1471, -495, -163, -53, -18, -6, -2, 0,
               8031, 4447, 1471, 495, 163, 53, 18, 6, 2, 0]
        for w in 1, 2, 4:
            self.assertEqual(audioop.ulaw2lin(encoded, w),
                             packs[w](*(x << (w * 8) >> 14 for x in src)))

        # Current u-law implementation has two codes fo 0: 0x7f and 0xff.
        encoded = ''.join(chr(x) for x in range(127) + range(128, 256))
        for w in 2, 4:
            decoded = audioop.ulaw2lin(encoded, w)
            self.assertEqual(audioop.lin2ulaw(decoded, w), encoded)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def setsampwidth(self, width):
        for (raw, cooked) in self.sampwidthlist:
            if width == raw:
                self.config.setwidth(cooked)
                self.inited_width = 1
                break
        else:
            if width == 0:
                import AL
                self.inited_width = 0
                self.config.setwidth(AL.SAMPLE_16)
                self.converter = self.ulaw2lin
            else:
                raise error, 'bad sample width'
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def _ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:
                data = self._file.read()
            else:
                data = self._file.read(nframes * self._framesize)
            self._soundpos += len(data) // self._framesize
            if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
                import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_ulaw2lin(self):
        encoded = b'\x00\x0e\x28\x3f\x57\x6a\x76\x7c\x7e\x7f'\
                  b'\x80\x8e\xa8\xbf\xd7\xea\xf6\xfc\xfe\xff'
        src = [-8031, -4447, -1471, -495, -163, -53, -18, -6, -2, 0,
               8031, 4447, 1471, 495, 163, 53, 18, 6, 2, 0]
        for w in 1, 2, 4:
            self.assertEqual(audioop.ulaw2lin(encoded, w),
                             packs[w](*(x << (w * 8) >> 14 for x in src)))

        # Current u-law implementation has two codes fo 0: 0x7f and 0xff.
        encoded = ''.join(chr(x) for x in range(127) + range(128, 256))
        for w in 2, 4:
            decoded = audioop.ulaw2lin(encoded, w)
            self.assertEqual(audioop.lin2ulaw(decoded, w), encoded)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def setsampwidth(self, width):
        for (raw, cooked) in self.sampwidthlist:
            if width == raw:
                self.config.setwidth(cooked)
                self.inited_width = 1
                break
        else:
            if width == 0:
                import AL
                self.inited_width = 0
                self.config.setwidth(AL.SAMPLE_16)
                self.converter = self.ulaw2lin
            else:
                raise error, 'bad sample width'
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def _ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:
                data = self._file.read()
            else:
                data = self._file.read(nframes * self._framesize)
            self._soundpos += len(data) // self._framesize
            if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
                import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def setsampwidth(self, width):
        for (raw, cooked) in self.sampwidthlist:
            if width == raw:
                self.config.setwidth(cooked)
                self.inited_width = 1
                break
        else:
            if width == 0:
                import AL
                self.inited_width = 0
                self.config.setwidth(AL.SAMPLE_16)
                self.converter = self.ulaw2lin
            else:
                raise error, 'bad sample width'
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def _ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_ulaw2lin(self):
        encoded = b'\x00\x0e\x28\x3f\x57\x6a\x76\x7c\x7e\x7f'\
                  b'\x80\x8e\xa8\xbf\xd7\xea\xf6\xfc\xfe\xff'
        src = [-8031, -4447, -1471, -495, -163, -53, -18, -6, -2, 0,
               8031, 4447, 1471, 495, 163, 53, 18, 6, 2, 0]
        for w in 1, 2, 4:
            self.assertEqual(audioop.ulaw2lin(encoded, w),
                             packs[w](*(x << (w * 8) >> 14 for x in src)))

        # Current u-law implementation has two codes fo 0: 0x7f and 0xff.
        encoded = bytes(range(127)) + bytes(range(128, 256))
        for w in 2, 4:
            decoded = audioop.ulaw2lin(encoded, w)
            self.assertEqual(audioop.lin2ulaw(decoded, w), encoded)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
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)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def read_sound_file(path):
    with open(path, 'rb') as fp:
        au = sunau.open(fp)
        rate = au.getframerate()
        nchannels = au.getnchannels()
        encoding = au._encoding
        fp.seek(0)
        data = fp.read()

    if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
        raise RuntimeError("Expect .au file with 8-bit mu-law samples")

    # Convert the data to 16-bit signed.
    data = audioop.ulaw2lin(data, 2)
    return (data, rate, 16, nchannels)
项目:WaveNet-Theano    作者:huyouare    | 项目源码 | 文件源码
def save_output(data, filename):
    # data is the u-law quantized sample
    u_law = data
    u_law = [chr(x) for x in u_law]
    u_law = ''.join(u_law)

    original = audioop.ulaw2lin(u_law, input_sample_width)
    print "output data size: " + str(len(original))

    output = wave.open(filename,'w')
    output.setparams((input_num_channels, input_sample_width, SAMPLE_RATE, 0, 'NONE', 'not compressed'))
    output.writeframes(original)
    output.close()
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_ulaw2lin(self):
        encoded = b'\x00\x0e\x28\x3f\x57\x6a\x76\x7c\x7e\x7f'\
                  b'\x80\x8e\xa8\xbf\xd7\xea\xf6\xfc\xfe\xff'
        src = [-8031, -4447, -1471, -495, -163, -53, -18, -6, -2, 0,
               8031, 4447, 1471, 495, 163, 53, 18, 6, 2, 0]
        for w in 1, 2, 4:
            self.assertEqual(audioop.ulaw2lin(encoded, w),
                             packs[w](*(x << (w * 8) >> 14 for x in src)))

        # Current u-law implementation has two codes fo 0: 0x7f and 0xff.
        encoded = ''.join(chr(x) for x in range(127) + range(128, 256))
        for w in 2, 4:
            decoded = audioop.ulaw2lin(encoded, w)
            self.assertEqual(audioop.lin2ulaw(decoded, w), encoded)
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
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)
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def read_sound_file(path):
    with open(path, 'rb') as fp:
        au = sunau.open(fp)
        rate = au.getframerate()
        nchannels = au.getnchannels()
        encoding = au._encoding
        fp.seek(0)
        data = fp.read()

    if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
        raise RuntimeError("Expect .au file with 8-bit mu-law samples")

    # Convert the data to 16-bit signed.
    data = audioop.ulaw2lin(data, 2)
    return (data, rate, 16, nchannels)
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def _ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:
                data = self._file.read()
            else:
                data = self._file.read(nframes * self._framesize)
            self._soundpos += len(data) // self._framesize
            if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
                import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
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)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def read_sound_file(path):
    with open(path, 'rb') as fp:
        au = sunau.open(fp)
        rate = au.getframerate()
        nchannels = au.getnchannels()
        encoding = au._encoding
        fp.seek(0)
        data = fp.read()

    if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
        raise RuntimeError("Expect .au file with 8-bit mu-law samples")

    # Convert the data to 16-bit signed.
    data = audioop.ulaw2lin(data, 2)
    return (data, rate, 16, nchannels)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def _ulaw2lin(self, data):
        import audioop
        return audioop.ulaw2lin(data, 2)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:
                data = self._file.read()
            else:
                data = self._file.read(nframes * self._framesize * self._nchannels)
            if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
                import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet