过滤器可以用多种方式表示:
- 在复杂的平原上,您的示例 H(z) = (1+(1/z))/2
- 作为过滤器,
y[i] = h[0]*x[i] + h[1]*x[i-1] + h[2]*x[i-2] + ...
- 在频域中,Y[f] = H[f] * X[f]
其中第二个实际上是 h 和 x 数组的卷积。这也是最容易理解的。
上一个答案解释了从哪里开始构建过滤器。假设你有你的滤波器系数,h
那么它只是对非负数求和。
I believe I see what you are asking. Though you do not need more than one output. From the Wikipedia page the Karplus-Strong string synthesis algorithm needs a buffer of length L. If we have M filter coefficients (h
) that gives an output of the form,
y[i] = x[i] + h[0]*y[i-L] + h[1]*y[i-(L+1)] + h[2]*y[i-(L+2)] + ...
The Karplus-Strong synthesis from here uses a ring buffer to hold the last L outputs, y[i-1],...,y[i-L]
. This is initialised to be the x[i]
noise values for i<=L
; however, for i>L
x[i]=0
. The algorithm will be space efficient as you only store L values. The signal x[i]
for i>L
is just added to the ring buffer.
Finally, as a note of warning, if you are not careful with both the number of coefficients h
and the values the outputs y
may not have the desired behaviour.