Minimising a polymetric structure

šŸ‘‰ For geeks only!

This page is about the polyĀ­metĀ­ric notaĀ­tion used in the Bol Processor project and, most likeĀ­ly, othĀ­er softĀ­ware enviĀ­ronĀ­ments. This advanced tool is used to repĀ­reĀ­sent the time strucĀ­ture of events, which can be simĀ­ple notes, sound-objects, or more genĀ­erĀ­alĀ­ly time-objects that can be instanĀ­tiĀ­atĀ­ed as video fragĀ­ments, sequences of robotĀ­ic actions, and so on.

In a polyĀ­metĀ­ric strucĀ­ture, rests (or 'silences') are repĀ­reĀ­sentĀ­ed by inteĀ­ger ratios (their symĀ­bolĀ­ic duraĀ­tion), for examĀ­ple ā€˜6’ for "six beats" or '4 2/3' for "four and two third beats". Small inteĀ­gers can be replaced with hyphens, for examĀ­ple '---' for '3'.

In some (but not all) polyĀ­metĀ­ric strucĀ­tures, rests with explicĀ­it duraĀ­tions can be replaced with undeĀ­terĀ­mined rests (notatĀ­ed '…' or '_rest'), the valĀ­ue of which is calĀ­cuĀ­latĀ­ed by a (deterĀ­minĀ­isĀ­tic) algoĀ­rithm in the conĀ­sole (file 'polymetric.c'). This is an imporĀ­tant feaĀ­ture because it enables the notaĀ­tion to be simĀ­pliĀ­fied withĀ­out comĀ­proĀ­misĀ­ing the accuĀ­raĀ­cy of the time. Take a look at Charles Ames' examĀ­ple, for instance.

A polyĀ­metĀ­ric strucĀ­ture conĀ­tainĀ­ing at least an undeĀ­terĀ­mined rest is called 'minĀ­imised" for this reaĀ­son. Examples of minĀ­imised strucĀ­tures are found on the Polymetric strucĀ­tures page.

The topĀ­ic of this page is about 'revertĀ­ing' the algoĀ­rithm that assigns explicĀ­it duraĀ­tions to undeĀ­terĀ­mined rests in the Bol Processor conĀ­sole. Geeks will find this algoĀ­rithm in the 'polymetric.c' file, and they can set the 'trace_und' variĀ­able to '1' to trace its operation.

Examples of minimisation

All examĀ­ples are found in the "-da.tryMinimise" data file (disĀ­tribĀ­uted from the 3.3.6 verĀ­sion). Click the MINIMISE butĀ­ton to minĀ­imise all (eliĀ­giĀ­ble) polyĀ­metĀ­ric expresĀ­sions on the page.

Only polyĀ­metĀ­ric expresĀ­sions between curled braces { } are processed.

The first examĀ­ple {2, C4 C4 --} will be minĀ­imised as {2, C4 C4 …} whereĀ­as the secĀ­ond examĀ­ple {2, C4 C4 -} is not eliĀ­giĀ­ble. The reaĀ­son is that {2, C4 C4 …} is always instanĀ­tiĀ­atĀ­ed as {2, C4 C4 --} (or {2, C4 C4 2}) and there is no minĀ­imised verĀ­sion of {2, C4 C4 -}.

The third examĀ­ple {C4 D4 E4, A4 B4 F4 3 G4 A4 B4} is minĀ­imised as {C4 D4 E4, A4 B4 F4 …G4 A4 B4}. Both verĀ­sions yield the folĀ­lowĀ­ing time structure:

For this demo, we use simĀ­ple notes with arbiĀ­trary pitchĀ­es in English notaĀ­tion, as we are only focusĀ­ing on the time structures.

The folĀ­lowĀ­ing examĀ­ples are not eliĀ­giĀ­ble for a minimisation:

{C4 D4 E4, A4 B4 F4 1 G4 A4 B4}
{C4 D4 E4, A4 B4 F4 2 G4 A4 B4}
{C4 D4 E4, A4 B4 F4 4 G4 A4 B4}

It is not easy to guess which duraĀ­tion of the rest — 1, 2, 3, 4 beats? — makes it eliĀ­giĀ­ble for being undeĀ­terĀ­mined. The corĀ­rect valĀ­ue can be found by clickĀ­ing the EXPAND butĀ­ton to the right of {C4 D4 E4, A4 B4 F4 … G4 A4 B4}. The first line of the result is the expandĀ­ed polyĀ­metĀ­ric expression:

/1 {*1/1 C4 D4 E4,*1/3 A4 B4 F4 - _ _ G4 A4 B4}

The '- _ _ ' sequence is a rest of duraĀ­tion 3 beats. The symĀ­bol '-' repĀ­reĀ­sents a rest of one beat. This is folĀ­lowed by two proĀ­lonĀ­gaĀ­tions, '_'.

Note that the "expandĀ­ed polyĀ­metĀ­ric expresĀ­sion" disĀ­plays absolute temĀ­po markĀ­ers, such as '*1/3', to repĀ­reĀ­sent the strucĀ­ture, rather than relĀ­aĀ­tive markĀ­ers, such as '__tempo(1/3)'. This repĀ­reĀ­senĀ­taĀ­tion can be used for data, as was the case in earĀ­ly verĀ­sions of the Bol Processor.

Indeed, in this simĀ­ple examĀ­ple, the duraĀ­tion was visĀ­iĀ­ble on the graph. However, it becomes increasĀ­ingĀ­ly difĀ­fiĀ­cult to meaĀ­sure when rhythĀ­mic strucĀ­tures become more comĀ­pliĀ­catĀ­ed. For examĀ­ple, {A4 F4 G4, … C4 D4 … E4} is expandĀ­ed as:

/1 {*1/1 A4 F4 G4, *3/8 - *3/4 C4 D4 *3/8 - *3/4 E4}

It is not easy to figĀ­ure out that '*3/8 -' is a silence at twice the speed of '*3/4 C4', thereĀ­fore its (relĀ­aĀ­tive) duraĀ­tion is 1/2 and the strucĀ­ture is equivĀ­aĀ­lent to {A4 F4 G4, 1/2 C4 D4 1/2 E4}.

The process is more comĀ­plex for fields of the polyĀ­metĀ­ric strucĀ­ture that conĀ­tain at least two rests with difĀ­ferĀ­ent duraĀ­tions. For example:

{C3 D3 E3, A5 5/4 B5 5/2 C5 5/4 D5}

The algoĀ­rithm genĀ­erĀ­ates a table of equivĀ­aĀ­lent rests in chains, such as two 5/4 rests and one 5/2 rest. The table is sortĀ­ed down on the numĀ­ber of rests in each chain, which yields:

5/4 5/4
5/2

Then, each chain is conĀ­sidĀ­ered as a potenĀ­tial soluĀ­tion to the undeĀ­terĀ­mined rest(s). The first one that meets the conĀ­diĀ­tions proĀ­vides the soluĀ­tion. Here, it is "5/4 5/4", which yields:

{C3 D3 E3, A5 … B5 5/2 C5 … D5}

In this examĀ­ple, {C3 D3 E3, A5 5/4 B5 … C5 5/4 D5} is anothĀ­er solution.

If sevĀ­erĀ­al chains conĀ­tain the same numĀ­ber of units, the first acceptĀ­able one is givĀ­en as the soluĀ­tion and the (deterĀ­minĀ­isĀ­tic) algoĀ­rithm ends. However, othĀ­er chains of maxĀ­iĀ­mum length might also meet the conĀ­diĀ­tions. This means that the minĀ­imiĀ­saĀ­tion algoĀ­rithm does not proĀ­vide all soluĀ­tions, but at least it does proĀ­vide one which has the maxĀ­iĀ­mum numĀ­ber of undeĀ­terĀ­mined rests.

Tracing the minimisation

The algoĀ­rithm for minĀ­imisĀ­ing polyĀ­metĀ­ric strucĀ­tures is more comĀ­pliĀ­catĀ­ed to design than the one for assignĀ­ing explicĀ­it duraĀ­tions to undeĀ­terĀ­mined rests. As per this writĀ­ing, it does not covĀ­er all casĀ­es. Updated verĀ­sions will be impleĀ­mentĀ­ed in the interĀ­face file 'data.php'.

If you need to folĀ­low the process while lookĀ­ing at the code, open the setĀ­tings file and enter the item numĀ­ber at the botĀ­tom of the form. In this examĀ­ple, we have choĀ­sen to trace the minĀ­imiĀ­saĀ­tion of item #30.

Don't forĀ­get to save the setĀ­tings and save again the Data page. Now, click the MINIMISE butĀ­ton. You will get a trace that looks like this:

šŸ‘‰ { C3 D3 E3 , A5 5/4 B5 5/2 C5 5/4 D5 }
field #0 = 3/1 sounds, 3/1 beats, temĀ­po = 1/1
field #1 = 9/1 sounds, 9/1 beats, temĀ­po = 1/1
ref field = 0, duraĀ­tion = 3/1 beats
sounds = 9/1
TRYING field #1, "A5 5/4 B5 5/2 C5 5/4 D5 "
—> ref_field = 0, token = "5/4", number_rests = 2, duraĀ­tion = 5/2
āž” beats (3/1) - sounds (9/1) + rest duraĀ­tion (5/2) = xp/xq = -7/2, number_rests = 2
case 1 —> beats[ref_field] = 3/1, sounds[field] = 13/4
pmax/qmax = 12/4, lcm = 4, psounds/qsounds = 13/4
mgap = 1, x = 1.0833333333333, p_therest (before adjust) = 5.5
p_therest (after adjust) = 5, q_therest = 4
[field #1 -> rest = 5/4]
GOT IT: "A5 _rest B5 5/2 C5 _rest D5" —> count_this = 2
Result = {C3 D3 E3 , A5 _rest B5 5/2 C5 _rest D5}

(This trace will difĀ­fer in subĀ­seĀ­quent versions.)

.šŸ›  Work in progress .…. to be continued .….…

Leave a Reply

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