2. Rhythm

This chapter discusses various concepts and Humdrum Extras tools related to rhythm.

2.1. Extensions to **recip and **kern rhythms

Humdrum Extras programs recognize an extension to **recip and **kern rhythm representations which allows any rational rhythm to be encoded. A majority of rhythms found in printed music can be represented in standard **recip data. For example a dotted quarter-note is encoded as 4. and a quintuplet sixteenth note is 20. Such rhythms are based upon integral divisions of the whole note. The value 4 means 1/4th of a whole note; 4. means 1/4 of a whole note plus half of that (1/8 of a whole note). Rhythms which are composed of equal divisions of whole notes plus augmentation dots can be represented in this system. But a problem occurs when trying to represent other rhythms as illustrated in Example 2.1, like triplet whole-notes or non-power-of-two tuplet bases.

Example 2.1: Difficult rhythms to represent in **recip data.



In other words when **recip encodes reciprocal durations of notes, the durations must always have a 1 in the numerator (excluding duration additions from augmentation dots). For example an eighth note is represented in **recip or **kern data as 8. This means that the duration of an eighth note is 1/8th that of a whole note. Likewise, 12 means 1/12 of a whole note which translates musically into “triplet eighth-notes”. Here is a demonstration of the calculations that relate 12 to a “triplet eighth-note”:

\[12 = \frac{1}{\frac{1}{8} \times \frac{2}{3}}\]

“1/8” is an eighth-note duration, and “2/3” is the tuplet relation of “three notes in the time of two”, or a “3:2” tuplet. By analogy, 5:3-tuplet eighth notes have the reciprocal duration of 40/3:

\[\frac{40}{3} = \frac{1}{\frac{1}{8} \times \frac{3}{5}}\]

This means that a 5:3-tuplet eighth note is equal to 3/40ths of a whole note. Notice that this duration is not a integral division of the whole note since the numerator of the duration (or the denominator in the reciprocal duration) is not 1. The difficulty in the standard **recip representation is that it includes a default value of 1 for the denominator of the reciprocal duration since only integers are allowed for rhythms in **recip data. The quarter note value 4 is more generally the ratio 4/1 with the “/1” implied in **recip data. The Humdrum Extras programs allow for the denominator to be any other positive integer. In order to represent the duration 3/40 in **recip data, the symbol 40%3 can be used, where the % sign indicates a reciprocal duration ratio with a denominator other than one is being represented.

Table 2.1: Sample rational encodings of rhythms in **recip and **kern representations.

Encoding Reciprocal dur. Dur. (whole-note units) Musical name
4 4/1 1/4 Quarter note
4%1 4/1 1/4 Quarter note
8%2 4/1 1/4 Quarter note
4. 4/1 + dot⇒8/3 1/4 + dot⇒3/8 Dotted quarter-note
1%2 1/2 2/1 Breve (double whole-note)
1%4 1/4 4/1 Longa (quadruple whole-note)
1%8 1/8 8/1 Maxima (octuple whole-note)
40%3 40/3 3/40 5:3-tuplet eighth-note
3 3/1 1/3 Triplet half-note
7 7/1 1/7 Septuple quarter-note
7%2 7/2 2/7 Septuple half-note
7%3 7/3 3/7 7:3-tuplet whole-note
3%2 3/2 2/3 Triplet whole-note
3%2. 3/2+dot⇒1/1 2/3+dot⇒1/1 Dotted triplet whole-note
1 1/1 1/1 Whole-note
3%4 3/4 4/3 Triplet breve
16%3 16/3 3/16 4:3-tuplet quarter-note
8. 8/1+dot⇒16/3 1/8+dot⇒3/16 Dotted eighth-note

Notice that the duration 3/16 at the bottom of the table can represent both 4:3-tuplet quarter notes and dotted eighth-notes (both have a duration of 0.75 quarter notes). The augmentation dot count is necessary in order to determine the musical name of the duration.

The rational-duration extension to the **recip representation is mostly backwards-compatible with **kern. The % sign is a user signifier in **kern, meaning it does not have a fixed meaning, and can be given a temporary meaning. For the rational rhythm extension this character is reserved to separate the two integers in a reciprocal duration value. Example 2.2 shows the method for generating compatible rhythms for standard Humdrum Tools that don’t recognize the extension use the rscale program to scale the rhythm to a timebase which does not require the extension. For example if the duration of triplet whole-notes are decreased by half, they become triplet half-notes which are representable in the standard **recip system.

Example 2.2: Halving note duration in a **kern score to remove rational rhythms. The -o option will read the !!rscale: 1/2 structured global command to return the the original rhythmic scale after processing with Humdrum Toolkit programs.

**kern
*M3/1
3%2c
3%2d
3%2e
*-
⇒ rscale -f 1/2 ⇒
**kern
*M3/2
3c
3d
3e
*-
!!!rscale: 1/2
**kern
*M3/2
3c
3d
3e
*-
!!!rscale: 1/2
⇒ rscale -o ⇒
**kern
*M3/1
3%2c
3%2d
3%2e
*-

“Zero” extension to **recip rhythm interpretation

A different extension to the **recip rhythm representation uses the symbol 0 (zero) for breves (double whole notes). Note that q is used to represent grace notes with a zero notated duration. Most rhythm-parsing Humdrum Toolkit programs (such as census) recognize this zero convention. By extension, the symbol 00 represents a longa (quadruple whole note), and 000 represents a maxima (octuple whole note); however, most Humdrum Toolkit rhythm-parsing programs do not understand these longer durations as well as exotic rhythm values such as 0000 for a double maxima, or 00000 for a quadruple maxima. Example 2.3 shows how the beat command converts zero rhythms into durations in quarter-note units.

Example 2.3: Duration of various large rhythms in quarter-note units using the “zero” representation.

**kern
4c
2d
1e
0f
00g
000a
0000b
00000c
*-
⇒ beat -d ⇒
**dur
1
2
4
8
16
32
64
128
*-

Compare this to durational equivalents from rational representations of the same rhythms in Example 2.4, where the analyzed durations of the **recip rhythms in the right column match to those in Example 2.3.

Example 2.4: Duration of various large rhythms in quarter-note units using the rational representation.

**kern
4c
2d
1e
1%2f
1%4g
1%8a
1%16b
1%32c
*-
⇒ beat -d ⇒
**dur
1
2
4
8
16
32
64
128
*-

Nested tuplets

Nested tuplets are a recursive representation of rhythm which allows for iterative non-binary subdivisions. It is a further generalization of rhythm that is not accounted for in the **recip representation. Consider the music in Example 2.5 where quintuplets and septuplets are further subdivided into other tuplets. In the top part of the example, the third quintuplet quarter-note is further divided into triplets, with two of those triplet notes even further subdivided into a quintuplet.

Example 2.5: Nested tuplets, with notes equal to 1/50 of a whole note marked in red (see Example 2.7 for the **recip representation of this music).



The reciprocal durations of the shortest notes on the top line of Example 2.5 (highlighted in red) are 50 in the **recip representation. The following equation demonstrates the process of dividing the quarter note three successive times to arrive at this rhythm value: the quarter note is first subdivided by 3/5 then by 1/2 and finally by 2/5:

\[\begin{split}50 & = & \frac{1}{\frac{1}{4} \times \left[\left(\frac{3}{5}\right)\left(\frac{1}{3}\right)\left(\frac{2}{5}\right)\right] } \\ & = & 4 \times \left[\left(\frac{5}{3}\right)\left(\frac{3}{1}\right)\left(\frac{5}{2}\right)\right] = 4 \times \frac{25}{2}\end{split}\]

Going from **recip data to graphical music notation poses a problem in the general case, since the ordering of the subdividing factors are not specified in the data token 50. In other words, this rhythm can be approached from any number of tuplet subdivisions of notes. Consider the smallest notes in Example 2.6. These are also represented as 50 rhythms, as can be seen in the following equation:

\[50 = 4 \times \left[\left(\frac{5}{4}\right)\left(\frac{2}{1}\right)\left(\frac{5}{1}\right)\right] = 4 \times \frac{25}{2}\]

Example 2.6: Alternate notational interpretation of the **recip token 50 (highlighted in red).



In order to disambiguate such cases, the ordering of the factors within the brackets in the above equations must be known. This can be done with tuplet layout codes in Humdrum data which give clues to notation renders on how to organize the notation. Layout codes are structured local comments which start with !LO:, followed by the specific layout code, which is TUP for tuplets, followed by a colon-separated list of parameters for the layout code. Example 2.7 show the music of Example 2.5 encoded as Humdrum **kern data. The layout code in the second spine on line 4 of the file (!LO:TUP:r=2.:t=5) indicates the outer quintuplet bracket. The r=2. parameter is the rhythm value (reciprocal duration) of the bracket, and the second parameter, t=5 indicates that the tuplet’s duration will be split into 5 equal parts.

Example 2.7: **recip encoding of the music in Example 2.5, including tuplet layout codes.

**kern**kern
*clefX*clefX
*M3/4*M3/4
!LO:TUP:r=2.:t=7!LO:TUP:r=2.:t=5
28%3L20%3
28%3.
.20%3
!!LO:TUP:r=20%3:t=3
28%3.
.20L
!!LO:TUP:r=10:t=5
28%3.
.50L@
.50@
.50@
.50@
!LO:TUP:r=28%3:t=4!
112%3LK.
.50JJ@
.20%3
56%3.
112%3Jk.
!LO:TUP:r=28%3:t=3!
28.L.
56k.
.20%3
28J.
28%3J.
==
*-*-
!!!RDF**kern: @ = marked note (rhythm of "50").




2.2. Rhythm scaling

The rscale program can be used to multiply or divide the duration of all rhythms in a score. The two main purposes of rhythmic scaling are (1) to remove rational rhythm representations, and (2) to switch between early and modern rhythm units for the beat.

The Humdrum Toolkit programs will not understand reciprocal rhythms such as 3%2 for triplet whole notes. Typically a datafile with rational rhythms will contain a line such as !!!rscale-alt: 1/2 which indicates that the original file contains reciprocal rhythms, and a rhythm-scaling by 1/2 will remove them. For example, if 3%2 (triplet whole-note) is halved, then the reciprocal rhythm becomes 3 (triplet half-note). See the rscale usage in Example 2.2 for such cases.

A related concept is the *rscale: tandem interpretation which indicates that a rhythmic scaling should be applied to a spine when creating graphical notation. This interpretation is used frequently in Humdrum scores of music from the early Renaissance created by the Josquin Research Project (also available on GitHub). Music of the fifteenth century was written in mensural notation, and the JRP edition tries faithfully preserve the original rhythm levels in modern notation, with the beat typically occurring at the whole-note level rather than the quarter note.

JRP Humdrum scores are in resolved notation, such that a whole note in one part is always equal in duration to a whole note in another part. When an original part is in a different rhythmic scaling from the other parts (typically the cantus firmus), the rhythms are scaled to match the other parts, along with an *rscale: interpretation giving the factor which needs to be applied to the part to generate rhythmic values of the original notation. Example 2.8 demonstrates this sort of case. Two parts switch to reverse-C mensuration in the second measure while at the same time, increasing their rhythmic durations by a factor of two. Notice that the first and third parts have two whole notes per measure at this point while the second and fourth parts have four whole notes per measure.

Example 2.8: Josquin, Missa L’homme armé sexti toni, Credo, mm. 234–7.


!!!COM: Josquin des Prez
!!!OTL: Missa L'homme armé sexti toni, Credo
**kern**kern**kern**kern
*clefF4*clefGv2*clefGv2*clefG2
*k[b-]*k[b-]*k[b-]*k[b-]
*M3/1*M3/1*M3/1*M3/1
*met(C|3)*met(C|3)*met(C|3)*met(C|3)
=234-=234-=234-=234-
1BB-0F1D1f
0GG.1.BB-1g
.1E.1b-
..2AA/.
=235=235=235=235
*M2/1*M2/1*M2/1*M2/1
*met(Cr)*met(C|)*met(Cr)*met(C|)
*rscale:2**rscale:2*
0FF[0F1C0a
..2r.
..2C/.
=236=236=236=236
1r0F]1D1.f
1FF.1C.
...4e/
...4d/
=237=237=237=237
2FF/1r0F2c/
1BB-..2d/
.1F.2B-/
2BB-/..2d/
====
*-*-*-*-


The music can easily be converted to resolved and reduced notation as shown in Example 2.9.

Example 2.9: Resolved and reduced version of the music in Example 2.8.

rscale -f 1/2 jrp://Jos0602c | autostem | sed 's/\*rscale:/*Xrscale:/g; s/\*met(/*Xmet(/g'
!!!COM: Josquin des Prez
!!!OTL: Missa L'homme armé sexti toni, Credo
**kern**kern**kern**kern
*clefF4*clefGv2*clefGv2*clefG2
*k[b-]*k[b-]*k[b-]*k[b-]
*M3/2*M3/2*M3/2*M3/2
*Xmet(C|3)*Xmet(C|3)*Xmet(C|3)*Xmet(C|3)
=234-=234-=234-=234-
2BB-/1F/2D/2f/
1GG/.2.BB-/2g/
.2E/.2b-\
..4AA/.
=235=235=235=235
*M2/2*M2/2*M2/2*M2/2
*Xmet(Cr)*Xmet(C|)*Xmet(Cr)*Xmet(C|)
*Xrscale:2**Xrscale:2*
1FF/[1F/2C/1a/
..4r.
..4C/.
=236=236=236=236
2r1F/]2D/2.f/
2FF/.2C/.
...8e/
...8d/
=237=237=237=237
4FF/2r1F/4c/
2BB-/..4d/
.2F/.4B-/
4BB-/..4d/
====
*-*-*-*-
!!!rscale: 1/2



2.3. Composite rhythm

The beat program can be used to calculate the duration of each line of a Humdrum file containing **kern or **recip data. Musically this called the composite rhythm, which is the rhythm of all parts considered as a single stream. The following musical example shows four parts on the top two staves along with a staff beneath showing the composite rhythm of all parts. In measures 1, 3 and 4, no single part contains a complete measure of eighth notes, but when considered together the rhythmic texture is a sequence of continuous eighth notes.

Example 2.10: J.S. Bach, Chorale Hilf, Gott, laß mir’s gelingen, BWV 343, mm. 16–19. Composite rhythm of all parts given on the bottom line of the system.

myank -m 16-19 h://371chorales/chor199.krn  | satb2gs | ridx -GL

⇒  beat -dp  ⇒
!!!COM: Bach, J.S.
!!!OTL: Hilf, Gott, laß mir’s gelingen
!!!SCT: BWV 343
**kern	**kern
*clefF4	*clefG2
*k[b-]	*k[b-]
*M3/4	*M3/4
*^	*^
=16-	=16-	=16-	=16-
8dL	4G	4.b-	4g
8e-J	.	.	.
8fnXL	4F	.	4.d
8FJ	.	8a	.
4G	4E-X	4g	.
.	.	.	8c
=17	=17	=17	=17
2A;y	2D;	2f#;	2d;y
[4d	4D	4a	4f#
=18	=18	=18	=18
8dL]	4.G	2b-	2g
8B-J	.	.	.
4e-	.	.	.
.	8E-X	.	.
8dL	[4B-	4dd	4fnX
8B-J	.	.	.
=19	=19	=19	=19
4G	4B-]	2cc	8enXL
.	.	.	8d
8cL	4A	.	8e
8AJ	.	.	8f#J
8B-L	4G	4b-	4g
8dJ	.	.	.
=	=	=	=
*v	*v	*	*
*	*v	*v
*-	*-
 
!!!COM: Bach, J.S.
!!!OTL: Hilf, Gott, laß mir’s gelingen
!!!SCT: BWV 343
**dur	**kern	**kern
*	*clefF4	*clefG2
*	*k[b-]	*k[b-]
*M3/4	*M3/4	*M3/4
*	*^	*^
=16-	=16-	=16-	=16-	=16-
0.5	8dL	4G	4.b-	4g
0.5	8e-J	.	.	.
0.5	8fnXL	4F	.	4.d
0.5	8FJ	.	8a	.
0.5	4G	4E-X	4g	.
0.5	.	.	.	8c
=17	=17	=17	=17	=17
2	2A;y	2D;	2f#;	2d;y
1	[4d	4D	4a	4f#
=18	=18	=18	=18	=18
0.5	8dL]	4.G	2b-	2g
0.5	8B-J	.	.	.
0.5	4e-	.	.	.
0.5	.	8E-X	.	.
0.5	8dL	[4B-	4dd	4fnX
0.5	8B-J	.	.	.
=19	=19	=19	=19	=19
0.5	4G	4B-]	2cc	8enXL
0.5	.	.	.	8d
0.5	8cL	4A	.	8e
0.5	8AJ	.	.	8f#J
0.5	8B-L	4G	4b-	4g
0.5	8dJ	.	.	.
=	=	=	=	=
*	*v	*v	*	*
*	*	*v	*v
*-	*-	*-

The -d option for beat is used to extract the duration of each data line. The -p option prepends the duration analysis data to the start of each line (-a will append the analysis data to the end of the line).

The -f option will display duration information as fractional ratio values instead of decimal numbers. When the -f option is used, the value of one represents the duration of a while note (rather than a quarter note with the default floating-point duration vales).

Example 2.11: Extracting durations as rational numbers instead of floating-point values.

myank -m 16-19 h://370chorales/chor199.krn | ridx -GL | beat -dpf
**dur**kern**kern**kern**kern
**clefF4*clefGv2*clefG2*clefG2
**k[b-]*k[b-]*k[b-]*k[b-]
**g:dor*g:dor*g:dor*g:dor
*M3/4*M3/4*M3/4*M3/4*M3/4
*MM100*MM100*MM100*MM100*MM100
=16-=16-=16-=16-=16-
1/84G8dL4g4.b-
1/8.8e-J..
1/84F8fnXL4.d.
1/8.8FJ.8a
1/84E-X4G.4g
1/8..8c.
=17=17=17=17=17
1/22D;2A;2d;2f#;
1/44D[4d4f#4a
=18=18=18=18=18
1/84.G8dL]2g2b-
1/8.8B-J..
1/8.4e-..
1/88E-X...
1/8[4B-8dL4fnX4dd
1/8.8B-J..
=19=19=19=19=19
1/84B-]4G8ennXXL2cc
1/8..8d.
1/84A8cL8e.
1/8.8AJ8f#J.
1/84G8B-L4g4b-
1/8.8dJ..
=====
*-*-*-*-*-

Example 2.12 gives an example of extracting the distribution of durations for the composite rhythm of 370 Bach chorales. First the composite rhythm is extracted from the chorales. Next the rhythm is stripped of its Humdrum syntax structure with ridx -H (which is equivalent to “rid -GLId | grep -v ^=”) and then the raw data lines are sorted and counted with sortcount.

Example 2.12: Create a frequency distribution of composite rhythm durations in 370 Bach chorales.

beat -df h://370chorales | ridx -H | sortcount -p
69.43	1/8
19.46	1/4
7.11	1/16
2.79	1/2
0.94	3/4
0.18	1
0.04	3/8
0.03	1/32
0.02	3/16
0.01	2
0.01	3/2

The most common composite rhythm value is the eighth note (69.43%), then in decreasing frequency: quarter note, sixteenth note, half note, dotted half note, whole note, dotted quarter note, 32nd note, dotted eighth note, breve, and dotted whole note.

Below is a more complicated example which contains a polyrhythmic composite rhythm. The right-hand rhythm in measure 9 is five eighth notes in the time of three which has a duration of:

\[\frac{3}{5} \times \frac{1}{8} = \frac{3}{40} \quad \mbox{whole notes}\]

The duration of 3/40th of a whole note is represented in extended **recip by the rhythm value 40%3. Likewise, the septuplets in the last measure are \(\scriptstyle 3/7 \times 1/8 = 3/56\) whole notes, which is the **recip rhythm 56%3.

Example 2.13: F. Chopin, Nocturne in B major, op. 9/3, mm. 8–10.

beat -dpf
!!!COM: Chopin, Frédéric
!!!OTL: Nocturne in B Major, op. 9/3
**dur**kern**kern
**clefF4*clefG2
**k[f#c#g#d#a#]*k[f#c#g#d#a#]
=8-=8-=8-
1/8(8FF#\L[2a#/
1/88C#\.
1/88A#\.
1/88F#\.
1/248e\24a#]/LL
1/24.(24e#/
1/24.24f#/J
1/328A#\J)32g#/LL
1/32.32a#/
1/32.32b/
1/32.32c/JJJ)
=9=9=9
3/40(8BB\L(40%3d#\L
1/20.40%3fn\
**^*
1/40
8F#\4F#/
.
3/40
..
40%3e\
1/40
..
40%3c##\
1/20
8f#\J).
.
3/40
..
40%3d#\J)
*
*v*v
*
3/40(8BB\L(40%3dn\L
1/20.40%3e\
**^*
1/40
8Fn\4Fn/
.
3/40
..
40%3d#\
1/40
..
40%3c#\
1/20
8fn\J).
.
3/40
..
40%3dn\J)
*
*v*v
*
=10=10=10
1/88BB\L[4.c#^
**^*
1/8
8E\4E/
.
1/8
8e\J.
.
*
*v*v
*
3/568BB\L(56%3c#]\LL
3/56.56%3b#\
1/56.56%3c#\
**^*
1/28
8Gn\4Gn/
.
3/56
..
56%3c##\
1/28
..
56%3d#\
1/56
8gn\J.
.
3/56
..
56%3e\
3/56
..
56%3e#\JJ)
*
*v*v
*
===
*-*-*-