.. ####### AUTOMATICALLY GENERATED TEXT, DO NOT EDIT ###### .. |rarrow| unicode:: 0x21d2 :trim: .. |nbsp| unicode:: 0xA0 :trim: .. Humdrum Extras Chapter Sequence: 1: Introduction 2: Rhythm 3: Melody and Pitch 4: Harmony 5: Data Entry 6: Music Searching 7: MIDI Rendering 8: Notation Rendering 9: Other Useful Tools .. Section counters for the "Rhythm and Time" chapter: 1: **kern and **recip Extensions 2: Rhythm scaling 3: Composite rhythms .. ######################################################################## =========================================================================== 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:Start: 2.1 **Example 2.1:** Difficult rhythms to represent in \*\*recip _ data. .. image:: rhythm.rstd/Example_53eighth/53eighth.svg :align: center :width: 100% .. :Example:End: 2.1 | | 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": .. math:: 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: .. math:: \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:Start: 1 **Table 2.1:** Sample rational encodings of rhythms in \*\*recip _ and \*\*kern _ representations. .. csv-table:: :header: 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 |rarrow| 8/3, 1/4 + dot |rarrow| 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 |rarrow| 1/1, 2/3+dot |rarrow| 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 |rarrow| 16/3, 1/8+dot |rarrow| 3/16, Dotted eighth-note .. :Table:End: 2.1 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:Start: 2.2 **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. .. raw:: html
 .. literalinclude:: rhythm.rstd/Example_halve/tripletwholenotes.krn :language: humdrum .. raw:: html ⇒ rscale -f 1/2 ⇒ .. literalinclude:: rhythm.rstd/Example_halve/triplethalfnotes.krn :language: humdrum .. raw:: html
.. raw:: html
 .. literalinclude:: rhythm.rstd/Example_halve/triplethalfnotes.krn :language: humdrum .. raw:: html ⇒ rscale -o ⇒ .. literalinclude:: rhythm.rstd/Example_halve/tripletwholenotes-original.krn :language: humdrum .. raw:: html
.. :Example:End: 2.2 "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:Start: 2.3 **Example 2.3:** Duration of various large rhythms in quarter-note units using the "zero" representation. .. raw:: html
 .. literalinclude:: rhythm.rstd/Example_zerobig/zero.krn :language: humdrum .. raw:: html ⇒ beat -d ⇒ .. literalinclude:: rhythm.rstd/Example_zerobig/zero-beat-d.krn :language: humdrum .. raw:: html
.. :Example:End: 2.3 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:Start: 2.4 **Example 2.4:** Duration of various large rhythms in quarter-note units using the rational representation. .. raw:: html
 .. literalinclude:: rhythm.rstd/Example_ratbig/zero-rational.krn :language: humdrum .. raw:: html ⇒ beat -d ⇒ .. literalinclude:: rhythm.rstd/Example_ratbig/zero-rational-beat-d.krn :language: humdrum .. raw:: html
.. :Example:End: 2.4 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:Start: 2.5 **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). .. image:: rhythm.rstd/Example_messy/messy.svg :align: center :width: 60% .. :Example:End: 2.5 | | 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: .. math:: 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} 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: .. math:: 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:Start: 2.6 **Example 2.6:** Alternate notational interpretation of the \*\*recip _ token 50 (highlighted in red). .. image:: rhythm.rstd/Example_nested2/nested2.svg :align: center :width: 60% .. :Example:End: 2.6 | | 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:Start: 2.7 **Example 2.7:** \*\*recip _ encoding of the music in Example 2.5, including tuplet layout codes. .. raw:: html
 **kern **kern *clefX *clefX *M3/4 *M3/4 !LO:TUP:r=2.:t=7 !LO:TUP:r=2.:t=5 28%3L 20%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").
.. :Example:End: 2.7 | | | | 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:Start: 2.8 **Example 2.8:** Josquin, Missa *L'homme armé* sexti toni, Credo _, mm. 234--7. .. image:: rhythm.rstd/Example_jos0602c/jos0602c.svg :align: center :width: 100% | .. raw:: html
 !!!COM: Josquin des Prez !!!OTL: Missa L'homme armé 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- 0F 1D 1f 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 [0F 1C 0a . . 2r . . . 2C/ . =236 =236 =236 =236 1r 0F] 1D 1.f 1FF . 1C . . . . 4e/ . . . 4d/ =237 =237 =237 =237 2FF/ 1r 0F 2c/ 1BB- . . 2d/ . 1F . 2B-/ 2BB-/ . . 2d/ = = = = *- *- *- *-
.. :Example:End: 2.8 | | The music can easily be converted to resolved and reduced notation as shown in Example 2.9. .. :Example:Start: 2.9 **Example 2.9:** Resolved and reduced version of the music in Example 2.8. .. image:: rhythm.rstd/Example_reduced/reduced.svg :align: center :width: 100% .. raw:: html
rscale -f 1/2 jrp://Jos0602c | autostem | sed 's/\*rscale:/*Xrscale:/g; s/\*met(/*Xmet(/g'
 !!!COM: Josquin des Prez !!!OTL: Missa L'homme armé 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 2r 1F/] 2D/ 2.f/ 2FF/ . 2C/ . . . . 8e/ . . . 8d/ =237 =237 =237 =237 4FF/ 2r 1F/ 4c/ 2BB-/ . . 4d/ . 2F/ . 4B-/ 4BB-/ . . 4d/ = = = = *- *- *- *- !!!rscale: 1/2
.. :Example:End: 2.9 | | | 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:Start: 2.10 **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. .. image:: rhythm.rstd/Example_compositebach/chor199i.svg :align: center :width: 100% :alt: myank -m 16-19 h://371chorales/chor199.krn | satb2gs | ridx -GL | .. raw:: html
 ⇒  beat -dp  ⇒ .. literalinclude:: rhythm.rstd/Example_compositebach/durationoutput-dp.krn :language: humdrum .. raw:: html
.. :Example:End: 2.10 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:Start: 2.11 **Example 2.11:** Extracting durations as rational numbers instead of floating-point values. .. raw:: html
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/8 4G 8dL 4g 4.b- 1/8 . 8e-J . . 1/8 4F 8fnXL 4.d . 1/8 . 8FJ . 8a 1/8 4E-X 4G . 4g 1/8 . . 8c . =17 =17 =17 =17 =17 1/2 2D; 2A; 2d; 2f#; 1/4 4D [4d 4f# 4a =18 =18 =18 =18 =18 1/8 4.G 8dL] 2g 2b- 1/8 . 8B-J . . 1/8 . 4e- . . 1/8 8E-X . . . 1/8 [4B- 8dL 4fnX 4dd 1/8 . 8B-J . . =19 =19 =19 =19 =19 1/8 4B-] 4G 8ennXXL 2cc 1/8 . . 8d . 1/8 4A 8cL 8e . 1/8 . 8AJ 8f#J . 1/8 4G 8B-L 4g 4b- 1/8 . 8dJ . . = = = = = *- *- *- *- *-
.. :Example:End: 2.11 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:Start: 2.12 **Example 2.12:** Create a frequency distribution of composite rhythm durations in 370 Bach chorales. .. raw:: html
 beat -df h://370chorales | ridx -H | sortcount -p .. literalinclude:: rhythm.rstd/Example_durfreq/chorale-composite-rhythm.txt :language: humdrum .. raw:: html
.. :Example:End: 2.12 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. .. note: The is a small bug in that composite rhythm of tied notes will not be extracted properly. Consider the following example: **kern 1c = [2c 2c] == *- This should have a composite rhythm of two whole notes, but the tied note duration value is given as a half note instead of a 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: .. math:: \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 :math:\scriptstyle 3/7 \times 1/8 = 3/56 whole notes, which is the \*\*recip _ rhythm 56%3. .. :Example:Start: 2.13 **Example 2.13:** F. Chopin, Nocturne in B major, op. 9/3, mm. 8--10. .. image:: rhythm.rstd/Example_nocturne/noc9-3.svg :align: center :width: 100% .. raw:: html
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
*
===
*-*-*-
.. :Example:End: 2.13