Lee Phillips’ Website


Subscribe:   RSS icon   twitter icon

The Plucked String

Lee Phillips

Adjust the position of the pluck position using the slider, then pluck the string by clicking the pluck button.

 

There are ??? people plucking around with this.

What is this?

This is a demonstration of the effect of pluck position on the timbre of plucked string instruments. When you pluck the string of a guitar, banjo, harpsichord, harp, etc., you create an initial shape for the string that resembles a triangle: Initial condition for the plucked string. After you release the string, it vibrates freely with a spectrum of overtones determined by the shape of that initial triangle. In the model used here, the overtones form a harmonic series, whose initial spectrum is shown in the bar plot above. The plot shows the dominant part of the spectrum, the first 12 harmonics. Each frequency component decays at a rate that depends on frequency; higher frequencies die off faster. The evolution of the spectrum in time for the first five seconds is shown in the spectrogram immediately below the guitar, showing 30 harmonics. The tone quality is determined by the initial spectrum excited by the pluck position and the differential decay of the various frequency components.

The string is 1,000 mm long, so placing the pluck position, determined by the slider, all the way to the right (at 500 mm) will pluck the string at its midpoint.

If you’ve permitted autoplay you’ll also hear the first 2.5 seconds of the synthesized string sound. If (like me) you’ve disabled autoplay, just click on the audio player’s play button, overlapping the initial spectrum plot. If you’re using Firefox you won’t hear anything because of a long-standing bug in that browser.

Varying the position of the right hand along the strings (for a right-handed guitarist) is an important part of the technique of artistic expression on the classical guitar. The effect is exploited to some extent in all plucked instruments; for example, some harpsichords have different “stops” with plectra at different positions.

What’s left out?

Plenty! The modeling here captures the dominant effects of the pluck position on timbre. It does a pretty good job of this—to my ear this is a decent simulacrum of the sound of the nylon strings on a classical guitar.

The main factor left out is whatever makes a guitar sound different from a harp or harpsichord or, even more complexly, a banjo. This model just has a string. In real instruments the body and the string’s coupling to the body shape the spectrum further.

This model uses an exponential decay dependent on frequency. In reality the sound envelopes are more complex.

The stiffness of real strings causes their overtones to depart slightly from a harmonic series. Although amounting to just a few hundredths of a semitone, our ears are sensitive enough to this effect for it to make a difference.

How does this work?

The front end uses HTMX and its websocket extension to communicate with the server. This allowed me to just add a few tags to normal HTML to create the front end with no javascript. I did add a few scraps of plain javascript to keep the pluck position slider and the box that displays the numerical value of the position (which you can use to enter it as well) in sync.

The page communicates over a websocket with a Julia program running on a server. That program does the calculations, generates the plots and the sound, and sends them back for insertion in the page. No files are created. The part of the Julia program handling the communication amounts to just a few lines, calling functions from the HTTP.jl library. We don’t need any web frameworks or boilerplate. To get the code do
git clone https://lee-phillips.org/pluckit/code
I’ve no doubt it can be improved. If you have ideas, please send a patch or comment by email.

Websocket communication (secure and encrypted) goes through an Apache reverse proxy. The Julia program runs in a systemd-nspawn container.

I made another page using the same techniques that simulates the dynamics of a 2D system of fluid vortices.

Julia is the best programming language for science and engineering (and much else). It combines C-class performance with a powerful, high-level syntax. I wrote this book to teach people with little programming experience how to use Julia to attack problems in biology, statistics, physics, signal processing, and other fields.


Share with Facebook Share with Twitter Share with Reddit Share with Slashdot lee-phillips.org is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.
Quotilizer ... loading ...

Tenuously related: