How far an equal scale drifts from pure ratios.
Why does a tuning feel resolved, and what does the arithmetic actually guarantee? I wanted the relationship between ratio and temperament laid out where I can check it. Every number below is recomputed, as an exact fraction where one exists, from the ratios you type. The numbers describe ratios; how a tuning sounds to a listener is a separate question.
equal steps: the nearest step to the pure fifth is , and the nearest to the pure third is . Drag the number, or use the arrow keys.
Exact ratios and tempered steps
Supply whole-number ratios, a reference frequency and a number of equal divisions per octave. The engine reduces each ratio exactly, factors it into primes, measures it in cents, finds the nearest tempered step and its deviation, certifies which integer harmonics a chord's members are, and multiplies stacked intervals to exact commas.
Equal temperament trades exact ratios for transposability: every step is the same factor, the N-th root of two, so no tempered interval except a whole octave is a whole-number ratio. Tenney height, Euler's gradus and prime limit are historical measures of how simple a ratio is.
The tuning you edit
The intervals, chords and stacks are example inputs, and everything runs in your browser: nothing you type is stored or sent, and no audio is recorded.
Intervals, chords, stacks, the reference and the equal division are all editable in the JSON source. Loading an example or resetting replaces your edits and clears the results.
Edit the intervals, chords, stacks and reference
Edit intervals[].ratio as whole-number num and den; equalDivisions for the temperament (default 12); referenceHz for the 1/1. Chords list interval ids and may include the reserved UNISON for 1/1. Stacks multiply an interval times an integer count, negative for descending.
1 to 24 intervals with ratio parts 1 to 1,000,000 and ratio between 1/1 and 8/1; 0 to 8 chords of 2 to 6 members; 0 to 8 stacks of 1 to 8 steps with times from -24 to 24 and a product within 1/4096 to 4096; reference 20 to 20,000 Hz at most 3 decimals; 1 to 72 equal divisions; 50,000 source characters. Unknown and duplicate JSON fields are refused.
JavaScript is required to compute. No calculation has run.
Summary of the run
Frequencies display three decimals; the exact fraction sits under each value and in the export. Deviations are tempered minus just, so a negative value means the tempered step is flat of the ratio.
Intervals, reduced and measured
Each ratio is reduced with an exact gcd, factored by trial division, measured as 1200 times the base-two logarithm, and rounded to the nearest equal-division step. Gradus is Euler's 1739 integer; Tenney height is the base-two logarithm of numerator times denominator. Both measure ratio simplicity.
| Interval / source | Reduced | Prime factors | Limit | Tenney | Gradus | Cents | Nearest step | Tempered | Deviation | Hz | Optional preview |
|---|
Each Play button makes two short sine tones, at the reference and at the interval frequency, for 1.2 seconds with the gain ramped to avoid clicks. Playback stays out of the download.
Where each ratio lands on the octave
Zero to 1200 cents, one pixel per cent, with a tick at every equal-division step. Each supplied interval is marked at its octave-reduced position for display only; the interval table keeps the supplied size. The bar beside each marker is its deviation from the nearest tick.
Scroll horizontally to inspect the full ruler on a small screen. Exact values are in the interval table and the export.
The same ratios in 12, 19, 31 and 53 divisions
Each supplied interval is rounded to the nearest step of four common equal divisions, and of this run's own division when that is none of the four. A bar is the deviation in cents, tempered minus just. The summary gives the worst interval, the mean absolute deviation and the root-mean-square deviation for each division, so a finer division that tracks the ratios more closely shows its advantage in one row.
Scroll horizontally on a small screen. Hover a bar for its step and exact deviation; the tables below list every value.
| Divisions | Step | Largest deviation | Mean | RMS | Within 5 cents |
|---|
Chords over a common fundamental
For each chord, every pair is an exact reduced ratio of the higher member over the lower. The common fundamental is the gcd of the numerators over the lcm of the denominators: the largest rational that every member is a whole multiple of. The resulting harmonic numbers, such as 4:5:6 for a just major triad, are arithmetic facts about the ratios; which note is heard as the root is a separate question. Each chord can be played from its lowest member up, from its highest down, or all at once: members enter 0.6 seconds apart in exact ratio order and sound together for the final 1.2 seconds.
Stacked intervals and their commas
A stack multiplies interval ratios by integer powers. Twelve fifths down seven octaves gives 531441/524288, about 23.460 cents, the Pythagorean comma. The comma column divides the product by the nearest power of two, so twelve fifths left unfolded (531441/4096, seven octaves up) show the same residue.
| Stack / source | Steps | Product | Prime factors | Cents | Octaves | Comma | Comma cents | Nearest step |
|---|
Each tempered step and its nearest ratio
Every step of the chosen division from zero to the octave, its tempered cents, its frequency at the reference, and the supplied interval that rounds to it with the smallest deviation. An interval is listed under whichever step it rounds to, so a ratio just above 2/1 can still appear at the octave step; one that rounds beyond the octave stays in the interval table only.
| Step | Tempered cents | Hz | Best just interval | Deviation | Other candidates |
|---|
Exact source text for this calculation
Whitespace and field order are preserved. Any change to the editor, including a silent programmatic edit, invalidates this run. Export checks the live editor again before creating a file.
Method and limits
Ratio, cents and tempered steps
Each interval is a positive whole-number ratio between 1/1 and 8/1, reduced by an exact BigInt gcd. Ratios below 1/1 or above 8/1 are refused as typed. Numerator and denominator are factored by trial division; both are at most 1,000,000. The prime limit is the largest prime that appears. Derived ratios (chord pairs and stack products) carry exact prime exponents and are cross-checked against the directly reduced product; a disagreement fails the run.
Cents are 1200 * log2(num / den) in IEEE-754 double precision. For any fraction whose terms exceed 2^53, such as a long stack or a wide chord fundamental, the engine takes the leading 53 bits of each term, with a relative error below 2^-52. The nearest step is round(cents * divisions / 1200), halves rounding up; tempered cents are 1200 * step / divisions; deviation is tempered minus just. The reference frequency is stored as an exact whole number of millihertz, so interval frequencies are exact fractions; tempered frequencies are referenceHz * 2^(step / divisions) and irrational except at whole octaves.
The comparison repeats the nearest-step rounding for 12, 19, 31 and 53 divisions, plus the run's own when it differs, and reports for each the largest absolute deviation, the mean absolute deviation and the root-mean-square deviation in double precision. By hand, the 3/2 fifth sits 1.955 cents flat in 12 divisions, 7.218 flat in 19 (step 11), 5.181 flat in 31 (step 18) and 0.068 flat in 53 (step 31); the 5/4 third sits 13.686 sharp, 7.366 flat, 0.783 sharp and 1.408 flat.
Equal temperament is the choice of a single irrational step so that every key is the same. That trade is what makes transposition free and what makes every interval except the octave inexact. Worked by hand: a 3/2 fifth is 701.955 cents; the 12-division step is 700, so the deviation is -1.955; in 19 divisions the nearest step is 11 at 694.737, deviation -7.218. See Cent (music) for the unit's definition.
Simplicity measures, the common fundamental and commas
Tenney height is log2(num * den) of the reduced ratio, a float. Euler's gradus suavitatis, from his Tentamen novae theoriae musicae of 1739, is 1 + sum over prime factors p with multiplicity of (p - 1) applied to num * den: an exact integer, 1 for 1/1, 4 for 3/2, 7 for 5/4. Both are historical arithmetic measures of ratio simplicity, reported as exactly that.
The common fundamental of a chord is the gcd of the members' numerators over the lcm of their denominators. Every member divided by it is an integer, and with reduced members those integers are coprime; the engine rechecks both facts and fails the run if either breaks. A just major triad 1/1, 5/4, 3/2 therefore reads 4:5:6 over 1/4; adding 7/4 reads 4:5:6:7. The chord table lists each pair's Tenney height and gradus, their maximum and sum, and the prime limit.
A stack multiplies the supplied ratios by integer powers from -24 to 24, exactly. The product must stay within 1/4096 to 4096 (twelve octaves either way) or the stack fails with its product named, long products abbreviated to their digit count. The comma divides the product by the power of two nearest in cents, so twelve fifths down seven octaves (531441/524288) and twelve fifths alone (531441/4096, seven octaves and the same residue) both expose 23.460 cents; four fifths down two octaves and a major third expose 81/80 (21.506 cents). See Pythagorean comma for the classical statement of the first.
Source schema and limits
Required top-level fields: fictional: true, scenario, referenceHz, intervals, chords, stacks; optional equalDivisions (integer 1 to 72, default 12). Unknown, missing or duplicate fields are errors. JSON nesting is limited to 16 levels. Each interval requires id, label, ratio with ratio.num and ratio.den integers from 1 to 1,000,000. Each chord requires id, label, intervalIds with 2 to 6 distinct members drawn from the interval ids or the reserved UNISON. Each stack requires id, label, steps with 1 to 8 steps of intervalId, times.
IDs are case sensitive, start with an ASCII letter, have at most 24 letters, digits, underscores or hyphens, and share one namespace across intervals, chords and stacks. Scenario: up to 120 characters; labels: 80. Text cannot contain control characters, invisible format characters such as zero-width spaces and bidirectional overrides, or unpaired Unicode surrogates. Reference: 20 to 20,000 Hz with at most 3 decimal places. Source: 50,000 characters. The equal-division table covers steps 0 to the division; the octave ruler reduces intervals above 2/1 by whole octaves for display only and says so.
Scope, implementation and checks
The scope is the arithmetic of ratios. Psychoacoustics, roughness, critical bands, preference and the question of which tuning is better sit outside it. The optional preview synthesises sine tones locally on request, two for an interval or one per member for a chord, and is excluded from the audit; nothing is recorded or analysed. I come to tuning as someone who builds instruments for questions, and this is one I keep returning to.
The engine and the interface are plain JavaScript with no dependencies; the same engine runs in Node and the browser. Edits disappear on reload. A download contains the complete supplied JSON, every reduced ratio, certificate, stack, comparison and table row, and replays in Node with RV_SOUND.analyze(exactInputText).
I checked the engine against hand-worked values: 3/2, 5/4 and 7/4 in cents, twelve- and nineteen-division steps, gradus, Tenney height, the 4:5:6 and 4:5:6:7 fundamentals and both commas. An independent float-only reimplementation, a naive factoriser and a brute-force fundamental search agree with it on random ratios. Those checks cover the arithmetic.