Fourier synthesis is a method of making sounds (usually pleasant sounding timbres to be used in music) using sine waves as building blocks. It is based on the work of Jean-Baptiste Joseph Fourier.

It is a certain form of additive synthesis that only uses sine waves. Additive synthesis in general can instead use any kind of waveform as its building blocks, though it's worth noting that any waveforms in turn could be made with sine waves anyway.

Some brief theory:

Pretty much any timbre that sounds melodic is made up of sine waves of related frequencies. The fundamental harmonic is the main one, which is simply the note you want to play. The next one is twice as fast and called the second harmonic. The next is three times the speed and called the third harmonic, and so on. By combining sine waves whose frequencies (speeds) are multiples of the fundamental one, but whose amplitudes (loudness) differ, you can make pretty much any melodic sound you can think of.

How to make some waveforms common in audio synthesis using just a handful of sine waves:

To create a sawtooth wave, include all integer harmonics. The amplitude of each harmonic n should be 1∕n the amplitude of the fundamental harmonic. In other words, the fundamental harmonic should be set to full blast, the second harmonic set to half that volume, the third to a third of its volume, and so on, with as many harmonics included as possible.

To create a square wave, include only odd harmonics (the frequency should be f(2n−1) where f is the fundamental harmonic). The amplitude of each harmonic n should be 1∕n the amplitude of the fundamental frequency. Put simply, ignore the second, fourth, sixth harmonic and so on, and keep the rest as they were.

To create a triangle wave, again include only odd harmonics (so the frequency should still be f(2n−1) where f is the fundamental harmonic). The amplitude of each harmonic n should be 1∕n² the amplitude of the fundamental frequency.

Python code for the above:

In these examples, the code is in a for loop where x is the number of the harmonic (x should count up from 1 to however many sine waves you want to generate; the more you choose, the more accurate the results, but the slower the program). The loop should be fed the variable time as a number between 0 and 1, which tells it how far along one cycle of the waveform it should be, and should return amplitude as a number between -1 and 1 for the position the speaker should be set to.

Sawtooth wave: `amplitude = amplitude + math.sin(x * 2 * math.pi * time) / x`

Square wave: `amplitude = amplitude + math.sin((x * 2 - 1) * 2 * math.pi * time) / (x * 2 - 1)`

Triangle wave: `amplitude = amplitude + math.sin((x * 2 - 1) * 2 * math.pi * time) / math.pow(2, (x * 2 - 1))`