Exploring Pythagoras Music Theory using Python
- Annauen Ravacio
- Jan 22
- 1 min read
Concept of Octave Higher
First Harmonic and Second Harmonic Frequencies
Do you wonder how to generate a code that can simulate the Open D string, its first harmonic, and second harmonic?

Here is the ChatGPT-generated Python script. Please feel free to run the script in your myenv environment. Please do not forget to install the numpy and sounddevice libraries.
pip install numpy sounddevice
Tech-awesome: The output of the Python script is the sound of each frequency. We would be able to hear how the Open D string, First Harmonic, and Second Harmonic sound like on the guitar.
Music Theory of Pythagoras:
Distances between notes in a piece of music that sounds good should always be whole numbers. Example:
First Harmonic: Half the length of the open D string shall produce double (2x) the frequency of the open D string.
Second Harmonic: One-third the length of the open D string shall produce triple (3x) the frequency of the open D string.
Observe: Please look at the snippet and divide the first harmonic Hz by the open D string Hz. What is the quotient? Is it a whole number? Do the same for the Second Harmonic.
Divide the second harmonic Hz by the open D string Hz. What is the quotient? Is it also a whole number?
What are your findings and conclusion?
Comments