# How to reference or calculate the percentage pitch change between two notes?

I'm building an arpeggiator software.

So to start off I have a note for a piano sample, call it 'piano-base-note.mp3'.

and I have a script to increase / decrease the pitch of an mp3 file by some percent. When the arpeggiator starts up, it will create the altered mp3 files needed to play the arpeggio. That is, it will change the pitch and save new copies.

Right now I'm defining a 'note' in terms of percentage difference from the base note. I.e. to go down 50% in pitch would be `0.5`. To double pitch is `2.0`.

Now I'm trying to use this percentage-based approach to make actual scales, and I'm not sure how.

Is there some kind of chart to show the percent pitch change between two notes? Or a formula to calculate it?

• huygens-fokker.org/scala might be worth a peek. Oct 24, 2016 at 16:09
• I was about to ask why you'd use percentage difference (an unnecessary complication) rather than ratio, but then saw that you're using ratio! (The two shifts you mention, expressed as percentage differences, would be –50% and +100%.) Oct 25, 2016 at 23:01
• If you read Objective-C code, checkout this class I created which does just what you are asking for. The audio player class in the library also allows you to modify pitch of a sample in real time. Here: github.com/rednebmas/SBMusicUtilities/blob/master/…
– SamB
Oct 28, 2016 at 6:58

The general answer to "what is the percent pitch change between two notes" is probably "Thursday", since the OP hasn't given any clue what "note" is supposed to mean.

If you are talking about conventional western music and equal temperament, an octave has a frequency ratio of 2:1 and is divided in to 12 parts (semitones). Pitch changes works on a logarithmic scale, so one semitone has a pitch ratio of (the 12th root of 2) : 1, or a 5.94630943592952645618252949463% increase (according to the calculator in Windows 10).

The standard way to describe the numerical size of musical intervals is in "cents" - one cent is 1/100 of a semitone or 1/1200 of an octave, measured on a logarithmic scale. One cent is therefore a pitch ratio of 0.05777895065548592967925757932% - note that since this is a logarithmic scale, it is NOT "the size of a semitone divided by 100" i.e. 0.0594630943592952645618252949463%.

There are many other possible tuning systems - try https://en.wikipedia.org/wiki/Musical_temperament is get started, or google "musical temperament".

In "Just intonation", the intervals of an arpeggio will usually be fairly simple fractions like 5/4, 4/3, 3/2, 8/5, etc.

There is no deep logical reason why an octave should be divided into 12 equal parts, as in popular Western music. For example, "classical" Indian music uses a scale with 22 unequal divisions. Scales with other numbers of equal divisions have also been used in the West - for example 19, 24, 53, or 72 "notes per octave" instead of 12.

• Great answer, but there is a (not necessarily deep) logical reason to divide a scale into equal semi-tones. If we use just intonation, and go around the circle of 5ths, from C back to C, we'll land slightly askew of where we started. Historically other compromises were used, with some keys sounding more in tune than others - each key had its own 'color'. . . with the advent of equal temperament, it became possible to write music that exploited key changes, such as launching into another key from a dominant 7th chord. (Ironically, a dominant 7th chord in just intonation is very smooth sounding) Jul 30, 2017 at 8:21

There are two types of formulas you can use to find the relation between notes— just intonation, and equal temperament; both of which have their benefits and trade-offs, which I will not go into in much detail in this answer, as it seems outside of the scope of your question.

First, a general rule, that holds true in both systems

To find a note an octave above another note, multiply its number by 2. To find a note an octave below another note, divide its number by 2.

Just Intonation

In just intonation, the number you will be multiplying a pitch by will be a ratio between two whole numbers— you gave two examples in your question: 1/2 (or 0.5) and 2/1 (or 2.0).

Here are the fractions you should multiply your base note by to get the notes of the major scale in just intonation:

Tonic/1st: 1

2nd: 9/8

3rd: 5/4

4th: 4/3

5th: 3/2

6th: 5/3

7th: 15/8

And here are the fractions for the notes of the minor scale:

Tonic/1st: 1

2nd: 9/8

3rd: 6/5

4th: 4/3

5th: 3/2

6th: 8/5

7th: 9/5

Equal Temperament

The octave is divided into 12 semitones. In equal temperament, each of the semitones is the exact same size— the twelfth root of two. Thus, 1 semitone up equals 1 times the twelfth root of two, 2 semitones up equals 2 times the twelfth root of two, and so on. Here are the decimal approximations for the equal tempered intervals of the scale.

1 semitone/minor second: 1.059463

2 semitones/major second: 1.122462

3 semitones/minor third: 1.189207

4 semitones/major third: 1.259921

5 semitones/perfect fourth: 1.334840

6 semitones/tritone: 1.414214

7 semitones/perfect fifth: 1.498307

8 semitones/Minor sixth: 1.587401

9 semitones/major sixth: 1.681793

10 semitones/minor seventh: 1.781797

11 semitones/major seventh: 1.887749

12 semitones/ octave: 2.0

So which system should you use?

The intervals of just intonation have a purer sound. However, it only works in one key. If you set the ratios up for C major in just intonation and then play a D major scale or arpeggio, it will sound wrong. Since you're making a program, I'm assuming you want it to work in all keys, so I would say that equal temperament is the right formula for the job. Additionally, you mentioned you were using a piano sample. Pianos are tuned in equal temperament, so it will probably sound truer to a real piano sound if you use equal temperament.

• Actually pianos are not tuned to equal temperament (google "Stretched tuning") - but if the OP is only working with ONE piano sample, that is irrelevant anyway.
– user19146
Oct 24, 2016 at 3:23
• In stretched tuning, are the steps not equal to each other? Oct 25, 2016 at 23:05
• Stretched tuning is something close to a perfect fifth being equally tempered over 7 steps, so pow((3/2), (n/7)), rather than an octave being equally split into 12 notes. This is how Steinway expects their pianos to be tuned, from what I understand. In reality, it varies by piano and by register, as the overtones of a struck piano string are wider than the overtones of an ideal string, and change based on the individual characteristics of each string (read more about this phenomenon at en.m.wikipedia.org/wiki/Inharmonicity). Oct 26, 2016 at 15:45

Your formula, excel style, will be pow(2, (n/12)) where n is n half steps above the original pitch.

For a major scale, use notes 0 2 4 5 7 9 11 and 12.

This will give you an equal tempered major scale in mp3 form.

Other answers go pretty far in-depth, but I've found that for quick back-of-the-envelope calculations, I'll use 6% as the half-step - multiply or divide by 1.06 - since that's about equal to the 12th root of 2. It's a decent approximation of 12-TET if you don't care about intonation and just want to estimate, say, how much smaller your guitar frets need to be higher up the neck or whatnot. Of course, if I need an exact answer, I'd never do this, but just for thought experiments where I need a ballpark guess, I'll quote 6%.

• 6% is a surprisingly good approximation (0.9 cent error), but when adding up the errors may add up, there is no reason not to use full precision in a computer program. Noteworthy, historically "rule of 18" was used in instrument building, so the first fret was at 17/18 length of the instrument scale (1.0 cent error). May 25, 2021 at 17:06

Using the SpeedCrunch high precision calc for Linux... it feels like Bitcoin mining as the final number lines up with perfect row of zeroes at the end....

In 64 bit floating point:

``````
1
= 1.00000000000000000000000000000000000000000000000000

ans*2^(1/12)
= 1.05946309435929526456182529494634170077920431749419

ans*2^(1/12)
= 1.12246204830937298143353304967917951623241111061399

ans*2^(1/12)
= 1.18920711500272106671749997056047591529297209246382

ans*2^(1/12)
= 1.25992104989487316476721060727822835057025146470151

ans*2^(1/12)
= 1.33483985417003436483083188118445277491239021262520

ans*2^(1/12)
= 1.41421356237309504880168872420969807856967187537695

ans*2^(1/12)
= 1.49830707687668149879928073202979579630215155373175

ans*2^(1/12)
= 1.58740105196819947475170563927230826039149332789985

ans*2^(1/12)
= 1.68179283050742908606225095246642979008006852471357

ans*2^(1/12)
= 1.78179743628067860948045241118102501597442523175632

ans*2^(1/12)
= 1.88774862536338699328382631333506875201513660667749

ans*2^(1/12)
= 2.00000000000000000000000000000000000000000000000000
``````

@user19146 it sounds like you're referring to Pythagorian tuning, which, while being quite cool, and mathematically elegant and using simple fractions, aint as funky as those log of 1/12. Twas' close, but not quite.

Is it necessary that the notes of the arpeggio be notes of the key scale? You might consider spacing them equally (in absolute frequencies rather than in logarithms), so that each is a multiple (within the tolerance of the temperament) of the same fundamental frequency. Thus: supposing that you're going from freq0 to freq1, with N-1 intermediate steps, the jth note of such an arpeggio is freq0+j*(freq1-freq0)/N.

(If the ideal ratio between the extreme frequencies is p:q, e.g. 5:8 for a minor sixth, N should be a multiple of |p-q|.)

I know this is old, but I was wondering the same thing. After some research and calculating for myself, the answer I think the OP was looking for is as follows: For a 12-note-per-octave equal-tempered scale, each note or semi-tone is 5.946309436% "higher" in frequency than the previous note. So if you have a piano sample in "A" and you play the sample at 1.0596309436x playing speed it would playback as A#/Bb. For B you increase playback speed of the A#/Bb sample by another 5.963...% (which works out to approximately 1.1225x playback speed of the original sample.) The 5.96309436% figure only works incrementally when going up the scale. When going down the scale each note (semi-tone) should be played 5.612568731% lower/slower than the previous note (or approx. 0.9439x playback speed)

Here's a simple partial chart giving the playback speed and resulting frequency of a few notes if you were using sample that was an A at normal speed (440hz) :

F#Gb- 0.8409x 369.99hz (5.61% slower than G)

G------ 0.8909x 392.00hz (5.61% slower than G#/Ab)

G#Ab- 0.9439x 415.30hz (5.61% slower than A)

A------ 1.0000x 440.00hz

A#Bb- 1.0595x 466.16hz (5.95% faster than A)

B------ 1.1225x 493.88hz (5.95% faster than A#Bb)

C------ 1.1892x 523.25hz (5.95% faster than B)

C#Db- 1.2599x 554.37hz (5.95% faster than C)

Just continue the same way in either direction for any other note you wish to play back based upon the original sample.

• I would give add the computation formula for the magical 5.6...% (12th root from 2 minus 1) and recommend to replace slower by lower and faster by higher, since if when already talking about frequencies, slower/faster is more misleading than helpful. Nov 28, 2018 at 9:14