in development

constructing an arbitrary scale

One of my goals in creating Quencher was to let users venture into experimental areas of composition. Microtonal scales have a long history both within Western music and outside of it, and the app permits would-be composers to construct such scales and use them in scores.

Here’s a functional (though simplified) Javascript version of the scale editor.

Tone Interval Pitch Number / Sum Frequency (Hz)


The tone frequencies are derived from the equal-temperament system of tuning, where the frequency of each note is a constant multiple of the one before it. For the twelve-tone Western scale, that constant is the twelfth root of two, or approximately 1.059463.

Why this number? Each octave doubles the frequency: the A above middle C is 440 Hz, and the next A above that is 880 Hz. For twelve tones, we’re dividing that doubling effect into twelve equal parts. If I multiply A (440Hz) by the twelfth root of two, I get 466.16 Hz, which is the frequency for the next note (B♭). Sweet!

There’s nothing sacred about twelve tones, of course. Want a fifteen-tone scale? Just take the fifteenth root of two, pick a starting frequency–say, middle C (261.63 Hz)–and keep multiplying to get each successive frequency. Or, you can use this handy formula.

Frequency = ReferenceFrequency * pow(NthRootOfTwo, PitchNumber);

Now, each tone has a “pitch number”, a simple integer that we can increase or decrease by 1 to go up or down the scale. Find the Nth root of two, where N is the number of tones in the scale, and raise it to the power of the pitch number to get the multiplier for that specific pitch. The reference frequency defines what the frequency is for a pitch number of zero.

This works fine when all the tones are the same distance from one another. However, this isn’t always the case. A major scale has the following interval formula: 2 – 2 – 1 – 2 – 2 – 2 – 1. It has seven tones, but obviously, not all are weighted the same. How do we generate it? Let’s revise the formula above.

Multiplier = pow(2, 1 / IntervalSum);
Frequency = ReferenceFrequency * pow(Multiplier, PitchNumber);

Instead of using the number of tones as the basis for the constant multiplier, we’re using the sum of the interval values. For the major scale, that’s 2 + 2 + 1 + 2 + 2 + 2 + 1 = 12, which looks familiar enough. The pitch numbers we plug into the formula are calculated by taking a running sum of intervals: 0, 2, 4, 5, 7, 9, 11, and 12. (For a twelve-tone scale originating at middle C, that’s C, D, E, F, G, A, B, and C). This way, you can easily define scales that are subsets of larger scales.

(Shameless plug: if I’ve piqued your interest, why not try the real thing? Quencher is a free download for Android.)

Also, feel free to download the source code for this example and do whatever you like with it. It uses the RIFFWAVE library, which is a lifesaver for anyone trying to do cross-browser HTML audio.

Comments are closed.