The following is a “computational” tonal analysis of musical works by J.S. Bach known as *The Well-tempered Clavier*, books II and II, published circa 1722 and 1742 respectively, and *Goldberg Variations* (1741).

All musical scores have been converted from MusicXML to Bol Processor syntax — read Importing MusicXML scores. This tonal analysis is produced by Bol Processor’s tonal batch-processing tool.

The aim of this exercise was to match each musical work against a set of tuning schemes described and implemented on the Bol Processor. These comprise all temperaments documented by Pierre-Yves Asselin ([1985], 2000) and “natural” scales constructed systematically — read Creation of just-intonation scales.

It was assumed that the best match for a scale points at the tuning scheme fit for the interpretation of a musical work. This assumption is based on the hypotheses that (1) musicians and composers of the Baroque period aimed at achieving optimum “consonance”, and that (2) this notion implied a preference for certain intervals expressed as integer ratios. These statements are discussed on this page. Accurately tuned sound examples are proposed for an auditive assessment of results.

The interest of this tonal analysis goes beyond the comprehension of music theory and practice. Its epistemological dimension is the trustworthiness of mathematical “predictive models” in vogue today. We show that, given a set of hypotheses, the solution of an optimisation problem — finding the best tuning scheme for all musical works in a repertoire — is not unique as it depends on initial conditions. Further, the same initial conditions may produce a cloud of seemingly identical solutions, even though each of them points at utterly different procedures for its realisation in the “real world” — here, tuning a harpsichord.

The giveaway message is that scientists should not be impressed by the accuracy and apparent consistency of solutions produced by machines. They need to critically examine initial conditions *and* the computational process itself.

In the end, listening to the audio rendering of results is the only acceptable way to (in)validate a compositional model.

## “Standard” analysis

*The Well-tempered Clavier* comprises two books, each enlisting 24 preludes and 24 fugues in all conventional key signatures. In sum, this analysis covered 96 musical works (presumably) composed by the same composer in (presumably) similar conditions.

Our first analysis relies on the following settings of intervals estimated *consonant* or *dissonant*:

The analysis of ascending and descending *melodic* intervals checks for common frequency ratios close to 3/2 (Pythagorean fifths) and 5/4 (harmonic major thirds) which are widely estimated “consonant”. It also includes ratios 6/5 (harmonic minor thirds) and 9/8 (Pythagorean major seconds) which *may be* considered optimal. Other ratios are often rated “dissonant”: 40/27 (wolf fifth), 320/243 (wolf fourth) and 81/64 (Pythagorean major third). These dissonant intervals are 1 comma (ratio 81/80) higher or lower than their “consonant” neighbours — read page Just intonation: a general framework.

Consonant intervals have been assigned positive weights, for instance ‘1’ for a harmonic major third and ‘2′ for a Pythagorean fifth. Dissonant intervals are assigned negative weights, for instance ‘-2′ for wolf intervals and ‘-1’ for Pythagorean major thirds. These weights can be modified; indeed, the modification will in turn alter the ratings of tuning schemes.

Each melodic interval found in the musical work will be sized as per the same interval in the tonal scale assessed for compatibility. For instance, when trying to match the *D’Alambert-Rousseau* tuning scheme (see image), a note sequence ‘C’ - ‘Eb’ will be sized 290 cents, which is close to 294 cents or ratio 32/27 (Pythagorean minor third). Should this ratio appear in the settings, the score of the scale will be incremented by the weight of the ratio multiplied by the (symbolic) duration of the interval — read Tonal analysis of musical works for details of this procedure.

The same method is applied to harmonic intervals, here assigned the same weights as melodic intervals, except ratio 9/8 which is ignored.

Scores for ascending and descending melodic intervals are then added with the score for harmonic intervals, with respective weights 1, 1, and 2. This weighing can also be modified if “consonance” is more expected on melodic versus harmonic intervals, or if ascending and descending melodic intervals are not estimated of equal importance.

Every tonal scale is gratified with a mark when found the best match for a musical item. Counting these marks over the whole repertoire indicates the best tuning scheme(s) for this repertoire.

Results are stored in tables that can be downloaded in both HTML and CSV formats. The initial settings are reminded at the bottom of the “all results” HTML page.

- Result for the 24 preludes of book I: follow this link (all results) or this link (abstract)
- Result for the 24 fugues of book I: follow this link (all results) or this link (abstract)
- Result for the 24 preludes of book II: follow this link (all results) or this link (abstract)
- Result for the 24 fugues of book II: follow this link (all results) or this link (abstract)

Each cell in the “all results” table indicates the rank of a given tuning scheme (scale) matched against a given musical work. For instance, in the fugues of book I, *Corette’s temperament* (column corrette) ranked 6^{th} for the 5^{th} fugue, and the best match for this piece was *Sauveur’s temperament* (column sauveur).

The line labelled Ranked first (times) displays the number of times each tuning scheme ranked first in the classification of this corpus. The line labelled Average score displays the average global (melodic + harmonic) score computed for this tuning scheme, as explained on our page Tonal analysis.

Abstract tables display the list of tuning schemes ranking first for each musical work.

➡ *The complete set of scale images is available on this page.*

## Discussion of the standard analysis

Out of these 96 musical works, 56 opted for ‘sauveur’ as their favourite tuning scheme, plus 9 as next to favourite. This temperament strikingly dominates the classification because of its proficiency in almost perfect Pythagorean fifths (ratio 3/2), harmonic major thirds (ratio 5/4) and harmonic minor thirds (ratio 6/5).

Note that it also contains a wolf fourth ‘Eb’ - ‘G#’ close to 477 cents (or ratio 320/243) perceived as a dissonant interval. The guess is that these two notes are never (or rarely) found in melodic or harmonic intervals on this repertoire. This illustrates the fact that there no *one-fits-all* solution to the problem of tuning an instrument for this type of music. In a “reverse engineering” turn of mind, we may say that the composer explored melodic and harmonic pleasant effects to build this repertoire: playing on the instrument before notating on sheets of musical scores.

As suggested in our tutorial, there is no evidence of J.S. Bach’s awareness of the theoretical work by French physician Joseph Sauveur, but the theoretical framework of this temperament — a single sequence of fifths diminished by 1/5 comma (see image and read Asselin, 2000 p. 80) — suggests that any composer might figure it out independently. This process has been recorded as follows on Bol Processor’s **Scale** page:

`Created meantone downward notes “do,fa,sib,mib” fraction 3/2 adjusted -1/5 comma`

Created meantone upward notes “do,sol,re,la,mi,si,fa#,do#,sol#” fraction 3/2 adjusted -1/5 comma

Interestingly, “natural scales” with names equating the key — for instance Abmin (i.e. G#min) for the *Fugue 18 in G♯ minor*, book II (BWV 887) — often came on top of the favourite tuning schemes, yet in most cases outraced by several temperaments. Read our page Creation of just-intonation scales for more details on these scales.

In all cases, the scoring of equal-temperament (see image) was among the lowest due to its use of major and minor thirds close to Pythagorean. *This contradicts the popular belief that Bach’s series of preludes and fugues aimed at equating “well-tempered” with “equal-tempered”…*

This first result also suggests that temperaments often provide a better tonal structure for achieving maximum consonance than the so-called *just intonation* scales.

Temperaments are based on * empirical* tuning

*procedures*guided by

*perceived*intervals (read Asselin, 2000) whereas “just intonation” is the outcome of

*speculations*on number ratios — a

*process. This takes us back to a discussion of the ancient Indian approach of tonality, read page The two-vina experiment.*

**deductive**## “Alternate” analysis

At this stage, it is tempting to conclude that J.S. Bach’s *The Well-Tempered Clavier *was meant to be performed on instruments tuned as per *Sauveur’s temperament*. However, the result of an analysis always need to be examined for biases in its hypotheses. In the present case, we need to revise the choice of certain frequency ratios as criteria for evaluating the “consonance” of melodic and harmonic intervals.

The minor third — either harmonic (6/5) or Pythagorean (32/27) — is at stake because the Pythagorean minor third appears in some temperaments. For instance, the Cmaj natural scale (see image) uses 32/27 for its interval ‘C’ - ‘Eb’. Therefore, it makes sense to ignore all minor thirds in the evaluation of harmonic intervals and accept both ratios 6/5 and 32/27 with equal positive weights in melodic intervals. *This option will be illustrated by sound examples, read further.* A meaningful variant would be different ratios in ascending and descending harmonic intervals.

Same remark regarding major thirds: even though ratio 5/4 (harmonic) sounds certainly better than 81/64 (Pythagorean) in harmonic intervals, there is no strong reason to prefer the former in melodic intervals — again with a possible distinction between ascending and descending movements.

Let us start again the entire analysis with these modified settings:

Results are the following:

- Result for the 24 preludes of book I: follow this link (all results) or this link (abstract)
- Result for the 24 fugues of book I: follow this link (all results) or this link (abstract)
- Result for the 24 preludes of book II: follow this link (all results) or this link (abstract)
- Result for the 24 fugues of book II: follow this link (all results) or this link (abstract)

## Discussion of the alternate analysis

Results contradict the conclusion of the “standard” analysis: *Sauveur’s temperament* might not be such a good choice, given the alternate choice of ratios for consonant/dissonant melodic and harmonic intervals.

According to these settings, the best tuning schemes might be *D’Alambert-Rousseau temperament* (see image and read Asselin, 2000 p. 119) and *H.A. Kellner’s BACH temperament* (see image and read Asselin, 2000 p. 101). Both have been designed after J.S. Bach’s death, but similar or identical tuning procedures could be figured out by the composer.

Comparing the images and cent positions (equal within ± 7 cents) explains why these two temperaments produced identical matches despite their utterly different tuning procedures. Look at the procedures (traced by the algorithm) and listen to short note sequences produced with these scales:

`D'Alembert-Rousseau temperament`

Created meantone upward notes “do,sol,re,la,mi” fraction 3/2 adjusted -1/4 comma

Created meantone downward notes “do,fa,sib,mib,sol#” fraction 3/2 adjusted 1/12 comma

Equalized intervals over series “sol#,do#,fa#,si,mi” approx fraction 2/3 adjusted 2.2 cents to ratio = 0.668

`Kellner's BACH temperament`

Created meantone upward notes “do,sol,re,la,mi” fraction 3/2 adjusted -1/5 comma

Added fifths down: “do,fa,sib,mib,lab,reb,solb” starting fraction 1/1

Created meantone upward notes “mi,si” fraction 3/2

As a reminder, the same sequence of notes with an equal-tempered scale:

These tuning procedures do not reproduce precisely the ones described by Asselin (2000 p. 120 and 102) but they yield the same tonal positions.

In these temperaments, intervals such as ‘C’ - ‘Eb’ are rendered as Pythagorean minor thirds (32/27), and many Pythagorean major thirds (ratio 81/64) are encountered. This justifies their choice, given the new conditions of analysis.

Again, these temperaments dominate the classification, ranking 65 times in first position and 15 times in second position, whereas equal-temperament ranked first only 21 times despite its proficiency in Pythagorean major thirds. Compared with *Sauveur’s temperament* in the standard analysis (56 first positions and 9 second positions) these tuning schemes look “better”, yet *this comparison is irrelevant since the two analyses focussed on different ratios*.

The 33 preludes and fugues uncompliant with these temperaments often preferred a just-intonation scale in the same key, for instance *Prelude 8 in E♭ minor* of book I (BWV 853) selects the Ebmin scale, and *Prelude 9 in E major* of book I (BWV 854) selects the Emaj scale. However, this matching is less frequent in “dissident” fugues.

More advanced analyses are required. Keep in mind that changing the weights of intervals or weights in the summing of melodic and harmonic scores may radically modify the classification.

In this discussion, we only examined tuning schemes at the top of the classification. Other schemes may be preferable when looking separately at melodic or harmonic scores — read our tutorial Tonal analysis.

## Sound examples

The automatic tonal analysis of a large repertoire matched against the whole set of tuning schemes implemented in the Bol Processor did not solve the problem of finding “the best tuning scheme” for this repertoire, as it depends on initial conditions: frequency ratios estimated “consonant” or “dissonant”, *plus the composer’s presumed focus on optimal consonance*. Nonetheless, two analyses selected 2 (or 3) tuning schemes as dominant in the classification. More analyses would be required to refine this result, if of any significance.

All sound examples are found, compared with human interpretations playing (not so well-tempered ?) physical instruments, on page The Well-tempered clavier.

These sound examples are useful to hear the difference between tuning schemes selected on the basis of the “standard” and “alternate” settings. For example, *Fugue 8 of book I *may sound more tuneful with a Dmin tuning (see image) than with Marpurg (see image). The difference might reside in the choice of convenient ratios for minor thirds.

## Is this method reliable?

As suggested by results displayed in the 4 tables for each book (see above), a few preludes and fugues ranked several tuning schemes as their favourite ones: number ‘1′ coloured red in “all results” tables. Despite this, we produced recordings for only one of the winners. How far does this matter?

Take for example *Prelude 12 of book I*. In “alternate” settings, five scales ranked first: Emin, Cmaj, BACH, d_alembert_rousseau, bethisy. We already showed that BACH and d_alembert_rousseau are almost identical despite differences in their tuning procedures. Emin and Cmaj are strictly identical. This leaves us with the following choice:

Tonal positions only differ by a few cents, which may not be noticed in melodic and harmonic intervals. Below are recordings using these three scales:

This example suggests that differences in scales ranking first may be inaudible if the widths of acceptable melodic and harmonic intervals have been set small enough to provide a well-focussed solution set.

## Listen to minor thirds

Appreciating by ear the sizes of common minor thirds may clarify the point of deciding which one is more “consonant”. Lucky users of Bol Processor BP3 only need to create the following data file:

`-cs.tryTunings`

// Harmonic minor third

_scale(2_cycles_of_fifths,0) DO3 RE#3 DO3 RE#3 DO3 RE#3 {4,DO3,RE#3}

//Pythagorean minor third

_scale(2_cycles_of_fifths,0) DO3 MIb=RE#-c3 DO3 MIb=RE#-c3 DO3 MIb=RE#-c3 {4,DO3,MIb=RE#-c3}

// Sequence harmonic then pythagorean

_scale(2_cycles_of_fifths,0) DO3 RE#3 DO3 MIb=RE#-c3 DO3 RE#3 DO3 MIb=RE#-c3 -{2,DO3,RE#3} {2,DO3,MIb=RE#-c3} {2,DO3,RE#3} {2,DO3,MIb=RE#-c3} {2,DO3,RE#3} {2,DO3,MIb=RE#-c3}

These items produce sequences of ‘C’ - ‘D#’ melodic and harmonic intervals using harmonic (6/5) and Pythagorean (32/27) minor thirds:

Listening to these examples suggests that both 6/5 and 32/27 are eligible ratios for minor thirds as “consonant” melodic intervals, whereas 6/5 sounds “softer” than 32/27 as a harmonic interval.

This demo makes use of scale “`2_cycles_of_fifths`

” described by Asselin (2000, p. 62) and implemented on a **Scale** page of Bol Processor — read pages Microtonality and Just intonation: a general framework.

The names of notes (inspired by the book, *ibid.*) sound bizarre but they make positions explicit. For instance, “Mib=RE#-c” indicates a position that is usually called *mi bémol* (E flat) and identical to *ré dièse* (D sharp) minus one comma.

This scale — and the even more complicated “`3_cycles_of_fifths`

” — is not practical to write music… It is used to visualise (and hear) tonal positions created by various tuning schemes compliant with the just intonation paradigm.

## Listen to tempered fifths

Readers unfamiliar with tuning procedures may need to appreciate tiny differences in intervals produced by temperaments created with the methods introduced on page Microtonality and fully described in Asselin (2000).

Let us listen to Pythagorean fifths in three forms: pure (frequency ratio 3/2 = 702 cents), equal-tempered (700 cents), diminished by 1/5 comma (697.3 cents) and diminished by 1/4 comma (696.2 cents).

Below is the Csound score of the last example:

i1 0.000 4.000 261.630 90.000 90.000 0.000 0.000 0.000 0.000 ; do4 i1 0.000 4.000 392.445 90.000 90.000 0.000 0.000 0.000 0.000 ; sol4 i1 4.000 4.000 261.626 90.000 90.000 0.000 0.000 0.000 0.000 ; C4 i1 4.000 4.000 391.996 90.000 90.000 0.000 0.000 0.000 0.000 ; G4 i1 8.000 4.000 261.630 90.000 90.000 0.000 0.000 0.000 0.000 ; do4 i1 8.000 4.000 391.399 90.000 90.000 0.000 0.000 0.000 0.000 ; sol-1|5c4 i1 12.000 4.000 261.630 90.000 90.000 0.000 0.000 0.000 0.000 ; do4 i1 12.000 4.000 391.137 90.000 90.000 0.000 0.000 0.000 0.000 ; sol-1|4c4

## Goldberg Variations

The same exercise has been tried on J.S. Bach’s *Goldberg Variations* (1741). The aria and its thirty variations were performed in a single sequence, obviously with the same instrument/tuning. For this reason, we checked a unique MusicXML score containing all variations.

With the “standard” hypothesis of consonance, the result is the following:

(As expected) *Sauveur’s *meantone temperament won the game, followed with *Kellner’s BACH*. The equal-tempered scale ranked 28^{th} on this classification… (Note that the computation of this table took 3 1/2 hours on an old MacBook Pro…).

➡ Listen to the synthesis of *Goldberg Variations* with * Sauveur’s* meantone temperament.

The “alternate” model of consonance yields the following classification:

Favourite tuning schemes, according to this model, would be *D’Alembert-Rousseau* (see image) and *Kellner’s BACH* (see image) meantone temperaments, both with equal ratings since their tonal intervals are almost identical.

➡ Listen to the synthesis of *Goldberg Variations* with *D’Alembert-Rousseau* temperament.

These favourite tunings are the same ones best fit to the set of preludes and fugues in *The Well-tempered Clavier*.

These sound examples may be compared with human performances, for example the Aria on a harpsichord tuned with *Werckmeister III* meantone temperament — listen to this recording. Indeed, musicians display a more flexible timing compared with Bol Processor sticking to parameters of the MusicXML score. Nonetheless, a comparison focussing on tonal intervals remains possible.

The fact that *Werckmeister III* (see image) ranked low in the automatic tonal analysis does not suggest an improper choice. This tuning scheme might rank higher against a specific model of “consonance”.

Let us figure out with calculations its main difference with *D’Alembert-Rousseau* and *Kellner’s BACH*. We may restrict the analysis to measures #1 to #32 (the *Aria*) exposing most melodic/harmonic intervals; this *Aria* works similar to the initial section (*ālāp*) in North Indian classical music… We notice that neither D - F# (397 cents) nor G - B (398 cents) in *Werckmeister III* are accurate harmonic major thirds (390 cents), intervals with high occurrence as shown on the table of interval frequencies:

The following is a comparison of scales *Werckmeister III* and *D’Alembert-Rousseau* in terms of matching *melodic* intervals (in the “alternate” model of consonance) over the 32 first measures of *Goldberg Variations*:

The widths of yellow lines are proportional to the occurrence/durations of melodic intervals in this part of the corpus. The picture confirms the absence of an accurate harmonic major third D - F# in the *Werckmeister III* scale, and the same mismatch of major third G - B. Another mismatch is on minor third E - G, here aiming at ratio 6/5 (315 cents) or 32/27 (294 cents).

## Sources of MusicXML scores

Links point at MusicXML scores used for this analysis. These links must be mentioned in the attribution part of Creative Commons licences. Upgraded versions are welcome.

*Our thanks to editors of these scores in the MuseScore community!*

The (public domain) score of Goldberg Variations has been edited by *MuseScore* lead developer Werner Schweer.

### Book I sources

1 | BWV 846 | Cmaj | Prelude | Fugue |

2 | BWV 847 | Cmin | Prelude | Fugue |

3 | BWV 848 | C#maj | Prelude | Fugue |

4 | BWV 849 | C#min | Prelude | Fugue |

5 | BWV 850 | Dmaj | Prelude | Fugue |

6 | BWV 851 | Dmin | Prelude | Fugue |

7 | BWV 852 | E♭maj | Prelude | Fugue |

8 | BWV 853 | E♭min/D#min | Prelude | Fugue |

9 | BWV 854 | Emaj | Prelude | Fugue |

10 | BWV 855 | Emin | Prelude | Fugue |

11 | BWV 856 | Fmaj | Prelude | Fugue |

12 | BWV 857 | Fmin | Prelude | Fugue |

13 | BWV 858 | F#maj | Prelude | Fugue |

14 | BWV 859 | F#min | Prelude | Fugue |

15 | BWV 860 | Gmaj | Prelude | Fugue |

16 | BWV 861 | Gmin | Prelude | Fugue |

17 | BWV 862 | A♭maj | Prelude | Fugue |

18 | BWV 863 | G#min | Prelude | Fugue |

19 | BWV 864 | Amaj | Prelude | Fugue |

20 | BWV 865 | Amin | Prelude | Fugue |

21 | BWV 866 | B♭maj | Prelude | Fugue |

22 | BWV 867 | B♭min | Prelude | Fugue |

23 | BWV 868 | Bmaj | Prelude | Fugue |

24 | BWV 869 | Bmin | Prelude | Fugue |

### Book II sources

1 | BWV 870 | Cmaj | Prelude | Fugue |

2 | BWV 871 | Cmin | Prelude | Fugue |

3 | BWV 872 | C#maj | Prelude | Fugue |

4 | BWV 873 | C#min | Prelude | Fugue |

5 | BWV 874 | Dmaj | Prelude | Fugue |

6 | BWV 875 | Dmin | Prelude | Fugue |

7 | BWV 876 | E♭maj | Prelude | Fugue |

8 | BWV 877 | D#min | Prelude | Fugue |

9 | BWV 878 | Emaj | Prelude | Fugue |

10 | BWV 879 | Emin | Prelude | Fugue |

11 | BWV 880 | Fmaj | Prelude | Fugue |

12 | BWV 881 | Fmin | Prelude | Fugue |

13 | BWV 882 | F#maj | Prelude | Fugue |

14 | BWV 883 | F#min | Prelude | Fugue |

15 | BWV 884 | Gmaj | Prelude | Fugue |

16 | BWV 885 | Gmin | Prelude | Fugue |

17 | BWV 886 | A♭maj | Prelude | Fugue |

18 | BWV 887 | G#min | Prelude | Fugue |

19 | BWV 888 | Amaj | Prelude | Fugue |

20 | BWV 889 | Amin | Prelude | Fugue |

21 | BWV 890 | B♭maj | Prelude | Fugue |

22 | BWV 891 | B♭min | Prelude | Fugue |

23 | BWV 892 | Bmaj | Prelude | Fugue |

24 | BWV 893 | Bmin | Prelude | Fugue |

## Reference(s)

Asselin, P.-Y. *Musique et tempérament*. Paris, 1985, republished in 2000: Jobert. *Soon available in English.*