当前位置: 首页>>代码示例>>Python>>正文


Python audioop.tostereo方法代码示例

本文整理汇总了Python中audioop.tostereo方法的典型用法代码示例。如果您正苦于以下问题:Python audioop.tostereo方法的具体用法?Python audioop.tostereo怎么用?Python audioop.tostereo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在audioop的用法示例。


在下文中一共展示了audioop.tostereo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_issue7673

# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import tostereo [as 别名]
def test_issue7673(self):
        state = None
        for data, size in INVALID_DATA:
            size2 = size
            self.assertRaises(audioop.error, audioop.getsample, data, size, 0)
            self.assertRaises(audioop.error, audioop.max, data, size)
            self.assertRaises(audioop.error, audioop.minmax, data, size)
            self.assertRaises(audioop.error, audioop.avg, data, size)
            self.assertRaises(audioop.error, audioop.rms, data, size)
            self.assertRaises(audioop.error, audioop.avgpp, data, size)
            self.assertRaises(audioop.error, audioop.maxpp, data, size)
            self.assertRaises(audioop.error, audioop.cross, data, size)
            self.assertRaises(audioop.error, audioop.mul, data, size, 1.0)
            self.assertRaises(audioop.error, audioop.tomono, data, size, 0.5, 0.5)
            self.assertRaises(audioop.error, audioop.tostereo, data, size, 0.5, 0.5)
            self.assertRaises(audioop.error, audioop.add, data, data, size)
            self.assertRaises(audioop.error, audioop.bias, data, size, 0)
            self.assertRaises(audioop.error, audioop.reverse, data, size)
            self.assertRaises(audioop.error, audioop.lin2lin, data, size, size2)
            self.assertRaises(audioop.error, audioop.ratecv, data, size, 1, 1, 1, state)
            self.assertRaises(audioop.error, audioop.lin2ulaw, data, size)
            self.assertRaises(audioop.error, audioop.lin2alaw, data, size)
            self.assertRaises(audioop.error, audioop.lin2adpcm, data, size, state) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_audioop.py

示例2: test_string

# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import tostereo [as 别名]
def test_string(self):
        data = 'abcd'
        size = 2
        self.assertRaises(TypeError, audioop.getsample, data, size, 0)
        self.assertRaises(TypeError, audioop.max, data, size)
        self.assertRaises(TypeError, audioop.minmax, data, size)
        self.assertRaises(TypeError, audioop.avg, data, size)
        self.assertRaises(TypeError, audioop.rms, data, size)
        self.assertRaises(TypeError, audioop.avgpp, data, size)
        self.assertRaises(TypeError, audioop.maxpp, data, size)
        self.assertRaises(TypeError, audioop.cross, data, size)
        self.assertRaises(TypeError, audioop.mul, data, size, 1.0)
        self.assertRaises(TypeError, audioop.tomono, data, size, 0.5, 0.5)
        self.assertRaises(TypeError, audioop.tostereo, data, size, 0.5, 0.5)
        self.assertRaises(TypeError, audioop.add, data, data, size)
        self.assertRaises(TypeError, audioop.bias, data, size, 0)
        self.assertRaises(TypeError, audioop.reverse, data, size)
        self.assertRaises(TypeError, audioop.lin2lin, data, size, size)
        self.assertRaises(TypeError, audioop.ratecv, data, size, 1, 1, 1, None)
        self.assertRaises(TypeError, audioop.lin2ulaw, data, size)
        self.assertRaises(TypeError, audioop.lin2alaw, data, size)
        self.assertRaises(TypeError, audioop.lin2adpcm, data, size, None) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:test_audioop.py

示例3: normalize

# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import tostereo [as 别名]
def normalize(self) -> 'Sample':
        """
        Normalize the sample, meaning: convert it to the default samplerate, sample width and number of channels.
        When mixing samples, they should all have the same properties, and this method is ideal to make sure of that.
        """
        if self.__locked:
            raise RuntimeError("cannot modify a locked sample")
        self.resample(params.norm_samplerate)
        if self.samplewidth != params.norm_samplewidth:
            # Convert to desired sample size.
            self.__frames = audioop.lin2lin(self.__frames, self.samplewidth, params.norm_samplewidth)
            self.__samplewidth = params.norm_samplewidth
        if params.norm_nchannels not in (1, 2):
            raise ValueError("norm_nchannels has invalid value, can only be 1 or 2")
        if self.nchannels == 1 and params.norm_nchannels == 2:
            # convert to stereo
            self.__frames = audioop.tostereo(self.__frames, self.samplewidth, 1, 1)
            self.__nchannels = 2
        elif self.nchannels == 2 and params.norm_nchannels == 1:
            # convert to mono
            self.__frames = audioop.tomono(self.__frames, self.__samplewidth, 1, 1)
            self.__nchannels = 1
        return self 
开发者ID:irmen,项目名称:synthesizer,代码行数:25,代码来源:sample.py

示例4: stereo

# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import tostereo [as 别名]
def stereo(self, left_factor: float = 1.0, right_factor: float = 1.0) -> 'Sample':
        """
        Turn a mono sample into a stereo one with given factors/amplitudes for left and right channels.
        Note that it is a fast but simplistic conversion; the waveform in both channels is identical
        so you may suffer from phase cancellation when playing the resulting stereo sample.
        If the sample is already stereo, the left/right channel separation is changed instead.
        """
        if self.__locked:
            raise RuntimeError("cannot modify a locked sample")
        if self.__nchannels == 2:
            # first split the left and right channels and then remix them
            right = self.copy().right()
            self.left().amplify(left_factor)
            return self.stereo_mix(right, 'R', right_factor)
        if self.__nchannels == 1:
            self.__frames = audioop.tostereo(self.__frames, self.__samplewidth, left_factor, right_factor)
            self.__nchannels = 2
            return self
        raise ValueError("sample must be mono or stereo") 
开发者ID:irmen,项目名称:synthesizer,代码行数:21,代码来源:sample.py

示例5: test_tostereo

# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import tostereo [as 别名]
def test_tostereo(self):
        for w in 1, 2, 4:
            data1 = datas[w]
            data2 = bytearray(2 * len(data1))
            for k in range(w):
                data2[k::2*w] = data1[k::w]
            self.assertEqual(audioop.tostereo(data1, w, 1, 0), data2)
            self.assertEqual(audioop.tostereo(data1, w, 0, 0), b'\0' * len(data2))
            for k in range(w):
                data2[k+w::2*w] = data1[k::w]
            self.assertEqual(audioop.tostereo(data1, w, 1, 1), data2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_audioop.py

示例6: test_tostereo

# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import tostereo [as 别名]
def test_tostereo(self):
        for w in 1, 2, 3, 4:
            data1 = datas[w]
            data2 = bytearray(2 * len(data1))
            for k in range(w):
                data2[k::2*w] = data1[k::w]
            self.assertEqual(audioop.tostereo(data1, w, 1, 0), data2)
            self.assertEqual(audioop.tostereo(data1, w, 0, 0), b'\0' * len(data2))
            for k in range(w):
                data2[k+w::2*w] = data1[k::w]
            self.assertEqual(audioop.tostereo(data1, w, 1, 1), data2)
            self.assertEqual(audioop.tostereo(bytearray(data1), w, 1, 1), data2)
            self.assertEqual(audioop.tostereo(memoryview(data1), w, 1, 1),
                             data2) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:test_audioop.py

示例7: testtostereo

# 需要导入模块: import audioop [as 别名]
# 或者: from audioop import tostereo [as 别名]
def testtostereo(data):
    if verbose:
        print 'tostereo'
    data2 = ''
    for d in data[0]:
        data2 = data2 + d + d
    if audioop.tostereo(data[0], 1, 1, 1) != data2:
        return 0
    return 1 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_audioop.py


注:本文中的audioop.tostereo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。