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.

Fifty-three pure fifths wound round the octave. The first twelve, in the heavier line, miss their starting point by the Pythagorean comma, the small wedge at the top.

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.

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.