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)
评论列表
文章目录