sample.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:synthesizer 作者: irmen 项目源码 文件源码
def normalize(self):
        """
        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.
        """
        assert not self.__locked
        self.resample(self.norm_samplerate)
        if self.samplewidth != self.norm_samplewidth:
            # Convert to 16 bit sample size.
            self.__frames = audioop.lin2lin(self.__frames, self.samplewidth, self.norm_samplewidth)
            self.__samplewidth = self.norm_samplewidth
        if self.nchannels == 1:
            # convert to stereo
            self.__frames = audioop.tostereo(self.__frames, self.samplewidth, 1, 1)
            self.__nchannels = 2
        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号