Skip to content

Uses the wave equation and Fourier transforms to simulate plucked guitar strings and their sound frequency in a Jupyter Notebook..

Notifications You must be signed in to change notification settings

nick-cirillo/string-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guitar String Simulator

guitar

Simulating guitar strings has a myriad of possible applications, including virtual instrument design that increases accessibility of guitar composing to those who don't play, faster prototyping of novel guitars for luthiers, and preservation of famous or unique instruments' sounds.

My guitar string simulation, written using Python (primarily the numpy and matplotlib libraries) in a Jupyter Notebook, uses the wave equation to simulate plucked guitar strings and analyzes the resulting time-evolution using a Fourier transform.

The focus of my project was to simulate the open strings of a guitar (meaning no notes are fretted), specifically, to use initial conditions that reflected a pluck over the pickups or sound hole of the guitar rather than the center of the string. This took the form of a triangular approximation that represents how the string is stretched from rest by the player's pick or finger.

triangular-approximation

You'll notice the axes differ in units. That's to exaggerate the silhouette of the string, as players only pick the string a few fractions of a centimeter away from rest.


I used the known frequencies of vibrations of guitar strings tuned to E-standard (EADGBE) and a common scale length (25.5") to find the wave speed of each string. Using these quantities, I performed the Verlet method of calculating the wave equation (a linear differential equation that accurately simulates string vibrations). I created several animations of the resulting time evolution.

simulation-not-to-scale

Here's a simulation of the string vibration. It's slowed and not to scale to exaggerate the motion. Notice the interesting movement as the vibration reflects off the nut of the guitar (where the strings anchor at the top of the fretboard).


simulation-to-scale

And here's a simulation with the y-axis closer to scale. Notice how subtle the motion is - this is a lot closer to how guitar strings look as they vibrate!


Next, I used a discrete Fourier transform to analyze the frequencies in the time evolution.

After completing the simulations, I looked to verify my methods against the known data. Research by Dan Russell from Penn State in 2012 shows that my animations are indeed accurate simulations of string vibrations.

In fact, these simulations went even further, and showed the decomposition of the wave into the standing waves of the string, created by harmonics. Musically, a harmonic is a note played exactly one or more octaves above the same note in a lower register.

sum-motion

My simulations were accurate, and reflected the hidden sum of standing waves generated by the guitar strings' harmonics. Credit to Dan Russell for this animation that confirms my findings.


If I return to this project, I'd like to enable user input that allows choice of string and fret. I'd also like to analyze the frequency of the resulting vibration and output this frequency from the computer, essentially creating a wholly simulated virtual instrument.

About

Uses the wave equation and Fourier transforms to simulate plucked guitar strings and their sound frequency in a Jupyter Notebook..

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published