👉 An earlier version of this page recommended w64devkit. This was a wrong choice, as its downloadable files are signalled with viruses or malicious code.
Look at the warning displayed at the top right of any page of the Bol Processor. In the Windows environment you can read:
The installation of MinGW will allow "gcc" to run on a Windows machine. This may not be necessary if it has already been installed by another application. In this case, there will be no such warning at the top right of Bol Processor pages:
Clicking on the "run the compiler" link will create the "bp.exe" console. After reloading the page you are ready to use BP3:
If you get a warning that the file may contain malicious code, don't take the risk. Try another file!
Install MinGW-w64:
Open the MinGW file with 7-Zip, telling it to extract files and store them to a folder, by default "x86_64-13.2.0-release-win32-seh-ucrt-rt_v11-rev0" in your Downloads folder.
Save the path to this folder in a text file, for instance (if the user is named "berna"): C:\Users\berna\Downloads\x86_64-13.2.0-release-win32-seh-ucrt-rt_v11-rev0\mingw64
👉 For geeks and expert Windows users: It is not good practice to keep executable files in the Downloads folder, as they may be deleted when optimising disk space. You should move them to a suitable location like other applications. I keep the Downloads location for the demo.
Set up the Environment Path:
Right-click on 'This PC' or 'Computer' on the desktop or in File Explorer, and select 'Properties'.
Click on 'Advanced system settings' and then 'Environment Variables'.
In the System Variables section, find and select the variable 'Path', then click on 'Edit'.
Click on 'New' and add the path to the directory 'bin' of your MinGW-w64 installation, such as "C:\Users\berna\Downloads\x86_64-13.2.0-release-win32-seh-ucrt-rt_v11-rev0\mingw64\bin" if you haven't changed the location.
Click 'OK' to close all dialogues.
Verify Installation:
👉 The BP3 interface does this verification automatically. If ‘gcc’ responds you will be offered to (re)compile the console. The following instructions are for an additional check.
Open Command Prompt (cmd.exe) and type: cd C:\MinGW\bin gcc --version
The first command opens a Unix "shell". The second command should output the GCC version installed and include 'x86_64', indicating it's set up for 64-bit. Ignore the win32 segments you see in file and folder names. They are there to confuse you!
Additional Tips
Choosing a Shell: MinGW-w64 works with standard Windows command prompt and also with more Unix-like terminals like Git Bash or Cygwin if those are already installed.
Using Make: To use 'make' with MinGW-w64, make sure that package 'mingw32-make' is selected during installation. It might be named differently like 'mingw-w64-make' based on the version. You might need to rename 'mingw32-make.exe' to 'make.exe' in the bin directory to make it recognizable as 'make'.
By following these steps, you should be well-equipped to compile 64-bit applications — not only BP3 — using GCC on Windows via MinGW-w64. This setup is useful for developers who need a lightweight GCC environment without needing a full Linux setup or the bulk of Visual Studio.
Kippen, James & Bernard Bel (1989) https://hal.science/hal-00275429v1 Can a computer help resolve the problem of ethnographic description? Anthropological Quarterly, 62 (3): 131-144.
Bel, Bernard (1990) https://theses.hal.science/tel-00009692 Acquisition et représentation de connaissances en musique (Knowledge acquisition and representation in music) Thèse de doctorat en sciences. Université de droit, d'économie et des sciences - Aix-Marseille III.
Kippen, James & Bernard Bel (1992) https://hal.science/halshs-00004506v1 Modelling music with grammars: formal language representation in the Bol Processor. In A. Marsden & A. Pople (eds.) Computer Representations and Models in Music, London, Academic Press, 1992: 207-238.
Kippen, James & Bernard Bel (1992) https://hal.science/hal-00256386v1 Bol Processor Grammars. In Mira Balaban, Otto Laske et Kemal Ebcioglu (eds.) Understanding Music with AI, American Association for Artificial Intelligence Press, Menlo Park CA: 366-400.
Kippen, James & Bernard Bel (1992) https://bp3.tech/two-algorithms/ Symbolic and sonic representations of sound-object structures. In Mira Balaban, Otto Laske et Kemal Ebcioglu (eds.) Understanding Music with AI, American Association for Artificial Intelligence Press, Menlo Park CA: 64-110.
Kippen, James & Bernard Bel (1992) https://hal.science/hal-00256385v1 Modelling improvisatory and compositional processes. In Denise Penrose & Ray Lauzanna (eds.) Languages of Design, 1. Elsevier Science Publishers, Amsterdam: 11-26.
Bel, Bernard (1992) https://bp3.tech/time-setting-of-sound-objects/ Time-setting of sound-objects: a constraint-satisfaction approach. International Workshop on Sonic Representation and Transform, Trieste (Italy), 26-30 October.
Bel, Bernard (1998) https://hal.science/hal-00250274 Migrating Musical Concepts - an overview of the Bol Processor. Computer Music Journal, Vol. 22, 2: 56-64.
Bel, Bernard (2001) https://bp3.tech/rationalizing-musical-time/ Rationalizing musical time: syntactic and symbolic-numeric approaches. In Clarence Barlow, (ed.) The Ratio Book. Den Haag: Royal Conservatory - Institute of Sonology: 86-101.
QAVAID
Kippen, James & Bernard Bel (1989) https://hal.science/halshs-00004505 The identification and modelling of a percussion ‘language,’ and the Emergence of Musical Concepts in a machine-learning experimental set-up. Computers and the Humanities, 23 (3): 119-214.
Bel, Bernard (1990) https://hal.science/hal-00275789v2 Inférence de langages réguliers. Journées Françaises de l'Apprentissage, Lannion, France : 5-27.
Modelling music with grammars: formal language representation in the Bol Processor. In A. Marsden & A. Pople (eds.): Computer Representations and Models in Music, London, Academic Press, 1992, p. 207-238.
Abstract
Improvisation in North Indian tabla drumming is similar to speech insofar as it is bound to anunderlying system of rules determining correct sequences. The parallel is further reinforced by the fact that tabla music may be represented with an oral notation system used for its transmission and, occasionally, performance. Yet the rules are implicit and available only through the musicians’ ability to play correct sequences and recognise incorrect ones. A linguistic model of tabla improvisation and evaluation derived from pattern languages and formal grammars has been implemented in the Bol Processor, a software system used in interactive fieldwork with expert musicians. The paper demonstrates the ability of the model to handle complex structures by taking real examples from the repertoire. It also questions the relevance of attempting to model irregularities encountered in actual performance.
Pattern grammars in formal representations of musical structures. 11th International Joint Conference on Artificial Intelligence, Workshop on AI & Music, 20 August 1989, p.113-42
Abstract
This paper introduces several formal models of pattern representation in music. Polyvalent multimodal grammars describe partially overlapping sound events as found in polyphonic structures. Bol Processor grammars are characterisations of sequential events in terms of substring repetitions, homomorphisms, etc. Parsing techniques, stochastic production and recent developments of BP grammars are briefly described.
Time-setting of sound-objects: a constraint-satisfaction approach. Invited paper, Workshop on Sonic Representations and Transforms. INTERNATIONAL SCHOOL FOR ADVANCED STUDIES (ISAS), Trieste, 26-30 October 1992.
Abstract
This paper deals with the scheduling of “sound-objects”, hereby meaning predefined sequences of elementary tasks in a sound processor, with each task mapped to a time-point. Given a structure of sound-objects completely ordered in a phase diagram, an “instance” of the structure may be obtained by computing the dates at which each task should be executed. Time-setting the structure amounts to solving a system of constraints depending on (1) metric and topological properties of sound-objects, (2) contexts in which they are found, and (3) parameters related to the performance itself (“smooth” or “striated” time, speed, etc.). This may require relocating/truncating objects or delaying part of the sound-object structure. A constraint-satisfaction algorithm is introduced, the time complexity of which is O(n.k) in most cases, where n is the number of sequences and k the maximum length of a sequence. In the worst case it remains better than O(n2.k3). Other fields of applications are proposed, including multimedia performance and computer-aided video editing.
Below is the complete set of Preludes and Fugues by J.S. Bach known as The Well-Tempered Clavier, Books II and II, published around 1722 and 1742 respectively.
What was the composer's intention when he used the term "well tempered"?
The matching algorithm selected the tuning scheme(s) that best matched the definitions of 'consonant' and 'dissonant' melodic and harmonic intervals. Two sets of definitions were used: "standard" and " alternative". Obviously, under any hypothesis, some tuning schemes are more suitable than others for achieving the composer's presumed perception of 'consonance'. Therefore, the following sound productions of the Preludes and Fugues, with their "best" tuning schemes, should not be taken as a definitive answer to the question of temperament discussed by Bach's students and followers. They may, however, come closest to what the composer intended, within the limits of the ear's ability to discriminate between intervals.
Note that if several tuning schemes ranked first for matching a piece, only one of them was used for the demo. It is possible that another may sound better.
All the pieces were played and recorded on a Csound instrument, similar to a harpsichord, allowing a clear appreciation of the tonal intervals. This kind of "magnifying glass" view of the tonal intervals produced harsh sounding versions, available in the Standard (raw) and Alternate (raw) folders. These have been post-processed with a bit of reverb to produce softer attacks. The post-processed sound files are the ones accessed in the tables below. Readers familiar with sound editing are invited to download the raw files and suggest better post-processing options.
The last two columns of each table contain recordings of human interpretations of the same works by outstanding harpsichordists. These explore dimensions of musicality that the mechanical interpretation of the score with perfect tonal intervals could not reach. It remains that the challenge of accurate tonality was a priority for this corpus, as evidenced by the title "well-tempered" given by its composer.
Book I sound examples
These Bol Processor + Csound recordings may be reused under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) licence. Attribution includes links to the present page, to Csound and to the author/editor of its MusicXML score (listed on the Bach Well-tempered tonal analysis page).
➡ Listen with headphones or a very good sound system!
As explained on the Bach Well-tempered tonal analysis page, the D'Alambert-Rousseau temperament was found to be equivalent to H.A. Kellner's BACH in terms of scale intervals.
➡ Listen to the synthesis of Goldberg Variations with Sauveur's meantone temperament. ➡ Listen to the synthesis of Goldberg Variations with D'Alembert-Rousseau temperament. ➡ Listen to the Aria on a harpsichord tuned with Werckmeister III meantone temperament.
In the same period (1730), the French musician François Couperin composed Les Ombres Errantes, for which our tonal analysis suggests a Rameau en sib temperament:
Conclusive remarks
The title of this corpus, The Well-Tempered Clavier, suggests that its composer intended to demonstrate the suitability of one or more temperaments for the performance of musical works in any tonality. As previously stated, this does not imply that they were all intended to conform to the same unique solution; however, it is tempting to hypothesize that the same instrument and tuning scheme were utilized for the entirety of the set. This has led to speculation by J.S. Bach's pupils, who were not instructed on how to proceed. Part of the reputation of great artists in those days was based on the withholding of information.
It would be illogical in the context of human musicians and physical instruments to play a prelude in one tuning and then retune the instrument solely for the purpose of playing the fugue. Consequently, these audio examples are not intended to emulate a genuine performance. They can, however, assist in evaluating the suitability of a preferred tuning scheme for each musical work.
A "deaf musicologist" employs a method of tonality assessment that involves measuring melodic and harmonic intervals in terms of frequency ratios. The results of this assessment depend on the values (weights) assigned to certain ratios in advance. Our findings demonstrate that equally meaningful sets of hypotheses can lead to completely different results, which only trained ears can distinguish. The combination of hypotheses may not elucidate the situation. An apparent preference for a tuning scheme may be the result of a numerical artefact rather than proof of its validity.
A meticulous listening to these recordings, with the exclusion of the somewhat inelegant rendering of fast trills in the lower octave, reveals a musical dimension that cannot be reduced to the concept of 'intervals'. Each piece can be likened to a precious stone, exhibiting an astonishing regularity in its structure. The listener is invited by the artist to explore all sides of the crystal and to appreciate its purity: a 'tonal landscape'. In this approach, the slightest imperfection, such as a few cents up or down, is amplified by the structure. In short, the most important feature may be less the choice of a structure than its consistency in rendering each musical phrase.
It is uncertain whether J.S. Bach had a specific, unique musical temperament in mind when he composed The Well-Tempered Clavier. This is because the highest rating in terms of intervals may not be the most appropriate. This question remains open to art historians and musicologists. However, from the sound examples, it is evident that playing this repertoire on improperly tuned instruments — in terms of consonance — is tantamount to exposing plastic imitations of diamonds.
Reference(s)
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 can use the Bol Processor BP3 to process musical works and implement further tuning procedures. Follow the instructions on the Bol Processor ‘BP3’ and its PHP interface page to install BP3 and learn its basic operation. Download and install Csound from its distribution page.
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).
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 the 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 which we note 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 the usual 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 the Just intonation: a general framework page.
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 wolfish 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). When 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.
Each cell in the "all results" table indicates the rank of a given tuning scheme (scale) that matches a given musical work. For example, in the fugues of book I, Corette's temperament (column corrette) was ranked 6th for the 5th 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. It is assumed 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 kind of "reverse engineering", 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 of 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 corresponding 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 on the 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 deductive process. This brings us back to a discussion of the ancient Indian approach to tonality, see the page on The two-vina experiment.
“Alternate” analysis
At this stage, it is tempting to conclude that J.S. Bach's The Well-Tempered Clavier was intended to be played 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 in question 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:
The results contradict the conclusion of the 'standard' analysis: Sauveur's temperament may 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 picture and read Asselin, 2000 p. 119) and H.A. Kellner's BACH temperament (see picture 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
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, p. 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 the equal temperament, despite its mastery of Pythagorean major thirds, took first place only 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 as 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 "alternative" settings. For example, Fugue 8 of book I may sound more melodious with a Dmin tuning (see illustration) than with a Marpurg tuning (see illustration). The difference may lie 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 recorded 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 the differences in their tuning procedures. Emin and Cmaj are exactly the same. 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:
-to.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}
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.
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 produced 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).
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 came 28th 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 "alternative" model of consonance gives the following classification:
Favourite tuning schemes, according to this model, would be D'Alembert-Rousseau (see picture) and Kellner's BACH (see picture) 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 preferred 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 indicate a wrong choice. This tuning scheme may 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 width of the yellow lines is 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!
Musical works encoded in the Bol Processor (using "simple notes" according to English, Italian/Spanish/French and Indian conventions) can be analysed in terms of harmonic or melodic intervals.
The musical aspects are discussed after a description of the process.
In the final section, we present a one-click method for evaluating the suitability of all documented tuning systems for a given piece of music. A demo of this analysis can be found on the Bach well-tempered tonal analysis.
Basic process
This calculation is started by pressing the ANALYZE INTERVALS button at the bottom of the 'Data' window:
The machine found a '-to.tryTunigs' declaration at the top of the data content, indicating that it should pick up the scale definitions contained in this tonality resource. These definitions are only accessible if '-to.tryTunigs' was opened less than 24 hours ago: these files are stored in the 'temp_bolprocessor' folder which is automatically cleaned up of old storage. Click on the 'open' link if necessary.
The analytical process is demonstrated using a single phrase of François Couperin's Les Ombres Errantes imported from a MusicXML score — see the Importing MusicXML scores page. This example is small enough to allow a visual check of the technical process, but too short to allow a meaningful musical interpretation of the result.
In Bol Processor notation (English convention), the musical item reads as follows — read the Polymetric structures page:
The sound production used the tonality resource file '-to.tryTunings' which contains the tonal scale 'rameau_en_sib' — see the page Comparing temperaments. This scale probably provides the best tuning for this piece when played on a "harpsichord-like" Csound instrument.
The machine has picked up a definition of the tonal scale in a temporary copy of '-to.tryTunings'. The essential content of this definition is the set of tonal positions in the scale shown in the image — see the Microtonality page.
Click on the ANALYZE INTERVALS button and the following screen appears:
The table above gives a summary of matching intervals: pairs of notes played one after the other (melodic) or one above the other (harmonic), distinguishing between ascending and descending melodic intervals. These matches can be checked in the graphical representation of this item:
Intervals are listed in descending order of importance. For example, the melodic interval 'C' to 'B' occurs in 20.3 beats, the highest number. Ascending melodic intervals 'B' to 'F' and 'D' to 'B' are the least frequent. Values less than 5% of the maximum in the column are ignored in the graphical 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 the comparison of its start and end dates with options that can be modified. Let $start1, $end1, $start2 and $end2 be the timings of two notes. We assume $start2 >= $start1 due to a preliminary chronological sorting of the list of notes. The matching_intervals() function does the following to evaluate harmonic intervals:
This function eliminates brief overlaps of time intervals, such as those created by slurs interpreted as _legato() performance controls when importing MusicXML scores — see details. It also eliminates notes with durations less than $min_dur, optionally set to 500 milliseconds. For example, short notes such as 'C5', 'B4', 'Eb5', etc., are 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, not shown here, is the maximum tonal distance between two notes, which is set to 11 semitones by default.
The conditions for matching melodic intervals are similar:
The $max_gap parameter (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 changed before the process is restarted. These settings are 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 will be listed. It is not practical to use this option on large pieces of music…
Dates are in seconds, rounded to 0.1s, although more accurate values are used. In fact, all time calculations are based on whole numbers, as in the Bol Processor console.
The result is always debatable. For example, some melodic or harmonic intervals may appear "accidental" rather than significant.
For this and other reasons, it may be necessary to explore other options related to musical and performance styles.
Graphic display
Melodic and harmonic tonal intervals are displayed against the background of the tonal scale used for the performance. Here it would be 'rameau_en_sib', although by default an equal-tempered scale is used.
Clicking on the links to the harmonic interval pictures (see image above) will bring up the following three graphs — in separate and resizable windows:
Intervals are shown as gold highlights with widths proportional to their relative values. In the left-hand image, these golden segments are drawn behind the fifths, major and minor thirds marked on the scale. For this reason, the yellow highlighting of the link between Eb and G, behind the green link of a harmonic major third, is less visible in the full image.
Minor thirds (ratio 6/5) have been added to the settings. For this reason, those available in this scale are shown as black segments. These additional ratios are listed at the top right of each image.
Restricted analysis
If a MusicXML file has been imported along with bar numbers (notated [—1—], [—2—] etc.), these can be used to restrict the analysis to a subset of the score.
Below is the setting of bars #1 to #32 (the Aria) in J.S. Bach's Goldberg Variations:
Restricting the tonal analysis to the Aria in the Goldberg Variations makes sense because other variations, due to their high speed, do not show harmonic intervals longer than the minimum duration fixed in the settings (500 ms).
Musicological discussion
Tonal analysis with the Bol Processor aims to help choose the most appropriate tuning system for a piece of music — a temperament as defined by Baroque musicians. This topic is covered on the 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 topic. In the next section, we will show how to automatically compare all candidate scales, taking into account the relevant parameters revealed in this section.
Take, for example, J.S. Bach's Prelude 1 in C major for which some historical information (reported by Asselin, 2000 p. 142) suggests the choice of a Kirnberger temperament. Which one?
The full representation of the harmonic intervals is shown above and compared with two different scales described by Kirnberger (Asselin, 2000 p. 90, 93). The match looks better on the right (Kirnberger III). For example, the interval 'D' - 'A' is closer to a "pure" fifth (702 cents) on Kirnberger III (697) than on Kirnberger II (691). Another significant match is the harmonic major third 'F' - 'A'. Other intervals are similar in terms of these scales.
A careful listening to both versions might confirm this mechanical analysis:
For François Couperin's Les Ombres Errantes, the same crude analysis yields no significant result. Harmonic interval analysis may be less relevant because this piece is more generally perceived as a sequence of melodic intervals, including minor thirds and major seconds. This can be seen in the graph of melodic intervals:
Comparing this graph with the 'rameau_en_sib' scale does not reveal any interesting patterns, for the simple reason that neither minor thirds nor major seconds have been taken into account in this scale in terms of "just intonation" — see page Just intonation: a general framework. Although we can assume that a Pythagorean major second (ratio 9/8) sounds more "consonant" than a harmonic one (ratio 10/9), there is no reason to systematically claim that the harmonic minor third (ratio 6/5) is "better" than the Pythagorean one (ratio 32/27).
The picture on the left shows that the frequent melodic intervals of major thirds emphasise the harmonic major thirds (ratio 5/4) of this scale.
We need to check intervals smaller than the major third in the tonal scales. If we tell the machine to check intervals close (within ± 10 cents) to the harmonic minor third (ratio 6/5), the above graphs will look like this:
The picture on the left side shows that all the minor thirds used in this performance coincide within ± 10 cents with the 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 (perhaps the best) tuning option for Les Ombres Errantes.
A counter-example is the matching of Les Ombres Errantes with a pure-minor-thirdstemperament designed during in 16th century (Asselin 2000 p. 82, see figure). Below are the graphs of the matching melodic (left) and harmonic (right) intervals, with black lines marking the harmonic minor thirds (ratio 6/5):
The main drawback of this 'pure_minor_thirds' temperament is the very low position of 'Ab' which is supposed to produce a consonant sequence of minor thirds: 'Ab' - 'B' - 'D' - 'F'. However, 'Ab' - 'B' is not a melodic interval found in this piece, nor are 'Db' - 'E' and 'E' - 'G', which are well represented by the 'pure_minor_thirds' temperament. There are also discrepancies in the harmonic intervals, which are easy to hear. We can conclude that the pure minor thirds temperament is neither the best nor the worst tuning system for this musical work, although the comparison of 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 has replaced a comparison of sound rendering — see the page Comparing temperaments — with a visual problem of pattern-matching. We have shown that Baroque musicians and tuners sought 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 the page Just intonation: a general framework.
Furthermore, one might be tempted to claim that a "just intonation" minor third should be harmonic (ratio close to 6/5), but the decision should remain open. To this end, it is possible to enter an additional set of melodic and harmonic intervals that the analyst considers significant for the evaluation of tonal scales. Each interval is defined by an integer ratio — which can be as complex as necessary.
Comparative pattern matching assigns a numerical score to each scale that has been evaluated for its fit with the musical work. This allows the candidate scales to be sorted. However, two separate scores are required, one for melodic intervals and one for harmonic intervals. A weighted sum of scores is therefore used to sort the list of scales.
This method has been implemented in the Tonal analysis process. We have compared all the scales defined in '-to.tryTunings' — including in particular all the temperaments documented by Pierre-Yves Asselin — in terms of their suitability for the rendering of melodic and tonal intervals in François Couperin's Les Ombres Errantes:
Great result! The machine confirms that the 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. (A total of 45 tuning schemes were tried.)
By default, the evaluation of melodic and harmonic intervals considers only perfect fifths (3/2) and harmonic major thirds (5/4) as "good" intervals, with weights of 2 and 1 respectively, and wolf fifths (40/27), wolf fourths (320/243) and Pythagorean major thirds (81/64) as "bad" intervals, with weights of -2, -2 and -1 respectively. All these weights can be modified as shown in the image above.
We repeat the comparison with the additional option of harmonic minor thirds (6/5) as melodic intervals:
As expected, all the melodic values 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 markings shows that there is little difference between these temperaments in terms of the performance of Les Ombres Errantes. Since the 'sauveur' temperament was designed in 1701 by the (hearing-impaired?) French mathematician Joseph Sauveur, it is not unlikely that it was used for the composition of Les Ombres Errantes in 1730.
The scale 'rameau_en_sib' again scores as good as 'sauveur' when the Pythagorean minor third (ratio close to 32/27) is tried as a melodic interval (both ascending and descending) in place of the ratio 6/5… This is due to the use of 'F' - 'Ab', which is rendered as a Pythagorean minor third by 'rameau_en_sib', but not by 'sauveur'.
Many more checks can be made by changing the weights assigned to the occurrences of melodic and harmonic ratios. Finding the best settings requires a thorough study of the musical score — this is where human musicologists come in!
Ears (plus expert knowledge of the score) could make the final decision:
The analytical process we are following is a kind of reverse engineering… Obviously, composers did not search for a suitable temperament after creating a musical work. It is more realistic to assume 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 time obeyed implicit melodic and harmonic constraints that best suited the tuning of their instrument(s).
Comparative study
Let us look again at J.S. Bach's Prelude 1 in C major, for which Kirnberger III was chosen (visually) as a better match than Kirnberger II. Including the ratios 6/5 and 9/8 as possible melodic up/down intervals, and 6/5 as a harmonic interval, the following classification of tuning schemes emerges:
The winner is undoubtedly 'sauveur' although the harmonic score is identical for six temperaments, but 'kirnberger_3' scores much lower.
Note that this was achieved by declaring ratios close to 6/5 as possible consonant melodic and harmonic intervals. For a discussion of this hypothesis, see Bach well-tempered tonal analysis for a discussion of this hypothesis.
Sauveur's temperament is the best suited 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 almost 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:
Unsurprisingly, 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 of the fugues in this series of works (books I and II) are associated with preludes in the same key.
The tonal analysis of J.S. Bach's Prelude 2 in C minor again selects 'sauveur' using the same evaluation criteria — including the ratios 6/5 (melodic and harmonic) and 9/8 (melodic up/down). The scoring is completely different, but the winner is unchanged, although it is challenged by 'rameau_en_sib' for its harmonic score.
Note that the Cmin scale has a bad rate because of the melodic intervals. It beats Sauveur's temperament in terms of harmonic intervals, but these are relatively rare in this prelude. This classification could be quite different if some ratios (such as 9/8) were ignored for the evaluation of melodic intervals. Even ratios close to Pythagorean thirds (81/64) may sound acceptable in fast melodic movements — see the page on Bach well-tempered tonal analysis.
J.S. Bach's Fugue 2 in C minor again favours '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 put forward to solve this problem for das Wohltemperierte Clavier.
These examples suggest that Sauveur's temperament may have been Bach's choice. Although there is little chance that the German composer (1685-1750) would have heard of the 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 could have worked it out independently.
To test (and challenge) this hypothesis, we have undertaken a tonal analysis of 24 preludes and fugues from books I and II of The Well-Tempered Clavier using the same settings. Read the Bach Well-tempered tonal analysis page. This large spectrum analysis requires a batch processing device, which we will now describe.
Batch processing
To analyse the tonality of a large number of musical works, we need to create a Data page containing the names of all the pages containing the Bol Processor scores of these items. For example, the page “-da.index_preludes_book_I” is 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, the Batch processing option can be checked in the settings.
In the batch-processing mode, the machine will not display the full set of scales for each piece of music analysed. If the score contains a specification for a tonal scale — a _scale(some_scale, 0) instruction — the list of preferred scales will be displayed down to the specified one. If the specified scale is the first in the ranking, then the next two following scales are listed. If no scale is given, only the 10 best matching scales are listed:
At the bottom of the page, a SHOW RESULTS button displays a downloadable HTML file containing all the results:
The HTML page also shows the settings for the analysis, and can be downloaded, along with a CVS file of the same figures, which is suitable for statistical graphing.
The results of the analysis of all the preludes and fugues of The Well-tempered Clavier are published and discussed on the page Bach well-tempered tonal analysis.
Does it apply to western classical music?
The analysis of tonal intervals and their correspondence to documented tuning systems (temperaments) makes sense in the context of Baroque music, assuming that composers and instrument tuners sought to achieve maximum consonance in the performance of their musical repertoire. The question remains whether it is equally reliable (and useful) for the analysis of musical works from more recent periods.
The best score — once again — is that of Sauveur's temperament, mainly because of the ascending melodic intervals. If performers are trying to achieve ratios 9/8, 6/5, 5/4 and 3/2, then ‘sauveur’ may be the best representation of the "tuning scheme" they have in mind.
The equal temperament 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 the two scales as a background to the harmonic intervals:
The most obvious difference is the use of almost perfect harmonic major thirds (ratio 5/4) on Sauveur's scale (see image) instead of Pythagorean major thirds (approximately ratio 81/64) on the equal tempered scale (see image). The former have been assigned weights (+1) and the latter (-1). Yellow background lines indicate that these intervals are used quite frequently.
One drawback of Sauveur's scale is the wolf fourth 'D#' - 'G#' (approx. 477 cents), but this interval does not occur frequently in the score.
Many other observations could be made, comparing the values of the melodic intervals, and the whole process (which took almost 8 minutes) could be started again with different settings of the weights, giving more or less importance to certain intervals. After all, we do not know whether an expert player of a string instrument would play minor thirds at intervals of 6/5, 32/27, tempered, or some other value, and even more so, 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 can use the current version of Bol Processor BP3 to process musical works and implement further tuning procedures. Follow the instructions on the Bol Processor ‘BP3’ and its PHP interface page to install BP3 and learn its basic operation.
These parameters are saved in '-se' settings files associated with grammars and data. They are expressed in milliseconds.
Time resolution is the minimum difference of dates between two events sent to a MIDI device or written on a Csound score. By default is is set to 10 ms but in some cases it may be necessary to diminish this value. This is already a type of quantization because several events occuring with time offsets lower than the resolution will be sent or written with identical dates.
Time quantization is an option allowing the polymetric expansion algorithm to reduce the size of the phase diagram constructed to frame out the symbolic timing of events — in fact, relations of precedence or simultaneity. Read page Complex ratios in polymetric expressions for a detailed explanation. In brief, it is a method for saving memory space and speeding up the computation.
In many cases, the production of a piece would simply be impossible with a quantization reduced to the time resolution. This is due to the fact that all Bol Processor time calculations are performed with integer ratios to reach the best accuracy compatible with limitations of the machine. However, for instance, storing two notes distant by a few milliseconds requires two distinct columns on the phase diagram although (in general) this differnce is not audible.
Even though it is possible to set the time quantization to a value lower than the time resolution, it would increase the size of the phase diagram (i.e. memory and computation time) with no effect on the output because the time resolution is the lowest value of the actual quantization. This inconsistency is signaled on the Data or Grammar window:
👉 Be aware that using a very short quantization (typically less than 10 ms) on a large item can increase memory usage to the point where the MAMP or XAMPP driver hangs without warning.
Randomisation of dates
The Bol Processor has a performance tool notated "_rndtime(x)" for randomizing the dates of events, in which 'x' is half the range in milliseconds. For instance, following "_rndtime(100)", all dates will be recalculated within a ± 100 ms range.
Randomisation is often used by poor composition devices to "humanize" computer-made pieces. This is a ridiculous approach based on the belief that human interpreters must be willingly imprecise in their performance… or that music is implicitly a "fuzzy" construction.
The _rndtime tool may otherwise be used to compensate unwanted effects when several digitally synthesized sounds are superposed, as explained on page Importing MusicXML scores. In this case, the range is very small and the value of the time resolution may need to be adjusted accordingly. For instance, "_rndtime(20)" should be associated with a time resolution of 1 millisecond so that 40 different values will be randomly picked up in a ± 20 ms range. Note that this has no incidence on the time quantization.
The effect of a ± 20 ms time randomisation can be noticed by carefully listening to the following two examples:
Flags can be used in grammars to activate/deactivate rules according to simple numerical and logical evaluations.
Let us look at the ‘-gr.tryFlags’ grammar:
-al.abc // First create string of ‘a’ gram#1[1] S --> X /Num_total = 20/ gram#1[2] /Num_total - 1/ X --> a X -------- // Create flags counting 'a' and 'b' gram#2[1] X --> lambda /Num_a = 20/ /Num_b = 0/ -------- // Now replace 'a' with 'b' until they are in equal numbers gram#3[1] /Num_a > Num_b/ a --> b /Num_b + 1/ /Num_a - 1/
This grammar produces a string of 20 terminal symbols (Num_total) containing an equal number of (randomly positioned) 'a' and 'b'. For example:
b b a a a b a a b a b a b b b a b b a a
In a grammar rule, flags are enclosed in '/'. The first occurrence of a flag usually sets its initial value (an integer number), for example /Num_total = 20/.
Additive/subtractive operations (on integers) can then be performed to increase or decrease the values of the flags, e.g. /Num_b + 1/ or /Num_a - 1/.
Flags that appear before the left argument of a rule are evaluated and used to control the rule. For example,
/myflag/ X --> Y
will only be a candidate rule if 'myflag' is strictly positive. This evaluation can also be a check of the values of two flags. For example, rule:
/flag1 > flag2/ /flag3 = flag2/ /flag4 = 50/ X --> Y
will only remain a candidate as long as the three conditions are met.
This technique can be combined with other control techniques, such as (positive/negative, proximate/remote, left/right) contexts, rule weights etc. An example of the use of flags can be found in "-gr.trial.mohanam", combined with rule weights and pattern contexts. Read the page Computing ‘ideas’.
➡ Note that the operators '≤', '≥' and '≠' are not yet accepted in the current version of BP3 as it does not handle multi-byte Unicode characters.