Here's a nice web audio demo: https://chinpen.net/castro/ that uses this js lib: https://github.com/mrahtz/javascript-karplus-strong/
Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm
21–26 of 26 posts
Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm
#22Fascinating. I implemented a small proof of concept of Mathematica and it sounds remarkably well, especially for such an extremely simple idea. Maybe a small nitpick, but by using the filter described in this article (taking the average with the next sample), the frequency isn't exactly equal to sample rate / samples per buffer, as the filtering method is asymmetric, and it shifts the signal half a sample to the left…
ListPlay@ Flatten@ NestList[
0.996*#& /@ MovingAverage[# ~Join~ {First[#]}, 2]&,
RandomReal[1.0, {80}], 100]
https://i.imgur.com/aIufLHn.pngRe: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm
#23Fascinating. I implemented a small proof of concept of Mathematica and it sounds remarkably well, especially for such an extremely simple idea. Maybe a small nitpick, but by using the filter described in this article (taking the average with the next sample), the frequency isn't exactly equal to sample rate / samples per buffer, as the filtering method is asymmetric, and it shifts the signal half a sample to the left…
Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm
#24Fascinating. I implemented a small proof of concept of Mathematica and it sounds remarkably well, especially for such an extremely simple idea. Maybe a small nitpick, but by using the filter described in this article (taking the average with the next sample), the frequency isn't exactly equal to sample rate / samples per buffer, as the filtering method is asymmetric, and it shifts the signal half a sample to the left…
Interesting! I gave that a shot and definitely do hear the difference. I believe the difference you hear is due to the fact that it's a stronger low pass filter to average 3 samples instead of 2. In any case, the result is much less harsh on the ears. I'm adding that to the post, thanks!
Timbre is not the same as fundamental frequency. A guitar, a piano or a violin playing the same note, say, a middle C, will have wildly different timbres, but they should have the same fundamental frequency (261 Hz). That's what allows them to play together in orchestras. However, if you use, say 50 samples per buffer and a sample rate of 8192, with your original filter you won't get a frequency of 163.84 Hz, but 8192/49.5 = 165.49 Hz. That might look like a small difference, but to our ears it sounds wildly out of tune. You can use a tone analyzer app to verify it.
Thanks for the shout out :) I know I'm nitpicking :p
0: like for example, replacing with the average of the two surrounding values
Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm
#25You can play around with a lot of this stuff in the ChucK programming language[1]. ChucK was co-created by one of the early advocates for physical modeling sound synthesis, of which Karplus-Strong is an instance. A few examples are in [2] [3] and [4]. Disclosure: I am one of the current developers working on ChucK. [1] http://chuck.stanford.edu/ [2] http://chuck.stanford.edu/doc/examples/deep/plu.ck [3] http://chuck.…
Awesome work, I really love ChucK and participated in the mailing list at some point to work out how to embed ChucK into another app. Conclusion: it wasn't easy as the code has a lot of global static state but I had ChucK as the audio solution for a game I never finished.
Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm
#26Earlier quoted context omitted.
Interesting! I gave that a shot and definitely do hear the difference. I believe the difference you hear is due to the fact that it's a stronger low pass filter to average 3 samples instead of 2. In any case, the result is much less harsh on the ears. I'm adding that to the post, thanks!
Oh, changing the filter definitely changes the timbre, but that's not what I meant. Even with a symmetric filter using only two values[0], there will still be an audible difference. The point of using the symmetric filter wasn't to get a more correct timbre, but to avoid changing the fundamental frequency. Timbre is not the same as fundamental frequency. A guitar, a piano or a violin playing the same note, say, a mid…