BP1 in its real musical context

In a pre­ced­ing arti­cle we explained how to install and run Bol Processor ‘BP1’ on a vir­tu­al Apple IIe. BP1 is the ear­li­est ver­sion of Bol Processor imple­ment­ed in 1981 on Apple II com­put­ers, as a require­ment for Jim Kippen’s field­work in India — read At the heart of Indian rhythms and their evo­lu­tion.… We will now show its oper­a­tion in a real musi­cal con­text: the mod­el­ling of a ‘theme-and-variations’ piece of drum­ming (called q‘aida) taught by Ustad Afaq Husain Khan, an expert of the Lucknow style of tabla in India.

This work dates back to the 1980s and has been doc­u­ment­ed in sev­er­al pub­li­ca­tions, includ­ing Kippen and Bel’s Modelling music with gram­mars: for­mal lan­guage rep­re­sen­ta­tion in the Bol Processor (1992) from which the exam­ple will be tak­en. Excerpt (page 207):

Pankaj Chowdhury, Jim Kippen, Afaq Husain Khan (c. 1982)

A large part of the tabla reper­toire involves impro­vi­sa­tion.  Any sequence of strokes may be con­sid­ered as a finite string of sym­bols whose organ­i­sa­tion is relat­ed to some implic­it for­mal sys­tem.  Automatic sequences (i.e. sequences gen­er­at­ed by finite-state automa­ta) share prop­er­ties that place them some­where between peri­od­ic­i­ty and chaos, yet clos­er to peri­od­ic­i­ty.  Since both strict and approx­i­mate peri­od­ic­i­ty are essen­tial fea­tures in music, it is real­is­tic to think that strings of musi­cal events may be appro­pri­ate­ly rep­re­sent­ed with automa­ta or for­mal gram­mars.  In oth­er words, the most fun­da­men­tal rea­son for us to view for­mal lan­guage mod­els as rel­e­vant mod­els of music lies in prop­er­ties that are intrin­sic to music, rather than in ana­log­i­cal links between music and nat­ur­al languages.

The theme of this q‘aida is the fol­low­ing sequence:

dhatid­hagenad­ha­trkt dhatid­hagedheena­ge­na
dhatid­hagenad­ha­trkt dhatid­hageteenake­na
tati­takenata­trkt tati­taketeenake­na
dhatid­hagenad­ha­trkt dhatid­hagedheena­ge­na
Theme of q‘aida asso­ci­at­ed with gram­mar Q2.7

Strokes on the drum — bols such as ‘dha’, ‘ti’, ‘ge’, ‘na’… — belong to the (ter­mi­nal) alpha­bet of the for­mal gram­mar. This sequence should be read lin­ear­ly from left to right. Each group rep­re­sents a beat com­pris­ing 4 units (‘trkt’ is a com­pound stroke of 2 units). Thus, the theme and its vari­a­tions are framed on a 16-beat rhyth­mic mod­el named tin­tal in North-Indian music.

The gram­mar and exam­ples of this qa‘ida are stored as “Q2.7” on diskette “BP-JULY87.DSK” which can be loaded after start­ing Bol Processor (BP-PRG.DSK). We rec­om­mend set­ting the vir­tu­al Apple II to max­i­mum speed to save the time of read­ing (vir­tu­al) diskettes! After load­ing Q2.7’s gram­mar and data, the theme can be dis­played as data item #2:

Keyboard map­ping for this q’aida

Note that the ter­mi­nal alpha­bet used on BP1 is not exact­ly the one of the pub­li­ca­tion. For instance, ‘dhee’ has been replaced with ‘dhi’, ‘tee’ with ‘ti’, com­pre­hen­sive changes for read­ers prefer­ing a translit­er­a­tion of Hindustani phonemes to the ren­der­ing of syl­la­bles in English.

In addi­tion, syl­la­ble ‘ti’ may be ren­dered as ‘tit’. These sub­tleties are gov­erned by the key­board map­ping that can be dis­played (and mod­i­fied) by select­ing “Alphabet” then “Modify” from the main menu.

The gram­mar imple­ment­ed in BP1 is the same as the one dis­played in Appendix 2 of the pub­li­ca­tion, leav­ing out spellings vari­ants of a few bols and dif­fer­ent glyphs used for tag­ging pat­terns — “mas­ter” and “slave” mark­ers, read our arti­cle Pattern gram­mars — and the instruc­tion of bol den­si­ty, as explained in a pre­ced­ing arti­cle. For exam­ple, rule

GRAM#2 [20] <100>  S32  <—>  * (= /6+ A16  V8 + /4) + O16

was dis­played as:

Bol den­si­ty mark­er “6” is nowa­days writ­ten “/6” and “4” as “/4”. The plus sign ‘+’ is used as a con­text marker.

In lat­er ver­sions of Bol Processor we cre­at­ed a “_tempo()” tool which is more flex­i­ble than bol den­si­ty. For instance, “_tempo(8)” would pro­duce the same effect as “/8” in a sim­ple sequence. However, in poly­phon­ic struc­tures, “/8” is an absolute val­ue where­as “_tempo(8)” is rel­a­tive to the cur­rent tem­po. This makes it pos­si­ble to cal­i­brate the dura­tions of sev­er­al sequences con­tained in a poly­met­ric expres­sion — read Two Algorithms for the Instantiation of Musical Structures (1994) for details. Furthermore, expres­sions such as “_tempo(7/4)” and even “_tempo(0.476)” are licit…

Templates

Subrammar #7 con­tains the tem­plates of this grammar:

[1]   TEM
[2]   (=+.….….….…+.….….….…+ * (=+.….….….…+) +.….….….…;)
[3]   (=+.….….….…+.….….….…+ * (=+.….….….…+) +/8+.….….….….….….….…;/4;)
[4]   (=+.….….….…+.….….….…+ * (=/6+.….….…/4.….…+) +.….….….…;)
etc.

These tem­plates are the com­plete list of pat­terns pro­duced by (pre­sum­ably) all vari­a­tions of the q‘aida. They con­tain brack­ets bor­der­ing ref­er­ence strings with the “=” mark­er (dis­played as “◆” in BP1), bol den­si­ty fig­ures and arbi­trary sym­bols “+” and “;” used as con­text in rule, as explained in the pub­li­ca­tion. Technically, pat­terns are sim­i­lar to reg­u­lar expres­sions against which a vari­a­tion is matched before being parsed by the grammar.

Any gram­mar con­tain­ing pat­terns and/or bol den­si­ty fig­ures must be com­plet­ed with tem­plates in order to assess the gram­mat­i­cal­i­ty of vari­a­tions. Fortunately, these tem­plates are auto­mat­i­cal­ly pro­duced by the grammar!

Producing items

To pro­duce vari­a­tions based on this gram­mar, select “Grammars” in the main menu, then go to sub­gram­mar #1, “Edit”, and move for instance to rule #2:

<100>  S  <—>  (=+ S64 ;)

This will pro­duce vari­a­tions con­tain­ing 64 bols as sug­gest­ed by the name of vari­able “S64”. Rule #3 would pro­duce vari­a­tions of 128 bols as sug­gest­ed by “D128”.

Type ctrl-C ([C]ompute). You will be asked to indi­cate the first sub­gram­mar (1) and the last sub­gram­mar (6). If you start com­put­ing from a rule of sub­gram­mar #3, for instance, it makes sense to spec­i­fy #3 as the first sub­gram­mar. If a sub­gram­mar low­er than 6 is spec­i­fied as the last one, some vari­ables may not be rewrit­ten as strings of ter­mi­nal sym­bols. This may be use­ful to check par­tial process­es in the pro­duc­tion of variations.

Options offered then are A)nalyse, S)ynthesize, D)estroy struc­ture and Q)uit. Choose “Synthesize”. Say “no” to “Create tem­plates” and to “Systematic tree-search”. You may reply “yes” to “Step by step?” to dis­play all deriva­tion steps, which makes you famil­iar with the gram­mar. Example of result:

Example of pro­duc­ing a vari­a­tion based on gram­mar Q2.7

This is an inter­est­ing exam­ple: on the third line, bol den­si­ty is dou­bled (8 instead of 4).

You are now offered the option of “Appending” the vari­a­tion to the data set, “Repeating” the pro­duc­tion process, “Printing” (on the vir­tu­al print­er), cre­at­ing “More” vari­a­tions or “Verifying” this vari­a­tion. It is not evi­dent that the gram­mar accepts this vari­a­tion if it has been poor­ly designed. (This is unlike­ly with this exam­ple.) Option “Verify” should quick­ly end up with “S”, the start string, if the vari­a­tion is correct.

If a few vari­a­tions have been append­ed to the data set, edit­ing Data will show them at the end of the set.

This process of pro­duc­ing vari­a­tions is called “modus ponens” in the jar­gon of expert sys­tems. Variations pro­duced in this way were read by the ana­lyst (Jim Kippen) to the expert musi­cian to check their accep­tance as lic­it vari­a­tions of the q‘aida.

Analyzing variations

Imagine now that the expert musi­cian is recit­ing a vari­a­tion which is typed in the data set. This makes it clear that quick and fault­less typ­ing was cru­cial for this field research… Use the key­board map­ping to learn typ­ing at high speed; it is less dif­fi­cult than play­ing on the drums!

In the data set, when a vari­a­tion is dis­played, type ctrl-C for “[C]ompute”. Say “yes” to “Revise pro­cess­ing?”. Now the first gram­mar is #1 but the last gram­mar should be #7 so that tem­plates are tak­en into account. Select “Analyse”, say “no” to “Display prob­a­bil­i­ty?” and “yes” or “no” to “Step by step?”.

If you are ana­lyz­ing step by step, use the right arrow to pro­ceed or the left arrow to back­track. The sub­gram­mar cur­rent­ly used for deriva­tions is men­tioned at the bot­tom of the page, and the index of the lat­est can­di­date rule appears on top. Thus, it is pos­si­ble to visu­al­ize all details of the com­pu­ta­tion for the pro­duc­tion or analy­sis of a variation.

You can check the entire data set against the gram­mar by select­ing “Verify gram­mars” on the main menu.

If the vari­a­tion match­es sev­er­al tem­plates, each one will be used to parse it. In case the pars­ing is suc­cess­ful with sev­er­al tem­plates, the struc­ture of the piece is ambigu­ous. This is anal­o­gous to pars­ing sen­tence “John said Mary is a liar” which requires the place­ment of either two com­mas or a semi-colon, each “tem­plate” yield­ing an oppo­site meaning…

Weights

Currently, in the gram­mar, all rule weights are set to 100 except for rule #3 of sub­gram­mar #1. We can use the 12 vari­a­tions in the data set to infer rule weights: each of them will be ana­lyzed and every rule in this process will have its weight incre­ment­ed by 1 unit.

In the main menu, select “Weights”, then “Emulate learn­ing” and “Reset weights to 0”. From item #2 to item #13. Last gram­mar is “7” (as tem­plates are required).

The result can be print­ed. Note that all weights in sub­gram­mar #6 are set to 100 because it is an “ORD” gram­mar: no ran­dom choice of the can­di­date rule.

Entering new data sets allowed “learn­ing” from more exam­ples and improv­ing the sto­chas­tic mod­el that would pro­duce more “aes­thet­i­cal­ly accept­able” variations.

Intermediate alphabet

Accessed from the main menu. This pro­ce­dure is used for chang­ing the names of vari­ables. This pro­ce­dure proved help­ful in cre­at­ing gram­mars mak­ing sense to humans, not only machines… 

Creating templates

To check this process we rec­om­mend to quite and reload the cur­rent project, as some pro­ce­dures may have been stored in mem­o­ry. Load only gram­mar, no data to keep enough free memory

Select “Grammars” from the main menu, then go to sub­gram­mar #7 (the cur­rent tem­plates) and delete it by select­ing “Remove from series”. (This might not be nec­es­sary as the machine nev­er dupli­cates a tem­plate, but things will be more clear in this manner.)

Then cre­ate a new sub­gram­mar #7, select “Compute” and “Create tem­plates”. You will be asked about the “last gram­mar defin­ing struc­tures”. This choice is of high rel­e­vance to the speed of com­pu­ta­tion because tem­plate pro­duc­tion implies the pro­duc­tion of “all vari­a­tions”. If your answer is “6” the machine may work an extreme­ly long time. Looking at the gram­mar shows that sub­gram­mar #3 is the last one con­tain­ing struc­tur­al mark­ers. Therefore the prop­er answer is “3”.

This process takes a very long time even at the high­est speed. Its pro­gres­sion is shown by ‘+’ signs print­ed on the line under “WAIT”. Since this gram­mar pro­duces 21 tem­plates, you need to wait for 21 ‘+’ signs. Fortunately, tem­plate pro­duc­tion was per­formed once for ever in most grammars…

Conclusion

This demo is an attempt to illus­trate the usage of Bol Processor BP1, in the ear­ly 1980’s, as an expert sys­tem mod­el­ling compositional/improvisational process­es in the q‘aida genre of tabla drum­ming. It was of great rel­e­vance to devel­op an edi­tor facil­i­tat­ing the quick and accu­rate writ­ing of bols (rep­re­sen­ta­tions of strokes on the drum) and the cre­ation of pat­tern rules tak­ing into account implic­it syn­tac­tic struc­tures of these musi­cal pieces.

Later on, Bol Processor was imple­ment­ed on Macintosh com­put­ers. Versions of ‘BP2’ com­pli­ant with sys­tem ver­sions up to MacOS 10.14 (Mojave) can be dowloaded from SourceForge.

BP2 repro­duced all pro­ce­dures of BP1, notably the ones described in Kippen & Bel’s paper Modelling music with gram­mars: for­mal lan­guage rep­re­sen­ta­tion in the Bol Processor (1992). However, its edi­tor is not as sophis­ti­cat­ed with respect to pat­tern edit­ing. Furthermore, the “smart key­board” option makes it pos­si­ble to map ter­mi­nal sym­bols to indi­vid­ual keys, but the cur­sor does not “jump” over ter­mi­nal sym­bols, vari­ables and reserved words.

BP2 intro­duced the pos­si­bil­i­ty of polyphonic/polyrhythmic rep­re­sen­ta­tion. Polymetric struc­tures are an unmatched mod­el for the rep­re­sen­ta­tion of musi­cal time and by exten­sion the struc­ture of “time objects”: music, speech, nois­es, video, robot­ic move­ments etc. This mod­el is able to deal with incom­plete def­i­n­i­tions and per­forms all ter­mi­nal time cal­cu­la­tions accu­rate­ly, using inte­ger ratios. Results are sim­pli­fied to avoid inte­ger over­flow and com­ply with the quan­ti­za­tion required for the actu­al performance.

Current work

At present, a new ver­sion of Bol Processor com­pli­ant with 64-bit proces­sors on var­i­ous sys­tems (MacOS, Windows, Linux…) is under devel­op­ment. Currently it works with a PHP inter­face. We invite soft­ware design­ers to join the team and con­tribute to the devel­op­ment of the core appli­ca­tion and its client appli­ca­tions. Please join the BP open dis­cus­sion forum and/or the BP devel­op­ers list to stay in touch with work progress and dis­cus­sions of relat­ed the­o­ret­i­cal issues.

References


Contributors to this arti­cle: Bernard Bel

Leave a Reply

Your email address will not be published. Required fields are marked *