
Musical works encoded on the Bol Processor (using “simple notes” as per English, Italian/Spanish/French and Indian conventions) can be analysed in terms of harmonic or melodic intervals.
Musical aspects are discussed after a description of the process.
In the final section, we present a single-click method for evaluating the adequacy of all documented tuning systems to a given musical work. A demo of this analysis is on page Bach well-tempered tonal analysis.
Basic process
This computation is launched by button ANALYZE INTERVALS at the bottom of the ‘Data’ window:

The machine found a ‘-cs.tryTunigs’ declaration on top of the data content, indicating that it should pick up definitions of tonal scales contained in that Csound resource. These definitions are only accessible if ‘-cs.tryTunigs’ has been opened less than 24 hours ago: these files are stored in the ‘temp_bolprocessor’ folder automatically cleaned up of old storage. Click the ‘open’ link if necessary.
The analytical process will be demonstrated with a single phrase of François Couperin’s Les Ombres Errantes imported from a MusicXML score — read page Importing MusicXML scores. This example is small enough for a visual check of the technical process, although too short to derive any meaningful musical interpretation of the result.
The musical item reads as follows in Bol Processor notation (English convention) — read page Polymetric structures.
-cs.tryTunings_scale(rameau_en_sib,0)
_rndtime(20) {_tempo(13/15) _vel(64){3, _legato(20) C5 _legato(0) {1/4,C5 B4 C5}{3/4,B4} _legato(20) Eb5,{1/2,Eb4}{5/2,G4 D4 F4 C4 Eb4},Eb4 D4 C4}} {_tempo(13/15) _vel(64){4, _legato(0) {1/4,Eb5 D5 Eb5}{3/4,D5} _legato(20) C5 _legato(0) {1/4,C5 B4 C5}{3/4,B4}{1/8,C5 B4}{7/8,C5},{4,B3 F4 Eb4 G4 D4 F4 C4 Eb4},B3 Eb4 D4 C4}}

Sound production made use of the Csound resource file ‘-cs.tryTunings’ in which the tonal scale ‘rameau_en_sib
’ is found — read page Comparing temperaments. This scale presumably provides the best tuning for this piece when performed on a “harpsichord-like” Csound instrument.
The machine picked up a definition of the tonal scale in a temporary copy of ‘-cs.tryTunings’. The significant content of this definition is the set of tonal positions in the scale shown on the picture — read page Microtonality.
Clicking the ANALYZE INTERVALS button yields the following display:

The table above contains a summary of matching intervals: pairs of notes played in sequence (melodic) or superposed (harmonic), with a distinction between ascending and descending melodic intervals. These matchings may be verified on the graphic display of this item:

Intervals are listed in decreasing order of relevance. Thus, melodic interval ‘C’ down to ‘B’ occured during 20.3 beats, scored highest. Ascending melodic intervals ‘B’ to ‘F’ and ‘D’ to ‘B’ are the least frequent ones. Scores below 5% of the maximum one in the column will be ignored in the graphic display.

Interestingly, the highest scores of harmonic intervals in this musical phrase are minor thirds such as ‘D’/‘B’ and ‘C’/‘Eb’. The fifth ‘C’/‘G’ is scored only 1.6 beats, which is 18% of the highest score.
The detection of a “harmonic interval” is based on comparisons of their start and end dates with options that can be modified. Let us call $start1, $end1, $start2 and $end2 the timings of two notes. We assume $start2 >= $start1 owing to a preliminary chronological sorting of the list of notes. Function matching_intervals() does the following to assess harmonic intervals:
$duration1 = $end1 - $start1;
$duration2 = $end2 - $start2;
$overlap = $end1 - $start2;
$smallest_duration = $duration1;
if($duration2 < $duration1) $smallest_duration = $duration2;
if($smallest_duration < $min_dur) return FALSE;
if($start1 + ($duration1 / 2.) < $start2) return FALSE;
if($overlap < ((1 - $ratio) * $smallest_duration)) return FALSE;
return TRUE;
This function eliminates brief overlaps of time intervals, as created for instance by slurs interpreted as _legato() performance controls when importing MusicXML scores — read details. It also eliminates notes with durations less than $min_dur optionaly set to 500 milliseconds. Thus, for instance, brief notes such as ‘C5’, ‘B4’, ‘Eb5’ etc. will be discarded. Finally, it checks that $overlap is greater than a fraction of the smallest duration, with $ratio set to 0.25 by default. Another option which is not shown here is the maximum tonal distance berween two notes, set to 11 semitones by default.
The conditions for matching melodic intervals are similar:
if($start2 > ($end1 + $max_gap)) return FALSE;
if($start1 + ($duration1 / 2.) >= $start2) return FALSE;
if($overlap >= ($ratio
* $smallest_duration)) return FALSE;
return TRUE;
Parameter $max_gap (typically 300 milliseconds) is the maximum delay between the end of the first note and the beginning of the next one.
All parameters can be modified before launching again the process. These settings will be discussed later:

Calculations

To check the sequence of time intervals in great detail it is possible to activate the “Display all dates” option yielding a detailed analysis.
All matching intervals are listed. It is not practical to use this option on large musical items…
Dates are in seconds, rounded to 0.1 s, although more accurate values are taken into account. In fact, all time calculations are performed on integer ratios, just as in Bol Processor’s console.
The result is always arguable. For instance, some melodic or harmonic intervals may appear “accidental” rather than significant.
For this and other reasons, it may be necessary to figure out more options associated with musical and performance styles.
Graphic display
Melodic and harmonic tonal intervals are displayed with the background of the tonal scale used for the performance. Here it would be ‘rameau_en_sib
’, although an equal-tempered scale would be used by default.
Clicking the links to harmonic interval images (see above picture) yields the following three graphs — in separate and resizable windows:

Intervals are shown as gold highlightings with widths proportional to their relative scores. On the leftmost picture, these golden segments are drawn behind fifths, major and minor thirds marked on the scale. For this reason the yellow highlighting of link between Eb and G, behind the green link of a harmonic major third, is less visible on the full picture.
Minor thirds (ratio 6/5) have been added in the settings. For this reason, the ones available on this scale are displayed as black segments. These additional ratios are listed on the top right of each picture.
Restricted analysis
If a MusicXML file has been imported along with measure numbers (notated [—1—], [—2—] etc.), these can be used to restrict the analysis to a subset of the score.
Below is the setting of measures #1 to #32 (the Aria) in J.S. Bach’s Goldberg Variations:

Restricting the tonal analysis to the Aria in Goldberg Variations makes sense because other variations, due to their high speed, do not display harmonic intervals longer than the minimum duration fixed in the settings (500 ms).
Musical discussion
Tonal analysis with the help of Bol Processor aims at supporting the choice of a tuning system best fitting a musical piece — a temperament as figured out by Baroque musicians. This issue is addressed on page Comparing temperaments.
We first describe a visual method for estimating (rather than measuring) the adequacy of a tuning system for the performance of musical works imported from MusicXML scores — read the page on this subject. In the next section, we will show how to compare all candidate scales in an automatic way, taking into account relevant parameters revealed in this section.
Take for instance J.S. Bach’s Prelude 1 in C major for which some historical information (reported by Asselin, 2000 p. 142) suggested the choice of a Kirnberger temperament. Which one?

The full representation of harmonic tonal intervals is shown above and matched against two different scales described by Kirnberger (Asselin, 2000 p. 90, 93). The matching looks better on the right one (Kirnberger III). For instance, interval ‘D’ - ‘A’ is closer to a “pure” fifth (702 cents) on Kirnberger III (697) than on Kirnberger II (691). Another significant matching is the harmonic major third ‘F’ - ‘A’. Other intervals are similar with respect to these scales.
A careful listening to both versions might confirm this mechanical analysis:
The same crude analysis does not yield a noticeable result for François Couperin’s Les Ombres Errantes. Harmonic interval analysis may be of less relevance because this item is globally more perceived as sequences of melodic intervals, including minor thirds and major seconds. This is visible on the graph of melodic intervals:

Matching this graph with the ‘rameau_en_sib
’ scale does not reveal interesting patterns for the simple reason that neither minor thirds nor major seconds have been taken into account on this scale in terms of “just intonation” — read page Just intonation: a general framework. Even though we may assume that a Pythagorean major second (ratio 9/8) sounds more “consonant” than a harmonic one (ratio 10/9), there is no reason for systematically asserting that the harmonic minor third (ratio 6/5) is “better” than the Pythagorean one (ratio 32/27).
The picture on the left side reveals that frequent melodic intervals of major thirds do highlight harmonic major thirds (ratio 5/4) of this scale.
We need to check intervals smaller than major thirds on tonal scales. If we instruct the machine to check intervals close (within ± 10 cents) to the harmonic minor third (ratio 6/5), the preceding graphs are displayed as follows:

The picture on the left side reveals that all minor thirds used in this performance coincide within ± 10 cents with harmonic minor thirds (ratio 6/5) of the scale, which is an incentive to admit that the ‘rameau_en_sib
’ scale would be a fair (if not the best) tuning option for Les Ombres Errantes.
A counter-example is the matching of Les Ombres Errantes with a pure-minor-thirds temperament designed during the 16th century (Asselin 2000 p. 82, see image). Below are the graphs of matching melodic (left) and harmonic (right) intervals, along with black lines marking harmonic minor thirds (ratio 6/5):

The main drawback of this ‘pure_minor_thirds’ temperament is the very low position of ‘Ab’ meant to produce a consonant sequence of minor thirds: ‘Ab’ - ‘B’ - ‘D’ - ‘F’. Yet ‘Ab’ - ‘B’ is not a melodic interval found in this piece, nor ‘Db’ - ‘E’ and ‘E’ - ‘G’ which are well rendered by the ‘pure_minor_thirds’ temperament. Mismatches are also visible on harmonic intervals — and easy to detect by listening. We may conclude that the pure minor thirds temperament is neither the best not the worst tuning system for this musical work, although comparing sound productions suggests that it is significantly less good than the ‘rameau_en_sib
’ scale.
➡ Comparing graphs is easy with the detached resizable pictures produced by the Bol Processor.
A “deaf musicologist’s” approach
The analysis shown so far replaced a comparison of sound rendering — read page Comparing temperaments — with a visual pattern-matching issue. We made it clear that musicians and instrument tuners of the Baroque period were trying to achieve consonance in terms of simple frequency ratios for fifths (close to 3/2) and harmonic major thirds (close to 5/4). This approach and its underlying assumptions are discussed on page Just intonation: a general framework.
Further, one might be tempted to assert that a “just-intonation” minor third should be harmonic (ratio close to 6/5), yet the decision should stay open. To this effect, it is possible to enter an additional set of melodic and harmonic intervals which the analyst estimates significant for the evaluation of tonal scales. Each interval is set by an integer ratio — which may be as complex as necessary.
A comparative pattern matching will assign a numeric score to every scale assessed for its fitting with the musical work. This makes it possible to sort candidate scales. Still, two separate scores are required, one for melodic and the next one for harmonic intervals. A weighed sum of scores is therefore used for sorting the list of scales.
This method has been implemented in the Tonal analysis process. We compared all scales defined in ‘-cs.tryTunings’ — containing notably all temperaments documented by Pierre-Yves Asselin — in terms of their adequacy for the rendering of melodic and tonal intervals in François Couperin’s Les Ombres Errantes:


Great result! The machine confirms that scale ‘rameau_en_sib
’ is the best candidate for the interpretation of Les Ombres Errantes. Its scores are significantly better for both melodic and harmonic intervals. (Altogether, 45 tuning schemes have been tried.)
By default, the scoring of melodic and harmonic intervals only takes into account perfect fifths (3/2) and harmonic major thirds (5/4) as “good” intervals, with respective weights of 2 and 1, and wolf fifths (40/27), wolf fourths (320/243) and Pythagorean major thirds (81/64) rated as “bad” intervals weighing respectively -2, -2 and -1. All these weights can be modified as shown on the above picture.
We repeat the comparison with the additional option of harmonic minor thirds (6/5) as melodic intervals:

Expectedly, all melodic scores increased but the winner remained. If we add the Pythagorean major second (ratio close to 9/8) we get the following:


The ‘rameau_en_sib
’ scale is now challenged by ‘sauveur’ for melodic intervals, but its harmonic score remains higher.
Note that scales Abmaj and Cmin are identical, which explains their equal scores.
A visual comparison of scales with melodic interval highlightings shows that there is little difference between these temperaments with respect to the performance of Les Ombres Errantes. Since ‘sauveur’ temperament had been designed in 1701 by the (hearing impaired?) French mathematician Joseph Sauveur, it is not unlikely that it could be used for the composition of Les Ombres Errantes in 1730.

Scale ‘rameau_en_sib
’ again scores as good as ‘sauveur’ if the Pythagorean minor third (ratio close to 32/27) is tried as a melodic interval (both ascending and descending) in replacement of ratio 6/5… This is due to the usage of ‘F’ - ‘Ab’ rendered as a Pythagorean minor third by ‘rameau_en_sib
’, yet not by ‘sauveur’.
Many more checks can be done by changing the weights assigned to occurrences of melodic and harmonic ratios. Finding the best settings requires a thorough study of the musical score — this is where human musicologists come back to the scene!
Ears (plus expertise of the score) might make a final decision:
The analytical process we are following is a kind of reverse engineering… Evidently, composers did not look for a suitable temperament after creating a musical work. It is more realistic that they composed works on existing instruments, with the effect that sets of pieces produced by the same composer (using the same instrument) at a given period obeyed implicit melodic and harmonic constraints best fitting the tuning of their instrument(s).
Comparative study
Let us examin again J.S. Bach’s Prelude 1 in C major for which Kirnberger III had (visually) been elected as a better match than Kirnberger II. Including ratios 6/5 and 9/8 in eligible melodic up/down intervals, and 6/5 as a harmonic interval, yields the following classification of tuning schemes:

The winner is undoubtedly ‘sauveur’ although the harmonic score is identical for six temperaments, yet ‘kirnberger_3′ rates much less.
Keep in mind that this has been obtained by declaring ratios close to 6/5 as eligible consonant melodic and harmonic intervals. Read page Bach well-tempered tonal analysis for a discussion of this hypothesis.
Sauveur’s temperament is the best fit because of its high proficiency in harmonic minor thirds (6/5) and Pythagorean major seconds (9/8). It also has a complete set of perfect fourths and fifths (3/2) except for the wolf fourth ‘D#’ - ‘G#’ which is close to 477 cents (instead of 498). Fortunately, this interval is never used in Bach’s piece:

This rendering can be compared (in terms of tunefulness) with a human performance on a real harpsichord:
Unsurprizingly, J.S. Bach’s Fugue 1 in C major shares the same preference for ‘sauveur’, with other tuning schemes following in a different order. All fugues in this series of works (books I and II) have been associated with preludes of the same key.
The tonal analysis of J.S. Bach’s Prelude 2 in C minor again selects ‘sauveur’ under the same evaluation criteria — including ratios 6/5 (melodic and harmonic) and 9/8 (melodic up/down). The classification is utterly different but the winner is unchanged, even though it is challenged by ‘rameau_en_sib’ for its harmonic score.

Note that the Cmin scale has a bad rate due to melodic intervals. It beats Sauveur’s temperament with respect to harmonic intervals, but these are relatively less frequent in this prelude. This classification might be quite different if some ratios (such as 9/8) are ignored for evaluating melodic intervals. Even ratios close to Pythagorean thirds (81/64) might sound acceptable in quick melodic movements — read page Bach well-tempered tonal analysis.
J.S. Bach’s Fugue 2 in C minor again selects ‘sauveur’.
We get the same result with J.S. Bach’s Prelude 6 in D minor (random choice). Note the strikingly high melodic scores of ‘sauveur’:

J.S. Bach once claimed that he could play his entire repertoire on the instrument he had tuned by himself. This sounds like squaring the circle, and many hypotheses have been advocated to solve this problem for das Wohltemperierte Clavier.
These examples suggest that Sauveur’s temperament could be Bach’s choice. Although there is little chance that the German composer (1685-1750) had heard about research work of the French physician (1653-1716), the systematic construction 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.
In order to check (and challenge) this hypothesis we completed the tonal analysis of 24 preludes and fugues in books I and II of The Well-Tempered Clavier using the same settings. Read page Bach Well-tempered tonal analysis. This large-spectrum analysis requires a device for batch processing which we describe now.
Batch processing
In order to analyse the tonality of a large number of musical works we need to create a Data page containing the names of all pages containing the Bol Processor scores of these items. For instance, page “-da.index_preludes_book_I” reads as follows:
When reading this page, the Tonal analysis procedure opens each data file and picks up the Bol Processor score it contains. To facilitate this, option Batch processing may be checked in the settings.
In the batch-processing mode, the machine will not display the whole set of tonal scales for each analysed musical work. If the score contains a specification for a tonal scale — a _scale(some_scale, 0) instruction — the list of prefered scales is displayed down to the specified one. If the specified scale comes first in the classification, the following next 2 following scales are listed. If no scale is specified, only the 10 best-matching scales are listed:

Items #2 and #3 contain the specifications of tonal scales sauveur and Dbmaj respectively.
This preference is confirmed by the analysis of item #2 but it is not the case with item #3.
At the bottom of the page, a button SHOW RESULTS displays a HTML file — which can be downloaded — containing all results:

The HTML page also displays the settings of the analysis and it can be downloaded, along with a CVS file of the same figures which lends itself to statistical graphic display.
Results for the analysis of all preludes and fugues of The Well-tempered Clavier are published and discussed on page Bach well-tempered tonal analysis.
Does it apply to western classical music?
The analysis of tonal intervals and of matchings with documented tuning systems (temperaments) makes sense with respect to Baroque music, taking for granted that composers and instrument tuners were trying to achieve a maximum consonance in the performance of their musical repertoire. The question remains open whether it produces an equally reliable (and useful) analysis of musical works in more recent periods.
Indeed, launching the analytical process is technically possible once the score has been imported to the Bol Processor. Let us try Beethoven’s Fugue in B flat major (circa 1830). We may set up harmonic major thirds (6/5) and Pyhagorean major seconds (9/8) as significant melodic intervals for the evaluation. This yields the following:

The best score — once again — is that of Sauveur’s temperament, notably owing to ascending melodic intervals. In case performers do attempt to achieve ratios 9/8, 6/5, 5/4 and 3/2, then ‘sauveur’ might be the best representation of the “tuning scheme” they have in mind.
The equal-tempered scale comes last with scores of 3529, 1680 and 240 for ascending melodic, descending melodic and harmonic intervals respectively. Part of the explanation lies in the comparison of both scales as backgrounds of harmonic intervals:

The most visible difference is the usage of almost perfect harmonic major thirds (ratio 5/4) on Sauveur’s scale (see image) instead of Pythagorean major thirds (approx. ratio 81/64) on the equal-tempered scale (see image). The former have been assigned weighs (+1) and the latter (-1). Background yellow lines indicate that these intervals are used quite often.

A drawback of Sauveur’s scale is the wolf fourth ‘D#’ - ‘G#’ (approx. 477 cents), yet this interval is not frequent on the score.
Many other remarks could be done comparing the scores of melodic intervals, and the entire process (which took almost 8 minutes) could be launched again with different settings of weighs assigning more or less importance to particular intervals. After all, we do not know whether an expert player of a stringed instrument would perform minor thirds at intervals 6/5, 32/27, tempered, or any other value, and even more whether these values depend on the harmonic/melodic context of each musical phrase.
This suggests that we shouldn’t get too excited about a (still primitive) tonal analysis tool when it comes to sophisticated tonal material…
Reference
Asselin, P.-Y. Musique et tempérament. Paris, 1985, republished in 2000: Jobert. Soon available in English.
➡ Musicians interested in continuing this research and related development may use Bol Processor BP3’s beta version to process musical works and implement more tuning procedures. Follow instructions on page Bol Processor ‘BP3’ and its PHP interface to install BP3 and learn its basic operation. Download and install Csound from its distribution page.