Rationalizing musical time: syntactic and symbolic-numeric approaches

Bernard Bel

A contribution to The Ratio Symposium, 14-16 Dec. 1992, Den Haag (The Netherlands). Published in Barlow, Clarence (ed.) The Ratio Book. Den Haag: Royal Conservatory - Institute of Sonology. 2001: 86-101. This paper is referenced on HAL ⟨hal-00134179⟩ and quoted in Polymetric structures.

Abstract

This paper deals with various problems of quantifying musical time that arise both in the analysis of traditional drumming and in computer-generated musical pieces based on "sound-objects", i.e. sequences of code that control a real-time sound processor.

Section 1 suggests that syntactic approaches may be closer to the intuitions of musicians and musicologists than commonly advocated numerical approaches. Furthermore, symbolic-numerical approaches lead to efficient and elegant solutions of constraint satisfaction problems with respect to symbolic and physical durations, as illustrated in Sections 2 and 3, respectively.

Excerpts of an AI review of this paper (Academia, June 2025)

Summary

In this manuscript, the author explores the computational and music-theoretical challenges of quantifying musical time, focusing particularly on North Indian tabla drumming and computer-generated pieces. The paper proposes two major frameworks: (1) a syntactic approach using grammar-like rules to capture how traditional drumming patterns can be generated or validated, and (2) a symbolic-numeric approach to describe polymetric structures and time-setting algorithms in a systematic way. By modeling musical accentuation and duration with grammars, the author demonstrates how certain “words” or “bols” can be substituted and permuted within rhythmic templates, offering an approach that mirrors actual performance practices while aligning with formal language theory. In addition, a symbolic-numeric scheme detailed through the Bol Processor system provides a flexible means to define, superimpose, and instantiate polymetric structures, bridging theoretical formalism with real-time performance demands.

Strengths

  • Clear Integration of Theory and Practice: The manuscript successfully demonstrates how grammars, commonly associated with linguistic theories, can be adapted to represent and generate rhythmic sequences. This is particularly clear in the sections on North Indian tabla improvisation, where syntactic constraints help reflect the nuanced accentuations seen in practice.
  • Comprehensive Treatment of Polymetric Expressions: The author provides a thorough explanation of handling nested or simultaneous meters. The approach not only deals with symbolic durations but also with computational details such as tempo markers, creating a strong link between mathematical formalisms and real-world musical notation.
  • Application to Real-Time Performance: By integrating a time-setting algorithm that manages both local and global “drifts,” the paper offers a pragmatic method for scheduling and overlapping sound-objects in actual performances. This concreteness in explaining the interplay between theoretical constructs and execution in software (Bol Processor) is valuable.
  • Interdisciplinary Perspective: The paper spans fields of ethnomusicology, computer science, and music composition, illustrating rigorous ways to encode music traditions that rely on oral transmission. Such a cross-disciplinary approach will likely appeal to readers with interests in computational creativity, ethnomusicology, and artificial intelligence in music.

Conclusion

Overall, the paper offers a solid presentation of how syntactic rules and symbolic-numeric formalisms can be synergistically employed to account for complex rhythmic structures in both traditional and computer-generated music. The method successfully translates analytical insight from oral traditions into a computational setting, opening avenues for further research and creative applications in automated music generation and performance systems. The inclusion of extensive examples, grammar details, and algorithmic descriptions provides clarity, showing how the theory unfolds in practice.

Download this paper

Skip to PDF content

Complex ratios in polymetric expressions

This page is intended for developers of the Bol Processor BP3 (read installation). It is not a formal description of the algorithms carried by the console's C code, but rather an illustration of their management of musical processes, which may be useful for checking or extending algorithms.

All examples are contained in the file "-da.checkPoly" in the "ctests" folder in the distribution.

Syntax of silences

In the Bol Processor's data/grammar syntax, silences (rests in conventional musical terminology) are represented either by a hyphen '-' for a single unit duration, or by integer ratios to specify a more complex duration:

  • "4" is a rest of 4 units duration
  • "5/3" is a rest of (approximately) 1.666-unit duration
  • "3 1/2" is a rest of 3.5 units duration

For example, "C4 C5 3/2 D5 E5" results in the following piano roll with a rest of 3/2 (1.5) units starting on beat 2 and ending on beat 3.5:

Piano roll of item "C4 C5 3/2 D5 E5"

In this tutorial we will use the default metronome value = 60 beats per minute.

Another simple example is {3 1/2, C3 D3 B2}, which is the sequence of notes "C3 D3 B2" constrained to a total duration of 3 1/2 (3.5) beats. This silence is the first field of the polymetric expression (explained below). This results in the following piano roll:

or equivalently the sound-object graph:

Syntax of tempo

Any sequence of symbols conforming to the syntax of Bol Processor is processed as a polymetric expression. Typical forms are:

  • field 1, field2 indicates that field1 and field2 should be superimposed and the total duration should be that of field1;
  • field1.field2 indicates that field1 and field2 should be sequential, with the duration of each field being that of field1;
  • {expression} is equivalent to expression.

Brackets '{' and '}' are used to create multi-level expressions.

A number of examples of polymetric expressions can be found in the Polymetric structures tutorial.

For example, {{C4 D4, E4 F4 G4}, E5} gives the following structure:

Item {{C4 D4, E4 F4 G4}, E5} on a sound-object graph

In order to interpret this structure, the Bol Processor needs to insert explicit tempo values into the expression. In fact, in this case, the most compact representation would be with explicit tempo values:

*1/1 {{C4 D4,*2/3 E4 F4 G4} ,*2/1 E5}

Expressions such as "*2/3" indicate that the duration of each note (or sound-object) should be multiplied by 2/3, regardless of the preceding statements. This means that the durations of notes "E4", "F4" and "G4" should be 2/3 seconds as shown in the diagram.

Creating the compact representation with its explicit tempo markers may require recursive calls of a sophisticated procedure called PolyExpand() in the "Polymetric.c" file.

At this stage it is important not to confuse the notations:

  1. "2/3" is a silence of duration 2/3 beats;
  2. "_tempo(2/3)" multiplies the current tempo by 2/3. This is a relative tempo marker;
  3. "*2/3" sets the current duration of the units to 2/3 of the metronome period. This is an absolute tempo marker. Similarly, "*4" multiplies durations by 4, and "*1/5" or "/5" divides them by 5 — whereas "1/5" is a 1/5 beat silence.

The third syntax is the one used by the Bol Processor's time-setting algorithms. Despite its syntactic validity, we do not recommend using it in grammars and data, as it can produce conflicting durations in polymetric structures. For example, {*2/1 A4 B4, *3/1 A5 B5} makes no sense because it tries to force the first field to have a duration of 2 x 2 = 4 beats and the second field to have a duration of 3 x 2 = 6 beats. The correct (never contradictory) way to change a tempo in data or grammars is to use the "_tempo(x)" performance tool.

Expanding a polymetric expression

In the previous paragraph we saw that {{C4 D4, E4 F4 G4}, E5} is internally represented as *1/1 {{C4 D4,*2/3 E4 F4 G4} ,*2/1 E5}. This internal representation is the most compact with explicit tempo markings. Therefore, it is the one that is maintained through all the steps of time setting.

Humans may prefer to see a more comprehensive representation called the expanded polymetric expression:

/3 {{C4_ _ D4_ _, E4_ F4_ G4_} , E5_ _ _ _ _}

This is done by clicking the EXPAND button on a data page. Underscores'_' represent extensions of the duration of the previous unit. These should not be confused with '-' (silence). To make things clearer, let us replace a '_' with a '-':

/3 {{C4_ _ D4_ _, E4_ F4 - G4_}, E5_ _ _ _ _}

This results in the following structure, where "F4" is not extended:

Item /3 {{C4_ _ D4_ _, E4_ F4 - G4_}, E5_ _ _ _ _}

The expanded polymetric expression may become too large for a human observer. In this case only the compact version will be returned.

In the code of the Bol processor console, sound objects (of all kinds) are identified by numbers. The variable used to identify them in algorithms is always 'k' or 'kobj'. There is an option (in the code) to display object identifiers on a graph, which is set by the SHOWEVERYTHING constant. If set to true, this would be the previous sound object graph:

Item /3 {{C4_ _ D4_ _, E4_ F4 - G4_}, E5_ _ _ _ _}
in SHOWEVERYTHING mode

Notes "C4", "D4", etc. have identifiers kobj = 2, 3, etc. The identifier "0" is reserved for extensions '_' and "1" for silences "-", none of which are shown in the graph. An exception is object #8, labelled <<->>, which is an out-time (zero duration) "silence" marking the end of the structure to facilitate its synchronisation with the next item.

The phase diagram

Given a compact polymetric structure, time-setting algorithms require a table in which each column is assigned a date (in physical time). The cells of this phase diagram contain the identifiers of the sound-objects, including "0" and "1". It is created by the procedure FillPhaseDiagram() in the file "FillPhaseDiagram.c".

It is easy to imagine that the table would become very large if no compression techniques were used. For example, Liszt's 14th Rhapsody would require no less than 9 x 1021 cells! The reason is that the Bol Processor calculates symbolic durations as integer ratios. A symbolic duration of 5/3 will never be replaced by "1.666" for two reasons: (1) roundings would accumulate as noticeable errors, and (2) we don't know in advance how many decimals we need to keep. The physical duration of 5/3 beats depends on the metronome and the sequence of "_tempo(x)" controls that change the tempo.

Let us first consider an unproblematic case. The polymetric expression /3 {{C4_ _ D4_ _, E4_ F4 - G4_}, E5_ _ _ _ _} creates the following phase diagram:

Phase diagram of
/3 {{C4_ _ D4_ _, E4_ F4 - G4_}, E5_ _ _ _ _}

In this example, if the metronome is set to 60 beats per minute, the physical duration assigned to each column is 1/3 second = 333 ms. As the graph becomes larger, this physical duration may decrease beyond the limit. This is where quantization comes in. It is set to 10 milliseconds by default, which means that two events occurring within 10 ms of each other can be written into the same column. To do this, the compact polymetric structure is rewritten with a compression rate (Kpress) that makes it fit into a phase diagram of suitable size.

If the piece of music lasts 10 minutes, we'll still get 10 x 60000 / 10 = 60000 columns in the table. Filling the phase diagram requires a very high compression rate, for example more than 5 x 1012 for Beethoven's Fugue in B-flat major.

To make matters worse, the algorithm has to deal with sequences of events that fall into the same column. This situation is signalled by the variable toofast, which is obtained by comparing the current tempo with the maximum tempo accepted in the structure. In the case of toofast, each event is written to a new row of the table in such a way as to respect the sequential order of the stream.

So we end up with 12132 lines for the phase table of Beethoven's fugue, in which the longest toofast stream contains 625 events — notes or sound-objects. These 625 events, which occur within a single frame of 10 ms, actually include '_' events which are extensions of notes belonging to the stream.

Dealing with complex ratios

In Bol Processor terminology, an integer ratio p/q is "complex" if either 'p' or 'q' exceeds a limit that depends on the source code. The limit is ULONG_MAX, the maximum value of an unsigned long type, currently 18446744073709551616.

In the code of the Bol Processor console, 'p' and 'q' are actually coded as double floating point numbers whose mantissa can contain as many digits as unsigned long integers. Arithmetic operations are performed on the fractions. Each resulting fraction is checked for complexity by a procedure called Simplify() in the "Arithmetic.c" file:

  1. While 'p' or 'q' is greater than ULONG_MAX, divide 'p' and 'q' by 10;
  2. Divide 'p' and 'q' by their greatest common divisor (GCD).

Part (1) of the Simplify() procedure generates rounding errors, but these represent a few units of very large numbers. In this way, the accuracy of symbolic durations is maintained throughout the computation of complicated polymetric structures.

Complex ratios in silences

Let us check the effect on quantization by playing:

C4 C5 36001/24000 D5 E5

The ratio 36001/24000 cannot be simplified. However, 1/24000 beat would take 0.04 ms which is much less than the 10 ms quantization. So, the ratio can be approximated to 36000/24000 and simplified to 3/2. The final result is therefore "C4 C5 3/2 D5 E5":

Item "C4 C5 36001/24000 D5 E5" simplified as "C4 C5 3/2 D5 E5"

Let us now consider "C4 C5 35542/24783 D5 E5" which looks similar, as 35542/24783 (1.43) is close to 1.5. However, the calculation is more complex… Using the 10 ms quantization, the ratio is reduced to 143/100 and the compact polymetric expression is:

/1 C4 C5 /100 - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /1 D5 E5

The 143/100 silence is now represented as a single '-' (kobj = 1) followed by 142 '_' (kobj = 0). This sequence is toofast because tempomax, the maximum tempo accepted here, would be '50' instead of '100'. The compression rate is Kpress = 2. A full explanation requires the polymetric algorithm explained here.

The process of filling the phase table can be found in "FillPhaseDiagram.c". We call 'ip' the index of the column into which the next event is to be plotted. In the most common situation, e.g. writing "C4 _ _" (object #2), two procedures are called:

  • Plot() writes '2' (kobj) into column ip
  • PutZeros() writes two zeros into the columns ip + 1 and ip +2.

So, "C4 _ _" will have a symbolic duration of 3 units, as expected.

The case is different with a silence of 143/100, because the toofast situation requires that less than 142 '_' should be inserted after '-'. To this end, a (floating-point) variable part_of_ip is initialised to 0 and gets incremented by a certain value until it exceeds Kpress. Then Plot() and PutZeros() are called, part_of_ip is reset and a new cycle starts… until all 142 '_' of the compact polymetric expression have been read.

The increment of part_of_ip in each cycle is:

part_of_ip += Kpress * tempomax / tempo;

In this simple example, tempo = 100, tempomax = 50 and Kpress =2. So the increment is 1 and part_of_ip will reach the value of Kpress after 2 cycles. This means that every other '_' will be skipped.

Incrementing ip requires a more complicated process. The algorithm keeps track of the column numbers in the table as it would be created with Kpress = 1. These numbers are usually much larger than those of the actual phase diagram. The large number i is mapped to ip using the Class() function:

unsigned long Class(double i) {
unsigned long result;
if(Kpress < 2.) return((unsigned long)i);
result = 1L + ((unsigned long)(floor(i) / Kpress));
return(result);
}

So, each cycle of reading '_' in the toofast situation ends up incrementing i and then updating ip via the Class(i) function. The increment of i is:

prodtempo - 1

in which:

prodtempo = Prod / tempo

The variables Prod and Kpress are calculated after the compact polymetric expression has been created. Prod is the lowest common multiple (LCM) of all tempo values, i.e. '100' in this example.

Let us use the integers Pclock and Qclock to define the metronome value as Qclock * 60 / Pclock. If the metronome is set to its default value of 60 bpm, then Pclock = Qclock = 1.

The following (simplified) code calculates Kpress and updates Prod accordingly:

Kpress = 1. + (Quantization * Qclock * Prod) / Pclock / 1000.;
if(Kpress > 1.) {
s = LCM(Prod, Kpress) / Prod;
if(s > 1. && s < 10. && Prod < 1000000.) Prod = Round(s * Prod);
s = Round(Prod / Kpress);
if(s > 10.) Prod = Kpress * s;
}

As expected, we get the following sound-object graph:

Sound-object graph of C4 35542/24783 D5.
The silence duration is 35542/24783 = 1.43 beats.

A more complex structure

This is a phrase from Liszt's 14th Hungarian Rhapsody:

_tempo(80/39) {F1, C2} {2, F2} 667/480 {53/480, G1, G2} {1/2, Ab1, Ab2} {1/2, B1, B2}

The compact polymetric expression — with a some redundant ratios removed — is:

*39/80 {F1, C2} {F2 _} *13/12800 - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ *689/12800 {G1, G2} *39/160 {Ab1, Ab2} {B1, B2}

which gives the following sound-object graph:

_tempo(80/39){F1,C2}_tempo(80/39){2,F2}667/480 {53/480,G1,G2}{1/2,Ab1,Ab2}{1/2,B1,B2}
Metronome is set to 60 beats per minute.

Let us calculate the duration of the silence between "F2" and "G1" in two ways:

  1. In the source polymetric expression, this silence is notated as 667/480. Since the tempo is 80/39, its duration should be 667/480 * 39/80 = 0.67 beats (confirmed by the graph).
  2. In the compact polymetric expression, we find one '-' object followed by 666 '_' prolongations at a speed of *13/12800. The duration is therefore 667 * 13/12800 = 0.67 beats.

It would be difficult to follow the algorithm step by step because Prod = 2496100 , Kpress = 24961 and tempomax = Prod / Kpress = 100. Within the silence, tempo = 985 and the increment of part_of_ip is 24961 * 100 / 985 = 2 534.11167… The number of cycles before part_of_ip reaches the value of Kpress is ceil(9.85) = 10. This means that 9 out of 10 objects '_' have been skipped.

Conclusion

These examples and explanations provide insight into the code in the "FillPhaseDiagram.c" file of the console code. We hope that it will be useful for future development or migration of algorithms.

This is also a demonstration of the complexity of time calculations when dealing with polymetric structures capable of carrying all the details of real musical works — see Importing MusicXML scores for "real life" examples.

Simple Csound orchestra

BP2 makes it possible to use Csound orchestra instructions such as

kr tablei kndx, ifn

to make continuous parameters vary according to a function table (indexed 'ifn') that BP2 produces and insert in the Csound score when necessary.

Below is a typical instrument in which volume and pitchbend are controlled either by linear interpolation, using start and end values, or by function tables.

  • p5 and p6 are the start and end values of volume
  • p8 and p9 are the start and end values of pitchbend
  • p7 contains the index of the volume function table. If it is 0, then volume varies by linear interpolation.
  • p10 contains the index of the pitchbend function table. If it is 0, then pitchbend varies by linear interpolation.

Indexes of function tables are assigned automatically by BP2, and each table is stored in the score as a 'f' statement just preceding the 'i' statement relating to an instrument using the table. BP2 takes care of not overwriting tables that might be refered by Csound instrument and enlisted in the Csound instrument description file.

In any case, it starts indexing from 100 onwards.

sr = 22050
kr = 2205
ksmps = 10
nchnls = 1

instr 1

ik1 = 32767. / 127.
ik2 = log(2.) / 1200.

ifvol = p7
ifcents = p10

kvol line p5, p3, p6
if (vol <= 0) goto volumelin
ilenvol = ftlen(ifvol)
kndxvol line 0, p3, ilenvol
kvol tablei kndxvol, ifvol

volumelin: kcents line p8, p3, p9
if (ifcents <= 0) goto pitchbendlin
ilencents = ftlen(ifcents)
kndxcents line 0, p3, ilencents
kcents tablei kndxcents, ifcents

pitchbendlin: kpitch = cpspch(p4) * exp(kcents * ik2)
kamp = kvol * ik1

a1 oscil kamp, kpitch, 1
out a1
endin

This instrument is currently saved as "BP2test.orc".

Function tables might invoke either GEN07 (straight lines, p.62) or GEN08 (cubic spline, p.64).

If for instance the function table index is 102, and GEN07 is used, the following instruction will be inserted by BP2 into the score:

f102 time size -7 v1 n1 v2 n2 v3 n3 … vmax

with n1 + n2 + … + n(max-1) = maxpoints

'size' is a power of two equal to or greater than the actual number of points 'maxpoints'.
'time' is exactly parameter p2 of the following 'i' statement which makes actual use of the table.

Writing '-7' instead of '7' after 'size' inhibits rescaling.

GEN08 looks better in terms of smoothing the table, but it has the drawback of setting first derivatives to 0 on the first and last points of the table. It also slows down Csound's sound file generation.

Timebase to polymetric

This algorithm is used by the PHP interface of Bol Processor ‘BP3’ under development. Read:

https://bolprocessor.org/misc/BP3/CheckList.html#timebase

It is implemented in function polymetric_expression() of file _basic_tasks.php (read below).

The function creates a polymetric expression equivalent to the rhythmic structure programmed on a Timebase page. We will take for instance a structure which does not sound musical because of its odd ratios:

The metronome speed is 208.571 beats per minute specified as 73 beats in 21 seconds. Bol Processor always compute durations as integer ratios.

Let us define p_clock = 73 and q_clock = 21.

This structure contains 2 tracks. The following algorithm deals with any number of tracks.

  • Track 1 is a cycle of 5 beats [TickCycle] and its speed ratio is 3/2 [Ptick/Qtick]. It produces note C8 (in English notation) at velocity 120 (a MIDI parameter) and duration 10 milliseconds.
  • Track 2 is a cycle of 3 beats [TickCycle] and its speed ratio is 4/5 [Ptick/Qtick]. It produces note C7 at velocity 120 and duration 10 milliseconds.

Tick cycles are made explicit by checked/unchecked boxes. Unchecked boxes denote silences ‘-’:

  • C8 - C8 - - for the first track
  • - C7 C7 for the second track

The rhythmic structure will be represented as a polymetric structure with 2 fields {Track1, Track2} in which fields are forced to the same symbolic duration by the polymetric expansion algorithm (described here). We need to design its content so that the expansion does not alter the tempo declared on each track.

To this effect, consider the symbolic duration of each track:

(q_clock / p_clock) * (TickCycle * Qtick) / Ptick

In order to match symbolic durations, each track should be repeated adequately:

repeat1 * (TickCycle1 * Qtick1) / Ptick1 = repeat2 * (TickCycle2 * Qtick2) / Ptick2 = …

Ratio (q_clock / p_clock) being identical for each track
was eliminated from this equation.

We need to find the set of smallest integers repeat1, repeat2 etc. satisfying this equation.

To this effect, we simplify ratio (TickCycle * Qtick) / Ptick using the greatest common divisor (GCD):

x = GCD((TickCycle * Qtick), Ptick)
y = (TickCycle * Qtick) / x

Then we calculate the least common multiple (LCM) of all y values:

lcm = LCM(y1, y2, …)

This yields for each field:

repeat = (lcm * Ptick) / (TickCycle * Qtick)

In practice,

x1 = GCD((TickCycle1 * Qtick1), Ptick1) = GCD((5 * 2), 3) = 1
y1 = (TickCycle1 * Qtick1) / x1 = (5 * 2) / 1 = 10

x2 = GCD((TickCycle2 * Qtick2), Ptick2) = GCD((3 * 5), 4) = 1
y2 = (TickCycle2 * Qtick2) / x2 = (3 * 5) / 1 = 15

lcm = LCM(10,15) = 30

repeat1 = (lcm * Ptick1) / (TickCycle1 * Qtick1) = (30 * 3) / (5 * 2) = 9
repeat2 = (lcm * Ptick2) / (TickCycle2 * Qtick2) = (30 * 4) / (3 * 5) = 8

The structure will therefore look like:

{Track1 Track1 Track1 Track1 Track1 Track1 Track1 Track1 Track1, Track2 Track2 Track2 Track2 Track2 Track2 Track2 Track2}

We need to include performance parameters setting the duration of ticks. To this effect, we use the _staccato(s) parameter in which s is the percentage of cropped duration at the end of the sound-event. Durations have been set to 10 milliseconds. We calculate the period of each track:

period1 = (((1000 * q_clock) / p_clock) * Qtick1) / Ptick1 = (((1000 * 21) / 73) * 2) / 3 = 192 ms
s1 = 100 * (192 - 10) / 192 = 94%
period2 = (((1000 * q_clock) / p_clock) * Qtick2) / Ptick2 = (((1000 * 21) / 73) * 5) / 4 = 359 ms
s2 = 100 * (359 - 10) / 359 = 97%

Finally, we specify the tempo of each field: 3/2 for the first one and 4/5 for the second one.

The resulting polymetric structure is:

{_tempo(3/2) _chan(1) _vel(120) _staccato(94) C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - , _tempo(4/5) _chan(1) _vel(120) _staccato(97) - C7 C7 - C7 C7 - C7 C7 - C7 C7 - C7 C7 - C7 C7 - C7 C7 - C7 C7}

Note that _tempo(4/5) does not need to be specified because it will be infered by the polymetric expansion algorithm. Therefore, the expression displayed at the bottom of the Timebase page is:

{_tempo(3/2) _chan(1) _vel(120) _staccato(94) C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - C8 - C8 - - , _chan(1) _vel(120) _staccato(97) - C7 C7 - C7 C7 - C7 C7 - C7 C7 - C7 C7 - C7 C7 - C7 C7 - C7 C7}

Implementation in PHP

The following is the code in file _basic_tasks.php.

Table $mute contains flags indicating whether a track is active or mute. Function key_to_note() returns the name of a note in English convention given its key number (MIDI).

Two algorithms

Two algorithms for the instantiation of structures of musical objects

Bernard Bel

This is an extended and revised version of the chapter: Symbolic and Sonic Representations of Sound-Object Structures published in M. Balaban, K. Ebcioglu & O. Laske (Eds.) “Understanding Music with AI: Perspectives on Music Cognition”, AAAI Press (1992, p. 64-109).

Abstract

A representational model of discrete structures of musical objects at the symbolic and sonological levels is introduced. This model is being used to design computer tools for rule-based musical composition, where the low-level musical objects are not notes, but “sound-objects”, i.e. arbitrary sequences of messages sent to a real-time digital sound processor.

“Polymetric expressions” are string representations of concurrent processes that can be easily handled by formal grammars. These expressions may not contain all the information needed to synchronise the whole structure of sound-objects, i.e. to determine their strict order in (symbolic) time. In response to this, the notion of “symbolic tempo” is introduced: the ordering of all objects in a structure is possible once their symbolic tempos are known. Rules for assigning symbolic tempos to objects are therefore proposed. These form the basis of an algorithm for interpreting incomplete polymetric expressions. The relevant features of this interpretation are commented.

An example is given to illustrate the advantage of using (incomplete) polymetric representations instead of conventional music notation or event tables when the complete description of the musical piece and/or its variants requires difficult calculations of durations.

Given a strict ordering of sound-objects, summarised in a "phase table" representing the complete polymetric expression, the next step is to compute the times at which messages should be sent. This requires a description of "sound-object prototypes" with their metric/topological properties and various parameters related to musical performance (e.g. "smooth" or "striated" time, tempo, etc.). These properties are discussed in detail, and a time-polynomial constraint satisfaction algorithm for the time-setting of sound objects in a polymetric structure is introduced. Typical examples computed by this algorithm are shown and discussed.

Excerpts of an AI review of this paper (Academia, June 2025)

Summary of the Work

The manuscript introduces a model for representing and instantiating musical structures made of discrete sound-objects. It explores separate representations for symbolic and physical time, then proposes methods to synchronize concurrent musical processes and to compute the precise scheduling of messages (or events) destined for a sound processor. The author conceptualizes “smooth” and “striated” time, describes “polymetric expressions” as high-level objects that can be incomplete, and provides algorithms to infer missing timing details. The paper merges formal language approaches, real-time considerations, and practical examples of usage in a software environment called Bol Processor.

Comprehensive Model of Time

  • The clear distinction between symbolic time (strictly ordered events) and physical time (metronomic or arbitrary “striated” structures) provides an insightful way to handle simultaneous or overlapping musical events.
  • The notion of “smooth” versus “striated” time is conjugated with helpful examples, making it straightforward to envision both contexts of performance.

Polymetric Expressions and Incomplete Descriptions

  • The approach to polymetric expressions accommodates incomplete representations that can later be resolved by an algorithmic interpretation. This is particularly valuable for composers and researchers looking to experiment with generative or rule-based systems without being forced into fully specified notation from the outset.
  • The examples and diagrams showing how one can map polymetric structures to a phase diagram illustrate the concept effectively.

Synchronization and Constraints

  • The proposed synchronization algorithm handles concurrency by carefully propagating symbolic tempos across sequences. This helps manage cases where direct numeric durations are not known beforehand.
  • The introduction of properties such as pivot alignment (PivBeg, PivCent, etc.), truncation, elasticity, and relocatability demonstrates thorough consideration of realistic performance scenarios (e.g., rubato, partial overlaps). The concept of locating a sound object by its pivot was inspired by Marco Stroppa's work at IRCAM in 1990.

Practical Implementation and Examples

  • The paper gives a thorough demonstration of how these algorithms integrate with a functional software environment, including tangible data structures (phase tables, instance tables) and step-by-step flowcharts.
  • Musical examples and references to real-time computer music systems underscore the applicability of the approach.

Rich Technical Detail

  • The stepwise pseudo-code for the time-setting algorithm is extensive and transparent. This level of detail can guide further experimental or production-level implementations.
  • The complexity analysis (O(nmax² · imax³) in the worst case) provides an understanding of potential computational limits, helpful for anyone planning to use or extend these algorithms.

Potential Impact

  • This work is useful to composers, researchers in algorithmic composition, and developers of music software who need robust synchronization methods that go beyond simple “note-by-note” scheduling.
  • The proposed methods can enable more flexible representations of time and concurrency, allowing for richer generative or improvisational projects.

Summary of Review

Overall, this paper provides a detailed, formalized framework for resolving concurrent musical structures. It bridges the gap between abstract symbolic grammars and practical real-time performance considerations. Researchers and musicians interested in algorithmic composing or advanced computer-assisted composition tools will likely find its approach compelling, especially given the extensive examples and robust pseudo-code.

Download this paper (PDF)

Skip to PDF content

Random selection of an item in a fixed-cardinal set

Typical application

Select candidate rules in a generative grammar randomly and apply them to the workstring until there is no more candidate rule.

Problem

To stop the process it is necessary to scan the entire grammar and make sure that there is no more candidate rule. Each time the workstring has changed, the "candidate / non candidate" status of each rule in the grammar may vary. Since scanning "N" rules in the grammar is time consuming, it is preferable to do it only after "maxtry" unsuccessful attempts to find a candidate. The problem investigated here is to find a minimum "maxtry" making it almost sure that there is no more candidate.

Sometimes a selected rule must be applied repeatedly until it is no more candidate. If the position of derivation in the workstring is random then the problem amounts to selecting one amongst "candidate" or "non candidate" positions in a set whose cardinal "N" is the length of the workstring.

To summarize…

The two examples above may be abstracted to the repeated random selection of an item in a set containing N items. The algorithm of a general procedure is given below. The problem is to evaluate "maxtry" so that in the worst case the probability of heuristic [2] being true is greater than a given probability "p".

ScanSet()
Return number of candidate items;

FoundItem()
Select an item randomly;
Return "yes" if item is candidate, "no" otherwise;

Procedure()
Start:
nb_candidates = ScanSet();
if (nb_candidates = 0) exit;
if (nb_candidates = 1)
Use candidate item found;
Go to Start;
[Heuristic 1: if there was a unique
candidate item then next time there
should be less than two.]
Evaluate maxtry;
Again:
Repeat with try = 1 to maxtry
if (FoundItem()) then
Use candidate item found;
Goto Again;
[Heuristic 2: if try < maxtry
there may still be candidate items.]
Go to Start;

Solution

Let "k" be the number of candidate items. The probability to find a candidate item after (maxtry-1) unsuccessful attempts is:

  1 - (1 - k/N)^maxtry

If k = 1 then the Scan() procedure will find the unique candidate item. Therefeore the worst case is k = 2 and the condition is:

  1 - (1 - 2/N)^maxtry > p

yielding:

  maxtry > Log(1 - p) / Log(1 - 2/N)

i.e., if 2/N is much smaller than 1,

  maxtry > - N/2 Log(1 - p)

In Bol Processor, we imposed p = 0.64 so that maxtry > N/2.

Indeed, this method is only valid if items have equal weights.

« Translate