audio_filtering.py 文件源码

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

项目:pyglitch 作者: giofusco 项目源码 文件源码
def flanger(X, max_time_delay=0.003, rate=1, Fs=44100, amp=0.7):
    I = X.copy()
    if pgc.num_channels(X) == 3:
        I = __flangerRGB(I, max_time_delay, rate, Fs, amp)
        return I
    else:
        x = pgc.to_1d_array(I)
        idx = np.arange(0, len(x))
        sin_ref = (np.sin(2 * math.pi * idx * (rate / Fs)))
        max_samp_delay = round(max_time_delay * Fs)
        y = np.zeros(len(x))
        y[1: max_samp_delay] = x[1: max_samp_delay]
        for i in prange(max_samp_delay+1, len(x)):
            cur_sin = np.abs(sin_ref[i])
            cur_delay = math.ceil(cur_sin * max_samp_delay)
            y[i] = (amp * x[i]) + amp * (x[i - cur_delay])
        I = np.reshape(y, I.shape)
    return I
    # return I.astype(np.uint8)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号