Calculation of Sample Rates and Musical Intervals

New: Try the JavaScript Tempo/Pitch Calculator

How to calculate the frequency or tempo change required to shift a sample by a musical interval measured in cents.

If you have a sample recorded at 120 bpm (beats per minute), and want to shift the pitch up by a perfect fifth (seven semitones, i.e. 700 cents) what rate should it be played back at to achieve this?

The function required to calculate this is:

f2 = f1 * 2^( C / 1200 )

where:

f1 = original frequency or tempo

f2 = final frequency or tempo

C = number of cents shift required

So for this example, f2 = 120 * 2^( 700 / 1200 )

= 120 * 2^ 0.5833

= 120 * 1.4983

= 179.80 beats per minute

 

How to calculate the change in musical pitch, measured in cents from a change in sample frequency playback

If you have a sample recorded at 44.1 kHz and play it back at 32kHz, what will the change in pitch be?

The function required to calculate this is:

C = 1200 * log (f2/f1) / log 2

where:

f1 = original frequency or tempo

f2 = final frequency or tempo

C = number of cents shift required

So for this example, C = ( 1200 * log( 32000/44100 ) ) / 0.3010

= ( 1200 * -0.1393 ) / 0.3010

= -555.35 cents, i.e. a shift down of about five and a half semitones.

Mathematical explanation of the equations:

We know that for a change in pitch of one octave, i.e. 12 semitones, that frequency is doubled, so for an equally tempered scale, the ratio of frequencies for each adjacent semitone is 2^(1/12) (the 12th root of 2) which is approximately 1.0595. We also know that a semitone is represented by 100 cents. Let us call this ratio ‘r’. So, if f1/f2 = r, then f1 is greater than f2 by 100 cents.

 

From above, we know that r^12 = 2, and r^1 = r so for an arbitrary number of cents, ‘C’

let n = C/100,

i.e. r^n = f2/f1.

Taking logs,

n * log r = log (f2/f1),

n = log(f2/f1)/log r,

n = log(f2/f1)/ log (2^(1/12) )

substituting C back in,

C = 100 * log(f2/f1)/((1/12) * log 2),

C = 1200 * log(f2/f1) / log 2

Rearranging,

C * log 2 / 1200 = log(f2/f1)

Taking antilogs,

f2/f1 = 10^((C * log 2)/1200)

f2/f1 = 2^( C / 1200 )

 

Glossary

What is a "Cent"

A Cent is a term used to describe a fraction of a musical interval. By definition, on an equally tempered scale there are 100 cents in a semitone. This means that in a scale from for example C3 to C4 there are 1200 cents.

What is frequency

It is the frequency of a musical tone that determines its pitch. Frequency is usually measured in Hertz (Hz), but when describing a tempo is often in beats per minute. A4 is defined to be 440Hz (440 cycles or vibrations per second). Most sounds are complex and comprise a fundamental, plus a number of harmonics. It is the fundamental that we are interested in. Other harmonics contribute to the individual sound of the instrument.

What is an octave

An octave is the musical interval between two notes, where one note is exactly twice the frequency of the other. An octave is a musical interval of twelve semitones on an equally tempered scale.

What is an equally tempered scale

The scale on keyboard instruments since Bach’s time has been approximated into equal mathematical divisions. Before that time, if an instrument was tuned to one key, it would be unsuited to playing in other scales unless it was retuned. Bach promoted the retuning of instruments with a set of pieces for the "Well Tempered Clavier" that used a whole range of different keys. Natural acoustic scales (which vary slightly from 100 cents between each semitone) still exist in ethnic and folk music where fretless instruments and the human voice are used. Some synthesizers also permit retuning to other scale systems.


  • Back to the Musicians' Index page.

    (C) Iain W. Bird, April 1998