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 around 1722 and 1742 respectively, and the *Goldberg Variations* (1741).

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

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

It has been suggested that the best match for a scale is the tuning scheme that is appropriate for the interpretation of a musical work. This assumption is based on the hypotheses that (1) musicians and composers of the Baroque period aimed to achieve optimal ‘consonance’, and that (2) this notion implied a preference for certain intervals expressed as integer ratios. These claims are discussed on this page. Accurately tuned sound examples are suggested for auditive evaluation of the results.

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

The take-home message is that scientists should not be impressed by the accuracy and apparent consistency of machine-generated solutions. They must critically examine the initial conditions and the calculation process itself.

Ultimately, the only acceptable way to (in)validate a compositional model is to listen to the audio rendering of the results.

## “Standard” analysis

The *Well-Tempered Clavier* consists of two books, each containing 24 preludes and 24 fugues in all conventional key signatures. In total, this analysis covered 96 musical works (presumably) written by the same composer under (presumably) similar conditions.

Our first analysis is based on the following settings of intervals estimated to be *consonant* or *dissonant*:

The analysis of ascending and descending melodic intervals looks for common frequency ratios close to 3/2 (Pythagorean fifths) and 5/4 (harmonic major thirds), which are widely regarded as ‘consonant’. It also includes the ratios 6/5 (harmonic minor thirds) and 9/8 (Pythagorean major seconds), which can be considered optimal. Other ratios are often considered ‘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 — see page Just intonation: a general framework.

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

Each melodic interval found in the musical work will be sized according to the same interval in the scale being tested for compatibility. For example, 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 the ratio 32/27 (Pythagorean minor third). If this ratio appears in the settings, the scale value is increased by the weight of the ratio multiplied by the (symbolic) duration of the interval — see Tonal Analysis of Musical Works for details of this procedure.

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

The scores for ascending and descending melodic intervals are then added to the score for harmonic intervals, with weights of 1, 1 and 2 respectively. This weighting may be modified if “consonance” is expected to be greater for melodic than for harmonic intervals, or if ascending and descending melodic intervals are not considered equally important.

Each scale is given a mark if it is found to be the best match for a piece of music. Counting these marks over the entire repertoire gives the best tuning scheme(s) for that repertoire.

Results are stored in tables that can be downloaded in both HTML and CSV formats. The initial settings are recalled 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 to a given musical work. For example, in the fugues of book I, *Corette’s temperament* (column corrette) was ranked 6^{th} for the 5^{th} fugue, and the best match for this piece was the *Sauveur’s temperament* (column sauveur).

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

Abstract tables show the list of first ranked tuning schemes for each musical work.

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

## Discussion of the standard analysis

Of of these 96 musical works, 56 chose ‘sauveur’ as their favourite tuning scheme, plus 9 as their second favourite. This temperament strikingly dominates the classification because of its ability to produce 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) which is perceived as a dissonant interval. The assumption is that these two notes are never (or rarely) found in melodic or harmonic intervals in this repertoire. This illustrates the fact that there is no *one-size-fits-all* solution to the problem of tuning an instrument for this type of music. In a “reverse engineering” sort of way, we can say that the composer explored melodic and harmonic pleasing effects in order to build this repertoire: playing on the instrument before notating it on sheets of music sheets.

As suggested in our tutorial, there is no evidence that J.S. Bach was aware of the theoretical work by the 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 could work it out independently. This process has been recorded on the Bol Processor’s **Scale** page as follows:

`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 that equate to the key — for example, Abmin (i.e. G#min) for Fugue 18 in G♯ minor, Book II (BWV 887) — were often at the top of the popular tuning schemes, but in most cases were overtaken by several temperaments. For more details on these scales, see our page Creation of just-intonation scales.

In all cases, the 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 was intended to equate ‘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 (see Asselin, 2000) whereas “just intonation” is the result of

*speculation*about numerical ratios — a

*process. This brings us back to a discussion of the ancient Indian approach to tonality, see 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 intended to be performed on instruments tuned to *Sauveur’s temperament*. However, the result of any analysis must always be examined for bias in its hypotheses. In the present case, we must revise the choice of certain frequency ratios as criteria for assessing the ‘consonance’ of melodic and harmonic intervals.

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

The same observation applies to major thirds: although 5/4 (harmonic) certainly sounds 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 the whole analysis again with these changed 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

The results contradict the conclusion of the ‘standard’ analysis: *Sauveur’s temperament* might not be such a good choice, given the alternative choice of ratios for consonant/dissonant melodic and harmonic intervals.

According to these settings, the best tuning schemes might be the *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 were designed after J.S. Bach’s death, but similar or identical tuning procedures could have been devised by the composer.

A comparison of the images and cent positions (identical within ± 7 cents) explains why these two temperaments produced identical matches, despite their completely 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 are not exactly the same as those described by Asselin (2000, pp. 120 and 102), but they produce 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, taking first place 65 times and second place 15 times, while equal temperament, despite its mastery of Pythagorean major thirds, only took first place 21 times. Compared to *Sauveur’s temperament* in the standard analysis (56 first positions and 9 second positions), these temperaments look ‘better’, but *this comparison is irrelevant since the two analyses focused on different ratios*.

The 33 Preludes and Fugues that do not conform to these temperaments often prefer a just intonation scale in the same key; for example, *Prelude 8 in E♭ minor* of Book I (BWV 853) chooses the Ebmin scale, and *Prelude 9 in E major* of Book I (BWV 854) chooses the Emaj scale. However, this matching is less common in the “dissident” fugues.

More advanced analysis is required. Note that changing the weighting of intervals or the weighting in the summation of melodic and harmonic scores can radically change the classification.

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

## Sound examples

The automatic tonal analysis of a large repertoire, compared with 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, since it depends on the initial conditions: frequency ratios estimated as “consonant” or “dissonant”, *plus the composer’s presumed focus on optimal consonance*. Nevertheless, two analyses selected 2 (or 3) tuning schemes as dominant in the classification. Further analysis would be required to refine this result, if it is significant.

All sound examples are compared with human interpretations on (not so well-tempered?) physical instruments on the 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 melodius with a Dmin tuning (see image) than with a Marpurg tuning (see image). The difference may be in the choice of the most convenient ratios for minor thirds.

## Is this method reliable?

As the results shown in the 4 tables for each book (see above) suggest, some preludes and fugues ranked several tuning schemes as their favourite: number ‘1′ is coloured red in the ‘all results’ tables. However, we only made recordings for one of the winners. What does this mean?

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

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

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

## Listen to minor thirds

Judging the sizes of the common minor thirds by ear may make it easier to decide which is more “consonant”. Lucky users of the 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 suitable ratios for minor thirds as “consonant” melodic intervals, while 6/5 sounds “softer” than 32/27 as a harmonic interval.

This demo uses the scale “`2_cycles_of_fifths`

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

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

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

” — is not practical for writing music… It is used to visualise (and hear) tonal positions produces by different tuning schemes that conform to the just intonation paradigm.

## Listen to tempered fifths

Readers unfamiliar with tuning procedures may need to appreciate the tiny differences in intervals produced by temperaments created using the methods introduced on the Microtonality page and described in detail 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 was attempted with J.S. Bach’s *Goldberg Variations* (1741). The aria and its thirty variations were performed in a single sequence, apparently with the same instrument/tuning. For this reason, we checked a unique MusicXML score containing all the variations.

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

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

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

The “alternate” model of consonance gives 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 of which have equal value because their tonal intervals are almost identical.

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

These favourite tunings are the same as those best suited to the set of preludes and fugues in *The Well-Tempered Clavier*.

These sound examples can be compared to human performance, for example the Aria on a harpsichord tuned to the *Werckmeister III* meantone temperament — listen to this recording. In fact, the musicians show a more flexible timing than the Bol Processor, which sticks to the parameters of the MusicXML score. Nevertheless, a comparison focusing on tonal intervals remains possible.

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

Let us use calculations to work out its main difference from *D’Alembert-Rousseau* and *Kellner’s BACH*. We can limit the analysis to bars #1 to #32 (the *Aria*), which exposes most of the melodic/harmonic intervals; this *Aria* functions similarly to the opening 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 exact harmonic major thirds (390 cents), intervals with a high frequency as shown in the table of interval frequencies:

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

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

## Sources of MusicXML scores

Links point to MusicXML scores used in this analysis. These links must be cited in the attribution part of Creative Commons licences. Updated versions are welcome.

*Our thanks to the 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.*