# How To Simulate Guitar Sounds?

# Derivation of 1D wave equation

Hi, my friend! Have you ever seen how a guitar string viberate? I mean have you ever look closely after you plunking a string? I want to simulate the motion of a guitar string on my computer. I will show you how to do this from scratch using Python. The first thing first we need to do is to analysis a small piece on the string. Let look at this figure.

# Wave function

The motion of an ideal string can be discribed by a 1D wave equation(In this case the fraction between the string and the air is not considered),

2ut2=Tμ2ux2\frac{\partial^{2} u}{\partial t^{2}}=\frac{T}{\mu} \frac{\partial^{2} u}{\partial x^{2}}

Where, u=u(t,x)u=u(t,x) is the displacement of the the string at position xx, at the time, tt; TT is the tensile force; μ\mu is the linear density (mass per length). [1]

# String tension

String tension is a function of three aspects: string gauge, scale length, and pitch. String gauge refers to the thickness of the strings. Scale length is a measurement of the distance of a vibrating string on a given instrument—usually this means it’s measured from the nut to where the string contacts the bridge or tailpiece. Pitch refers to the note/sound the string is tuned to (or intended to be tuned to). [3]

Some parameters, such as string tension, of a set of classical guitar strings (J4501-J4506) [4]

For a guitar string, the string tension in newton is given by

T=4mLf2=μ(2Lf)2T = 4mLf^2 = \mu (2Lf)^2

where mm is its mass in kilogram, LL is the length in meter, and ff the lowest vibration frequency of the string in hertz which determines the pitch. [5]

# Solve PDE

Fingerboard Legends for Pitch and Frequency at Standard Tuning [6]

I am going to simulate the third string, which has the frequency of 196 Hz. The tension 5.39 Kg given by the the manufacturer is converter to 52.85785 newtons by multiplying the gravititional acceleration gg.

T=5.39kg×9.80665m/s2=52.8578435kgm/s2=52.85784NT = 5.39 \text{kg} \times 9.80665 \text{m}/\text{s}^2 = 52.8578435 \text{kg}\cdot \text{m}/\text{s}^2 = 52.85784 \text{N}

The unit weight (UW) of the third string J4503/EXP given is 0.00004679 pounds per linear inch (lb/in). Hence, the linear density μ\mu can be obtained.

μ=0.00004679lbin=0.000046790.45359237kg0.0254m=0.00083557kg/m\mu = 0.00004679 \frac{\text{lb}}{\text{in}} = 0.00004679 \frac{0.45359237 \text{kg}}{0.0254 \text{m}} = 0.00083557 \text{kg/m}

To slove the partial differential equation, we need to give the initial conditions.

The initial state of the third string is described as the dash lines.

The initio state of the string can be described as these equations.

u(0,x)=118x,x[0,0.18],u(0, x) = - \frac{1}{18} x, x \in [0, 0.18] ,

u(0,x)=147x0.01383,x(0.18,0.65],u(0, x) = \frac{1}{47} x - 0.01383, x \in (0.18, 0.65],

utt=0=0,\left. \frac{\partial u}{\partial t} \right|{t=0} = 0 ,


2ut2=Tμ2ux2\frac{\partial^{2} u}{\partial t^{2}}=\frac{T}{\mu} \frac{\partial^{2} u}{\partial x^{2}}

I use Euler's method to solve the equation numerically. First choose stepsizes Δt\Delta t and Δx\Delta x, and set t=0t=0 and x=0x=0.

What is the stable condition of this equation?

What is the constraint ?

[1] Composing molecular music with carbon, MRS Communications, 2015, doi: 10.1557/mrc.2015.9
[2] Youtube, Martin Shuppius - Physical modelling of guitar strings (ADC'17) (opens new window)
[3] Daddario, All about string tension (opens new window)
[4] Daddario, Ej45-Pro-Arte-Nylon-Normal-Tension (opens new window)
[5] Measuring String Tension, July 2006, Rod Cross, Physics Department, University of Sydney, Sydney, Australia (opens new window)
[6] A complete technical reference for fretted instrument string tensions (opens new window)
[7] Youtube: I Generated Guitar Audio in python using NUMBA, Mr.P Solver (opens new window)