- sound synthesis
One of the most noticeable and important features of sound, particularly in music, is its frequency.
Each musical note has a specific frequency, and a melody is distinguishable from its frequencies alone - you can recognise the same tune played on a guitar or a trumpet, even though they sound very different.
To keep things simple, in this section we will only consider sounds where the frequency is unchanging. We will look at time-varying sounds in a later article.
Units of frequency
Here is a simple sound wave:
This graph represents how the sound varies over time at a particular point in space. In some abstract sense, it represents the variation in air pressure at that point, but we are just treating it as a mathematical function - the sound value on some arbitrary scale.
This is discussed in the sound waves article. As we described there, the signal varies like this:
- The wave starts at 0.
- It goes up to the maximum value +1.
- It goes down to the minimum value, -1.
- It returns to zero.
This represents a single cycle of the wave. This cycle repeats over and over again.
The frequency of the wave is the number of times this cycle repeats every second. The number of cycles per second is measured in Hertz (written as Hz). So for example 400 Hz simple means the wave repeats as 400 cycles per second.
We will also use kilohertz, kHz. 1 kHz is equivalent to 1000 Hz.
The range of audible frequencies, for humans, is between 20Hz and 20 kHz. However, most people can't hear that entire range, and as you get older the range tends to diminish, especially the higher frequencies.
This shows the range of audible frequencies:
For comparison, the normal range of the human voice (about 500 Hz to 2 kHz) is also shown.
The frequency scale is logarithmic. That means that each division on the scale represents the frequency being multiplied by 10. So, for example, the range 10 Hz to 100 Hz has the same width as the range 100 Hz to 1 kHz.
Musical notes are generally in the range of 20 Hz to about 4 kHz. For example, an 88 key piano covers the range A0 (27.5 Hz) to C8 (4186 kHz).
Here are the frequency ranges of a few common instruments:
A church organ has the widest range - some go from about 8 Hz to 7 kHz. The bottom end of that range, the sub-bass, is not necessarily audible. If the sound is loud enough, you will feel it, as a vibration in your chest cavity.
Achieving very low or very high frequencies with a physical instrument can be difficult. A church organ requires very large pipes for the lowest frequencies, which is why they are not portable. Analogue or digital synthesisers can create operate at any frequency without needing big or heavy components.
The frequency produced by a musical instrument determines the musical note we hear. For example, an oscillation of 440 Hz corresponds to the note A4.
When an instrument creates a sound, it often creates harmonics that are a multiple of the basic frequency. For example, if you play A4 on a guitar it will create additional frequencies of 880 Hz (ie twice the original frequency), 1320 Hz (three times the original), 1760 Hz (four times the original), and so on.
We don't hear all these frequencies as different notes, we only hear the note A4, but the harmonics contribute to the timbre of the sound. They give the sound richness and interest. The presence of harmonics in different proportions is what gives different instruments their unique sound, and what makes a trumpet sound different to a piano. This is covered in the wave shapes article.
Even though most musical instruments only create notes up to about 4 kHz, they usually create harmonics that go well above that frequency. For good quality sound, we need to be able to represent frequencies across the whole audible range, which is up to about 20 kHz. Otherwise, the sound will be of poor quality.
Sign up to the Creative Coding Newletter
Join my newsletter to receive occasional emails when new content is added, using the form below: