(max) karplus – strong plucked string algorithm

The Karplus-Strong synthesis algorithm is an early example of physical modeling synthesis. Physical models generally provide parameter controls that relate to real world changes. The Karplus-Strong algorithm uses noise fed into a feedback delay line, with lowpass filtering of the feedback, to produce plucked string textures. You can read about online at Music and Computers: A Theoretical and Historical Approach, Chapter 4 (Section 4.9). The site is an online textbook by Phil Burk, Larry Polansky, Douglas Repetto, Mary Roberts, and Dan Rockmore.

patcher

KarplusStrong.maxpat

implementation

For the pluck, the patcher uses either [noise~] or [rand~]. [rand~] will provide random noise up to the frequency specified in the argument (or message sent). Using [rand~] produces an excitation that is less chaotic, and hence, less bright in timbre of the pluck and resulting decay. The frequency message should be below the Nyquist Frequency (1/2 the sampling rate) to effect any noticeable change from using [noise~]. The pluck/excitation source is shaped by an [adsr~] envelope, with 1 ms attack, no initial decay, sustain amplitude of 1., and a 1 ms release. The [adsr~] object is sent the maxsustain 10 message at load, which means that it only needs to be triggered on. The object will move to its release section after 10 ms of sustain time without a zero-amplitude input.

The short burst of noise is sent directly out and also to a [tapin~]/[tapout~] pair. (Actually, two pairs, to represent two strings. More on that below.) To produce the pitch that corresponds to the MIDI note struck, you must convert MIDI-to-frequency, and then divide 1000 by that frequency to get the period of the frequency in milliseconds. Setting the delay time to the period of the frequency causes the delay line to resonate that frequency, and it’s harmonics.

The feedback amount in the delay line affects the decay time of the string, as does the lowpass filter. Experiment with these settings. Note that you cannot set the feedback amount to more than .999 to prevent an increasing feedback amplitude loop.

The second delay line has its time set by a multiplication factor to simulate a second string, such as you might find in a harpsichord or 12-string guitar. You can set the string to be detuned very slightly, or to be vibrating at some ratio to the fundamental.

limits

 

Note that if the frequency goes too high, or the delay time is too short, the output pitch from the delay line will hit a ceiling, or maximum point. This maximum point is determined by the signal vector size, in the Options > Audio Status window. The signal vector divided by the sampling rate gives the shortest time in seconds for the tapout value. You can set the signal vector to smaller values to obtain shorter delay times. The only drawback is increased processor demand, as you will notice your CPU percentage will increase as you lower the signal vector.

further modifications

The example shows you how to implement two strings. Neither string offers relative gain control, which you could add. You could also add some type of gain control to the portion of the noise that is sent directly to the output, to adjust the level of the pluck relative to the decay.

Change from noise~ to rand~, and then change frequency values to rand~ and listen to the changing sound. Try adjusting the lowpass cutoff frequency and the feedback amount to gain further control of the instrument.


Comments

Leave a Reply