Some sounds we hear have a certain pitch while others seem to be unpitched. Broadly speaking we can use pitched sounds for playing melodies and chords. Unpitched sounds are often used for making rhythm and sound effects.
Question: how can we detect the pitch?
Answer: by using a spectrum analyser
A spectrum analyzer measures the volume levels of all frequencies of an input signal. Often a range from 20 Hz to 20 kHz is shown, the range we humans can hear.
Pitched sounds
Here’s an example using a simple saw wave as tone generator:
I used Ableton Live for creating this image and as you can see it has a very useful setting build-in: instead of frequencies it can also show the note names so you can clearly see what key the sound is in. To detect the pitch of a sound you need to find the lowest significant peak in the frequency range. The other tones which are in the higher range are overtones which colorise the sound. If a sound has many overtones in the higher frequency range we hear a brighter sound. In this case, in the above screenshot, the peak level is at 264 Hz which means we’re hearing a C3.
Most spectrum analysers don’t have this very handy feature and will only show the frequencies. This makes it hard to detect the pitch of a sound, because you then need to do the calculations yourself related to the standard pitch of A4 = 440 Hz. And to make it even more complicated: since we use equal temperament tuning this calculation is actually way more complicated than a matter of multiplication or divide (check out Wikipedia for more info about Equal Temperament).
Unpitched sounds
Unpitched sounds don’t have a clear peak. On the spectrum analyser these sounds have changing peaks on a wide spectrum jumping up and down in volume which look chaotic and without a specific peak/spike. The most extreme type of these sounds, white noise is so unrelated to pitch that when you transpose the sound a few octaves up or down you won’t hear a difference. Other unpitched sounds with rather wild spectrums might be somewhat related to tuning differences. For example a snare drum which will sound different when we tune it up or down. Just have a look at the spectrum analyser, you will see that there’s a peak/loudest volume which makes the sound somewhat pitch-related.
The lowest significant peak
I would define pitch as the lowest significant peak in the frequency range.
Update 1: I’ve updated this post a bit because Ludvig Carlson (developer at Propellerhead) came with a better way to explain it. At first I thought the pitch could be found via the most dominant peak in the spectrum but Ludvig suggested the following experiment:
1) Play and hold a bass note with a harmonically rich sound (a saw tooth or a pulse wave for example).
2) Apply a High Pass Filter and gradually raise the cutoff frequency from 0, while you watch the spectrum analyser.
The High Pass Filter will make the fundamental peak lower in volume but our ears will tell us that this frequency is responsible for the pitch of the sound.
Update 2: Reason user Exowildebeest pointed to the Piano key frequencies Wikipedia page for looking up the frequencies via a (printable) chart.