# Math for Harmony: Harmonic Frequencies and Amplitudes

• Nov 2, 2020 - 13:28

I decided to investigate the result of two simultaneous frequencies. I’m using Audacity (computer program spectrum analyzer) that converts sound into the frequency domain.

Many years ago I heard about this simple trig for music =>
sin(a) * sin(b) = 1/2 cos(a - b) - 1/2 cos(a + b).
sin(550)* sin(330) = ½ cos(550 - 330) - ½ cos(550 + 330)
sin(550)* sin(330) = ½ cos(220) - ½ cos(880)

This means that producing an "E" and a "C#" simultaneously results in an "A" down one octave and an "A" up one octave - at half the volume.

Analyzing with Audacity, this equation is an “invalid” application for two simultaneously frequencies (ignore my other posts with this equation).

`````````````
The following sequence was used to analyze further. The sine waves are 440 Hz and 450 Hz with zero harmonics. Audacity was set for a project rate of 8000 Hz and a Spectrum size of 65536 with a Hann Window.

The x-axis is the frequency. The y-axis is the percentage of maximum volume.

This is 440 Hz:

This is 450 Hz:

This is 440 Hz and 450 Hz played simultaneously:

There are many harmonics from only two frequencies. The peak harmonic amplitudes are spaced 10 Hz => 410 Hz, 420 Hz, 430 Hz, etc. (This makes some sense as 450 Hz – 440 Hz = 10 Hz.)

Zooming in on the 0 Hz to 100 Hz range (450 Hz - 440 Hz = 10 Hz):

the largest peak is at 75 Hz. The amplitudes are “less than 0.5%”. The peak harmonic amplitudes are spaced 10 Hz. Wondering why the largest amplitude is at 75 Hz?

Zooming in on the 800 Hz to 900 Hz range (450 Hz + 440 Hz = 890 Hz):

the largest peak is at 815 Hz. The amplitudes are “less than 0.5%”. The peak harmonic amplitudes are spaced 10 Hz. Wondering why the largest amplitude is at 815 Hz?

What trigonometry equations create harmony: harmonic frequencies and amplitudes?

#### Comments

Why would you consider two sine waves to be played simultaneously to equal the product of those waves instead of the sum?

Try this:

1. Start a new project in Audacity
2. Add a new mono track
3. Choose "Generate → Tone...". Pick "Sine" as the Waveform, set 440Hz as frequency and amplitude at 0.4 with a duration of your choosing (for example 1s)
4. Add another track, and redo step 3, but now for 450Hz
5. Ctrl-A to select both tracks
6. Tracks → Mix → Mix and render to new track

Have fun looking at the spectrum analysis of all three tracks.

In reply to by jeetee

Hi jeetee!

As mentioned in my original post, the assumption that it is a "product" is an error. It is a "sum". I heard it was a "product" many years ago, and never took the time to verify.

I am creating a pure sine wave (using a C# software program I wrote). When I generate 440 Hz, Audacity confirms it is 440 Hz. Ditto for 450 Hz.

When I generate both simultaneously, Audacity captures the sound of both frequencies, and displays the results.

Commonly mixing allows modifying and tweaking each track. There is no reason to mix. I need pure sine wave sounds.

The results of all three tracks is in my original post.

To verify, set MuseScore to play an "A" and an "A#" simultaneously. You will hear more than the A" and "A#".

BTW - I understand harmonics. I spent my career as an electronic design engineer. The only difference now is that it can be done with software instead of equipment! :-)

In reply to by bhs67

Ciao.
I think the misunderstanding is in how exactly you "generate them simultaneously", as you say in your posts.
Do you sum the two sine waves? Do you multiply them?

Concerning playing A and A# simultaneously, what you hear is called a "beat": https://en.wikipedia.org/wiki/Beat_(acoustics)
It is just an interference pattern: the sum of two sine waves with close frequencies can be interpreted as a sine wave with average frequency modulated in amplitude by a low-frequency (=the difference between the two freq.) sine wave.
But in the case of a beat a spectral analysis gives only two frequencies, i.e. only the ones you are starting from.
In the case of a product, as you correctly show, you will obtain only two frequencies (it is some sort of viewing the beat formula "backwards").
In order to "gain" additional frequencies, the method you are using to "mix" the initial frequencies or the method you are using to record the composite signal must be non-linear (for example https://en.wikipedia.org/wiki/Musical_acoustics#Harmonics_and_non-linea… ).
You can have a look here for an interesting phenomenon: https://en.wikipedia.org/wiki/Combination_tone

In reply to by ABL

Hi Ciao!

After thinking more about harmonics - frequencies that are the result of two different frequencies played simultaneously are not really harmonics. Some people call them beats, but they don't sound like beats when they are at higher frequencies.

I've called them harmonics, but perhaps I should call them Combination Tones.

===========
For a frequency generated by a computer => https://docs.microsoft.com/en-us/archive/blogs/dawate/intro-to-audio-pr… --- http://soundfile.sapp.org/doc/WaveFormat/.

To create two frequencies, create an array of one frequency => divide every number by 2 (two frequencies) --- ditto for the second frequency --- add them together and send that array to MemoryStream. The sample rate is 352,800 (44,100 * 8).

===========
Using MuseScore, "A" and "A#" does sound like a beat. However, a spectral analysis shows that there are other frequencies at a much lower volume (less than 25%). As you spread the two frequencies, the "beat" speed increases.

===========
I looked at the Microsoft canned software. As it is not flexible enough, I created my own software.

===========
Here are two frequencies and the sum of those two frequencies:
+ =

Here a third frequency is added and the sum of all three.
=>

Adding frequencies is not complicated. Converting to a frequency spectrum commonly uses FFT.

Note that this example did not scale the results to have a peak of 1 - I wanted to provide an accurate perspective.

===========
The Wikipedia comments are unusual. Take two function generators (equipment) to generate two frequencies. Connect them to a spectrum analyzer (equipment). You will see more than two frequencies. These are actual frequencies, not perceptions.

In reply to by bhs67

Yes, but Fourier transform is linear, so if you sum two or more terms at (pure) different frequencies, you will see only those frequencies in the analysis of the result. This from a mathematical point of view.
Then you have to consider that when you perform a numerical analysis you are clipping the sine wave, which would have infinite extent. The FFT uses periodic boundary conditions, i.e. it assumes that the function repeats equal to itself outside the interval. So, if you are considering a time interval which is an exact multiple of the sine period (1 period = 1 full oscillation) you will see only its frequency (actually, two peaks, symmetric with respect to the center, since also the frequency function in the FFT is periodic). But if the time interval is not an exact multiple of that period, you are artificially introducing other frequency components.
See for example:
https://dsp.stackexchange.com/a/8606

I don't know how (hardware) function generators work internally, but if the output signal is just a sum of sinusoidal signal, then only their frequencies are present (if you rule out the spurious effects due to signal sampling and trimming).

In reply to by bhs67

I need to attempt to reconstruct my Trig knowledge - it's been a few years. Is this correct?

sin(a) + sin(b) = 2 * sin(½ * (a + b)) * cos(½ * (a - b))
sin(450) + sin(440) = 2 * sin(½ * (450 + 440)) * cos(½ * (450 – 440))
sin(450) + sin(440) = 2 * sin (½ * (890)) * cos(½ * (10))
sin(450) + sin(440) = 2 * sin(445) * cos (5)

In reply to by bhs67

sin(440) = sin(440 + k*2PI)
With k being any whole number.

This doesn't mean that a pure sine wave of 440Hz (for which the formula would strictly speaking be "`y(t) = sin(2*PI*440*t)`") suddenly produces an equal wave of 880 or 1760 Hz...

In reply to by bhs67

> This indicates 5 Hz and 445 Hz results from 440 Hz and 450 Hz?

No. The spectral content is still 440 Hz and 450 Hz, i.e. if you anaylze the frequency content you will see only those two frequencies (always provided that there are no numerical artifacts, as explained in the links of the posts above). The formula means that the superposition of these frequencies can be interpreted as a signal at 445 Hz modulated in amplitude (i.e. how "forte" or "piano" is the sound) by a sinusoidal function with frequency 5 Hz. It is the effect of "beats", i.e. the "wah - ooh - wah -ooh" effect you hear in the final signal.
But, as said before, the spectral content is only 440 Hz and 450 Hz.

By the way, every function can be derived as a discrete (if it is periodic) or continuous (if non-periodic) sum of (in general) an infinite number of sinusoidal functions. See https://en.wikipedia.org/wiki/Fourier_series (for periodic functions) and in general https://en.wikipedia.org/wiki/Fourier_transform

You can read this about Fourier transform: https://betterexplained.com/articles/an-interactive-guide-to-the-fourie…

In reply to by bhs67

>This indicates 5 Hz and 445 Hz results from 440 Hz and 450 Hz?

The opposite parts of the frequencies 440 and 450 (eg: -1 vs +1 and +1 vs -1) cancel each other out, while the equal parts (eg: +1 vs +1 and -1 vs -1) increase each other.
The remaining part is the two frequencies vibrating/tremulant at 10 Hz/sec, which is their difference.

Notice: If you are going to test this (and similar) two frequency combination(s): make sure the starting frequencies are -6dB or less, otherwise the combined frequency will overflow. In case of overflow, you can get unwanted combinations of frequencies such as square-wave, sawtooth, and triangle-waves, and many more harmonics. This can lead you to the wrong conclusions.

In reply to by Ziya Mete Demircan

It's a bit embarrassing to have had my perception wrong for many years. I was told the wrong thing more than 40 years ago. I never took the time to verify. I understand everything now that it has been explained in this sequence of posts. Thanks to jeetee, Ciao. ABL, and Ziya Mete Demircan.

The wrong information was a precursor to overtones (sum and difference frequencies).

Thinking more about overtones, it appears that when multiple singers sing Pure Tone notes (a cappella), it results in overtones. Overtones appear to be the result of multiple singers perfectly matching harmonic frequencies, which amplifies the higher frequencies.

I'm interested in your knowledge about overtones!

What you are seeing there are not harmonics but distortion products due to nonlinearity or to the fact that the numerical sample values are quantized (e.g., to the nearest integer). Actually the distortion case - 440 and 450 Hz giving rise to 430 and 460 - has been known to musicians for centuries under the name "combination tone" - if you play the upper two notes of a major triad, the distortion in the ear itself will fill in the missing lower note. (The upper combination tone is not heard because it is generated at a point in the ear where it is above the local cutoff frequency.)

Using Audacity and a pair of headphones you could generate a stereo signal of 800 Hz to the left ear and 900 Hz to the right ear; you will hear a certain chord. Now throw the switch from "stereo" to "mono" so that each ear receives both frequencies: you will hear a new additional tone (700 Hz) come in, which is being generated in the ear itself. This is a real tone, not just a sensation of tone; this is proved because it can be canceled out by adding 700 Hz in opposite phase (and correct amplitude) to the tones generated in Audacity.

Do you still have an unanswered question? Please log in first to post your question.