Comparing frequencies

.. is an easy task. But you can not simply compute the fundamental frequency (F0) and compare it with another (reference) value. The difference of two frequencies (in Hz) only shows, if they are equal or not. You can also find which one is higher frequency. But the difference in Hertz is no measure how different the frequencies are percepted by the human ear.

Here is an example:

The picture above shows the output of a pitch detection program. It contains some bars representing the frequency of sinus signal. The first four bars on the left side are at 100 Hz or 130 Hz as you can see. They are followed immediately by four bars of 600 Hz or 630 Hz. You should note that the difference between 100 Hz and 130 Hz is 30 Hz and the difference between 600 Hz and 630 Hz is 30 Hz too.

Now please click on the image and you will hear the frequencies displayed in the picture. If you open your ears, you will hear that the difference between the first 4 tones (100 Hz and 130 Hz) is not the same as the difference between the next 4 tones (600 Hz and 630 Hz). This is because the human ear perceives the difference between 100 Hz and 130 and the difference between 600 and 630 as a two different intervals. The first one correspondents roughly to a fourth, the second correspondents to a minor second. Do you know what a fourth or a minor second is? Recall you knowledge about music. A scale is a list of tones (like c, d, e, f, g, a, b, c). A fourth is eg. the interval between c and e. And minor second is the eg. the interval between c and c sharp. You can also find the minor second interval in the scale above. It is from e to f and from b to c.

Up to now I showed, that comparing frequencies can not be done using their Hz values. But there is a very simple transformation you can use instead: the logarithm.

difference = ln(100) - ln(130)

Or in general:
Compute f(x) = c*ln(x), for x > 0 and set f(x) to 0 for x<=0

For c = 12/ln(2) this transformation is called halftone transformation or semitone transformation. If you compute the difference of two halftone-transformed frequencies, you get the number of half tones between them (e.g. octave = 12 halftones). You now have a measure the compute the distance of two frequencies. Thats all.

Example:
difference = 12/ln(2) ( ln(130) - ln(100) ) = 4.54 and
difference = 12/ln(2) ( ln(630) - ln(600) ) = 0.84

So the higher tones are more similar. Their distance is roughly a halftone.

Another example:
Consider three tones at 110 Hz, 220 Hz and 440 Hz. From your school knowledge of music you should know that an octave simlpy doubles or halfes the frequencies. So 220 Hz is the octave of 110 Hz. And 440 Hz is the octave of 220 Hz. This is displayed in the picture below.

difference = 12/ln(2) ( ln(220) - ln(110) ) = 12 and
difference = 12/ln(2) ( ln(440) - ln(220) ) = 12

You can see, the differences are both 12. The tones have the same distances. But the differences of 440 Hz, 220 Hz and 110 Hz computed in Hertz are not the same.


Matthias Nutt