sample.py 文件源码

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

项目:synthesizer 作者: irmen 项目源码 文件源码
def echo(self, length, amount, delay, decay):
        """
        Adds the given amount of echos into the end of the sample,
        using a given length of sample data (from the end of the sample).
        The decay is the factor with which each echo is decayed in volume (can be >1 to increase in volume instead).
        If you use a very short delay the echos blend into the sound and the effect is more like a reverb.
        """
        assert not self.__locked
        if amount > 0:
            length = max(0, self.duration - length)
            echo = self.copy()
            echo.__frames = self.__frames[self.frame_idx(length):]
            echo_amp = decay
            for _ in range(amount):
                if echo_amp < 1.0/(2**(8*self.__samplewidth-1)):
                    # avoid computing echos that you can't hear
                    break
                length += delay
                echo = echo.copy().amplify(echo_amp)
                self.mix_at(length, echo)
                echo_amp *= decay
        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号