Live data from Hacker News

Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm

blog.demofox.org

11–20 of 26 posts

Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm

#11

Looks like the virtual "string" is shaped as a random string, and then suddenly let go to make that sound. I wonder what would happen if you shaped the original buffer with a certain shape--for instance a linear rampup then a linear rampdown at some point, much like how you would stretch a string. edit: hacked together a string plucking thing here: https://www.shadertoy.com/view/ldVSzd modify the coefficient inside p…

Nice! Another "trick" is to take the buffer with the impulse response of the body of the instrument you are modeling, e.g. a piano soundboard or violin body, and filter the excitation (noise, or ramp, etc.) before putting it in the buffer. You can hear this so-called commuted synthesis[1] being used here [2]-- not exactly Stradivarius but kinda sounds like a screechy violin.

[1] https://ccrma.stanford.edu/~jos/pasp/Commuted_Synthesis.html

[2] https://youtu.be/U8wjFmLQJT4?t=21s

Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm

#12
post #9

Here's an editable demo written in JS (just hit "preview"): http://tinyrave.com/tracks/67/remix

Sounds way better than the original author's demo! Original author's demo: https://www.shadertoy.com/view/MdyXRd

The shadertoy was an attempt at doing the algorithm without a delay buffer (making it stateless). The real demo is the wav file and the C++ that generated the wav file (:

Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm

#13
You 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.stanford.edu/doc/examples/deep/plu2.ck

[3] http://chuck.stanford.edu/doc/examples/deep/plu3.ck

Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm

#15

Looks like the virtual "string" is shaped as a random string, and then suddenly let go to make that sound. I wonder what would happen if you shaped the original buffer with a certain shape--for instance a linear rampup then a linear rampdown at some point, much like how you would stretch a string. edit: hacked together a string plucking thing here: https://www.shadertoy.com/view/ldVSzd modify the coefficient inside p…

Nice! Another "trick" is to take the buffer with the impulse response of the body of the instrument you are modeling, e.g. a piano soundboard or violin body, and filter the excitation (noise, or ramp, etc.) before putting it in the buffer. You can hear this so-called commuted synthesis[1] being used here [2]-- not exactly Stradivarius but kinda sounds like a screechy violin. [1] https://ccrma.stanford.edu/~jos/pasp/C…

Accidental downvote, sorry. Thanks for sharing those links!

Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm

#16

You 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

#18
I have implemented (with a group of two other people) a slightly fancier version of something like this at school, for an exercise at DSP implementation course.

The basic principle was really the same with the circular buffer and a filter, the combo of which can be understood as a long IIR filter. The fancier parts included tunable harmonic bandpass filter (in place of OP's two sample average), and a fractional delay filter for fine-tuning.

By changing the parameters on the bandpass filter it could be made to sound anything from a plucked string to a church bell (minus the reverb since we didn't have that). We were quite surprised how good it sounded.

Unfortunately I seem to have misplaced all the materials related to that course. The hardware we implemented it for was some exotic audio DSP, but we had a matlab model that could produce output samples. If only I could find it.. =/

Re: Synthesizing a Plucked String Sound with the Karplus-Strong Algorithm

#19
Fascinating. 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 every pass. With a more symmetric method, like replacing each value by the average of the surrounding values, that doesn't happen. It may sound pedantic, but the difference is quite clear audible

Post reply on HN