Simulation of a guitar string
Description
guitarstring.py simulates a guitar string by treating it as a chain of alternating springs and mass points.
It takes the spring constant of the whole string, the mass of the whole string, the unstretched and stretched length of the string, the plucking position and several other arguments as input and plots the movement of the string over time and creates a wave file. The created tone sounds impressingly realistic.
The program, together with an spectrum analyzer(e.g. the tools of matplotlib and numpy), makes it possible to investigate how the plucking position affects the tone. It can be discovered that when you pluck at the middle of the string, the even overtones miss, and when you pluck at one third, every third overtone misses, and so on, because these overtones would have a node at that position and thus are not interested in what happens there.
guitarstring.py is free software and distributed under the terms of the GNU General Public License.
Sample sound files
Each 5 seconds, 865kB
- Plucking in the middle of the string (12th fret)
- Plucking at one third of the string
- Plucking at one fourth of the string (above the sound hole)
- Plucking at one 32th of the string (near the bridge)
As one can hear, the nearer to the bridge you pluck, the more overtones you get.
Screenshots
Requirements
- Python with
Download
FAQ
- The guitar string "explodes"
This happens if the time interval for simulation is to small so that the simulation gets imprecise. Increase the framerate or the steps per frame to avoid this.
- The wave file clanks
This is because of clipping. Decrease wave amplification.
Weblinks
- http://www.speech.kth.se/music/acviguit4/part4.pdf: Description of properties of guitar strings
- http://en.wikipedia.org/wiki/Vibrating_string
- http://en.wikipedia.org/wiki/Piano_key_frequencies: Helpful table of frequencies and notes