Electronic – Karplus Strong – getting a pluck of particular frequency

algorithmfrequencysignal processing

So I have been lately looking at a python implementation of Karplus Strong algorithm, or more particularly of the system:

\$ y[n] = \alpha y[n-M] + x[n] \$

From what I understand, \$ x[n] \$ is supposed to be a signal defined from 0..M-1 and 0 everywhere else.
Also \$ y[n] = 0 \forall n < 0 \$

Now if we start \$ x\$ with a random input noise of M samples, then we'll get back a signal of fundamental frequency M from the above system.

To simulate a guitar chord of say following notes: D4,A4,D4,E4…
One calculates the required frequencies as: \$ 440 \times 2^\frac{n}{12} \$ where n would be number of half tones between A4 and the required harmonic.

Now the sources I have referred to,
(for instance, http://www.cs.princeton.edu/courses/archive/spr08/cos126/assignments/guitar.html)
Calculate the M (the buffer/delay of system) as:

\$ M = \frac{F_s}{F_o} \$
where \$ F_s \$ is the sampling frequency, while \$ F_o \$ is the frequency of the signal I am interested in (say D4)

So for \$ F_s = 44100 Hz \$ and \$ F_o = 441 Hz \$ then \$ M = 100 \$

This calculation confused me. It seems like now I'll get a signal whose fundamental frequency is 100 Hz, when I needed a signal whose fundamental frequency was 441 Hz. So according to my understanding, shouldn't M be simply,
\$ M = F_o\$ which will then give my requried signal.

Thanks 😀

Best Answer

You are confusing normalized frequency with real frequency (Hz). Wikipedia Normalized Frequency.

The equation for the fundamental frequency (\$f_0\$) given number of delay units in the "string" (\$M\$) should be \$f_0=\frac{F_s}{M}\$, as the website states. Note that the Karplus Strong algorithm (formulated for a plucked string) is no more than a feedback comb filter initialized to a noise burst, which has frequency response: \$H(\omega)=\frac{1}{1-\alpha e^{-j \omega M }}\$, where \$\alpha\$ is the scaling factor from your original difference equation.

Here is the magnitude plot with \$\alpha=.5\$ and \$M = 10\$:

Wolfram Alpha Plot

Note that the peaks are at \$\omega = 0, \pi/5, 2\pi/5...\$ This implies the fundamental frequency is at \$\omega_0 = \pi/5\$, which corresponds to the "real" frequency of \$44100/10 = 4410\$ Hz (assuming 44100 samples / sec). Remember that the fifth harmonic in this case is \$\omega_5 =5\pi/5 = \pi\$. This corresponds to what we expect, the fifth harmonic is 22050 Hz, the highest frequency we can represent with a sample rate of 44100 samples / sec.

Think about what happens in the frequency domain: over time, the initialized noise burse (which looks fairly uniform in frequency) gets filtered by the peaked harmonic response of the filter, which produces the harmonics you expect for a plucked string.