Connexions

You are here: Home » Content » Karplus-Strong Plucked String Algorithm
Content Actions
Lenses

What is a lens?

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

This content is ...
In these lenses
  • This module is included inLens: Digital Signal Processing with NI LabVIEW and the National Instruments Platform
    By: Sam ShearmanAs a part of collection:"Musical Signal Processing with LabVIEW (All Modules)"

    Comments:

    "This online course covers signal processing concepts using music and audio to keep the subject relevant and interesting. Written by Prof. Ed Doering from the Rose-Hulman Institute of Technology, […]"

    Click the "NI Signal Processing" link to see all content selected in this lens.

    NI Signal Processing
Tags

(?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

Karplus-Strong Plucked String Algorithm

Module by: Ed Doering

Summary: The Karplus-Strong algorithm plucked string algorithm produces remarkably realistic tones with modest computational effort. The algorithm requires a delay line and lowpass filter arranged in a closed loop, which can be implemented as a single digital filter. The filter is driven by a burst of white noise to initiate the sound of the plucked string. Learn about the Karplus-Strong algorithm and how to implement it as a LabVIEW "virtual musical instrument" (VMI) to be played from a MIDI file using "MIDI JamSession."

LabVIEWq.png This module refers to LabVIEW, a software development environment that features a graphical programming language. Please see the LabVIEW QuickStart Guide module for tutorials and documentation that will help you:
• Apply LabVIEW to Audio Signal Processing
• Get started with LabVIEW
• Obtain a fully-functional evaluation edition of LabVIEW

Introduction

In 1983 Kevin Karplus and Alex Strong published an algorithm to emulate the sound of a plucked string (see "References" section). The Karplus-Strong algorithm produces remarkably realistic tones with modest computational effort.
As an example, consider the sound of a violin's four strings plucked in succession: violin_plucked.wav (compare to the same four strings bowed instead of plucked: violin_bowed.wav). Now compare to the Karplus-Strong version of the same four pitches: ks_plucked.wav.
In this module, learn about the Karplus-Strong plucked string algorithm and how to create a LabVIEW virtual musical instrument (VMI) that you can "play" using a MIDI music file.

Karplus-Strong Algorithm

The Figure 1 screencast video develops the theory of the Karplus-Strong plucked string algorithm, which is based on a closed loop composed of a delay line and a low pass filter. As will be shown, the delay line is initialized with a noise burst, and the continuously circulating noise burst is filtered slightly on each pass through the loop. The output signal is therefore quasi-periodic with a wideband noise-like transient converging to a narrowband signal composed of only a few sinusoidal harmonic components.
sub_ks-theory.html
Figure 1: [video] Theory of the Karplus-Strong plucked string algorithm

LabVIEW Implementation

The Karplus-Strong algorithm block diagram may be viewed as a single digital filter that is excited by a noise pulse. For real-time implementation, the digital filter runs continuously with an input that is normally zero. The filter is "plucked" by applying a burst of white noise that is long enough to completely fill the delay line.
As an exercise, review the block diagram shown in Figure 1 and derive the difference equation that relates the overall output y(n) to the input x(n). Invest some effort in this so that you can develop a better understanding of the algorithm. Watch the video solution in Figure 2 only after you have completed your own derivation.
sub_ks-diffeqn.html
Figure 2: [video] Difference equation for Karplus-Strong block diagram
The Figure 3 screencast video shows how to implement the difference equation as a digital filter and how to create the noise pulse. The video includes an audio demonstration of the finished result.
sub_ks-build.html
Figure 3: [video] Building the Karplus-Strong block diagram in LabVIEW

Project Activity: Karplus-Strong VMI

In order to better appreciate the musical qualities of the Karplus-Strong plucked string algorithm, convert the algorithm to a virtual musical instrument (VMI for short) that can be played by "MIDI Jam Session." If necessary, visit MIDI Jam Session, download the application VI .zip file, and view the screencast video in that module to learn more about the application and how to create your own virtual musical instrument. Your VMI will accept parameters that specify frequency, amplitude, and duration of a single note, and will produce a corresponding array of audio samples using the Karplus-Strong algorithm described in the previous section.
For best results, select a MIDI music file that contains a solo instrument or perhaps a duet. For example, try "Sonata in A Minor for Cello and Bass Continuo" by Antonio Vivaldi. A MIDI version of the sonata is available at the Classical Guitar MIDI Archives, specifically Vivaldi_Sonata_Cello_Bass.mid.
Try experimenting with the critical parameters of your instrument, including sampling frequency and the low-pass filter constant g g MathType@MTEF@5@5@+=feaagaart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8srps0lbbf9q8WrFfeuY=Hhbbf9v8qqaqFr0xc9pk0xbba9q8WqFfea0=yr0RYxir=Jbba9q8aq0=yq=He9q8qqQ8frFve9Fve9Ff0dmeaabaqaciGacaGaaeqabaWaaeaaeaaakeaacaWGNbaaaa@3633@ . Regarding sampling frequency: lower sampling frequencies influence the sound in two distinct ways -- can you describe each of these two ways?

References

  • Moore, F.R., "Elements of Computer Music," Prentice-Hall, 1990, ISBN 0-13-252552-6.
  • Karplus, K., and A. Strong, "Digital Synthesis of Plucked String and Drum Timbres," Computer Music Journal 7(2): 43-55, 1983.

Comments, questions, feedback, criticisms?

Send feedback