Humdrum Lab 1

From CCARH Wiki
Jump to navigation Jump to search


Bach Chorales

Download

A Humdrum edition of 4-Part Chorales by J.S. Bach is available at http://kern.ccarh.org/browse?l=371chorales

The data files can be downloaded using the humcat and humsplit commands (first creating a new directory to store all of the downloaded files):

    mkdir chorales
    cd chorales
    humcat -s h://370chorales | humsplit

This should create 370 files in the format chor001.krn, chor002.krn, chor003.krn, etc. For OS X, you can type "cd ~/Desktop" (without the quotes) before the above three commands to make the folder called "chorales" visible on the Desktop.

MIDI rendering

Convert a particular chorale into a MIDI file with this command:

    hum2mid chor001.krn -o chor001.mid

The data file can also be downloaded on demand:

    hum2mid h://370chorales/chor001.krn -o chor001.mid

Once the MIDI file has been created, you can open it by double-clicking in a file browser. On OS X computers, you can type:

   open chor001.mid

to do the equivalent of double-clicking. You must have a MIDI player associated with the file. For newer OS X computers, you will have to download Quicktime 7 in order to play the MIDI file (recent versions of Quicktime cannot play MIDI files).

To pan the voices in the stereo field, try the --autopan option:

    hum2mid --autopan chor001.krn -o chor001pan.mid

Graphical Music Notation

These examples use muse2ps to generate graphical notation. Music can also be notated with abcm2ps via the export to ABC+ notation with hum2abc, or to MuseScore and similar notation programs which import MusicXML using hum2xml. To convert from PostScript output from muse2ps into PDF, the ps2pdf script is used (part of the GhostScript package). GhostScript typically comes installed by default on linux computers, OS X computers will need to install with a package management system such as Homebrew. But Preview.app in OS X will view PostScript file without any problems (just slightly slower while it converts them into PDF files).

Printing in a 4-staff format:

     autostem chor001.krn | hum2muse | muse2ps | ps2pdf - - > output.pdf

Note that the chorale data does not contain stem directions, and that muse2ps require them. The autostem program add stem directions to the data. Programs such as abcm2ps will determine the stem directions internally:

     hum2abc chor001.krn | abcm2ps - -O - | ps2pdf - - > output.pdf

Printing in a grand-staff format:

     satb2gs chor001.krn | autostem | hum2muse | muse2ps | ps2pdf - - > output.pdf

Applying formatting options to the last command for prettier graphical notation:

      satb2gs chor001.krn | autostem | hum2muse | muse2ps =z21jI50v120,120 \
        | ps2pdf - - > output.pdf

which should produce the following graphical notation:

Humdrumlab1-chor001-notation.png

Key

Each chorale is hand-labeled with a musical key. To generate a histogram of key designations in the chorales:

  extract -f 1 *.krn | grep '\*.*:' | sort | uniq -c | sort

The regular expression "\*.*:</tt"> translates into English as: "find lines which have a subset of characters starting with '*' then any number of characters (.*) and then end with ':'.

Questions:

  1. What is the most common key?
  2. What is the most common major key?
  3. What is the most common minor key?
  4. What is the least common major key (other than zero counts)?
  5. What is the least common minor key (other than zero counts)?
  6. How many chorales are labeled as being in a modal key? Such as *G:mix for G mixolydian.


Computational Key Identification

Use the keycor program to have the computer measure the key of the chorales:

   keycor chor001.krn

The computer should reply:

   The best is key G major

Compare this to the hand-labeled key:

    egrep -i '^\*[A-G][-|#]?:' chor001.krn

Here is a bash for-loop which can be used to examine the key one chorale at a time:

  for i in *.krn
  do
     echo $i analysis:
     keycor $i
     egrep -i '^\*[A-G][-|#]?:' $i
     echo =====================
  done | less

Questions:

  1. Find a chorale where the hand-labeled key does not match the automatically identified key.
  2. Take that chorale, and run the following commands on it. Do these all give the same key analysis?:
  keycor  chorXXX.krn  --aa
  keycor  chorXXX.krn  --bb  
  keycor  chorXXX.krn  --kk
  keycor  chorXXX.krn  --kp
  keycor  chorXXX.krn  -s

Transposition

The Humdrum Extras program transpose can be used to transpose chorales to another key with the -k option. For example, tranpose the first chorale into F# major:

     transpose -k F# chor001.krn | less

Printing the transposed chorale:

     transpose -k f# chor001.krn | autostem | hum2muse | muse2ps =z21jI50v120,120 \
         | ps2pdf - -  > output.pdf
Humdrumlab1-chor001-notation-fsharp.png

Vocal Range

To count all of the notes by pitch-class for each vocal part, use the prange command. Here is a sample command which extracts the bass part data:

  extract -f 1 *.krn | prange

or alternatively extracting by text pattern (Bass, Tenor, Alto, Soprano):

   extractx -g Bass *.krn | prange

For the bass part, the lowest note is CC (C2) and the highest note is e (E4), with a total vocal range of 28 semitones. The average (base-12) pitch is E- (E-flat 3), which is both the mean and median.

Do a similar vocal range analysis on the other three parts.

Questions:

  1. Which voice has the widest range?
  2. What is the highest and lowest note for each vocal part?

Scale Degrees

The deg command can be used to calculate the scale degree of each note if the key has been indicated. Here is a command to count how often each scale degree occurs in the chorales:

  serialize *.krn | deg -a | ridx -H | sed 's/[^1-7]//g' | sort | uniq -c 

This should produce the result:

  1090 
 15701 1
 11271 2
 12507 3
 10730 4
 16231 5
  8934 6
 10428 7

The sortcount program can handle sorting and counting. Here is an example with the -p option showing the relative frequency of each scale degree in the data:

  serialize *.krn | deg -a | ridx -H | sed 's/[^1-7]//g' | grep -v '^$' | sortcount -ph
 **pcent     **data
 18.92       5
 18.3        1
 14.58       3
 13.14       2
 12.51       4
 12.15       7
 10.41       6
 *-          *-

The dominant (5) is the most common, and the submediant (6) is the least common.

Question:

  1. Using the following template, what are the scale-degree frequencies in each part? Are there any differences?
    extractx -g Bass *krn | deg -a | ridx -H |  sed 's/[^1-7]//g' | grep -v '^$' | sortcount -ph

Melodic Intervals

Tritones can be notated as augmented 4ths (such as C-F) or diminished fifths (such as C–G).

    serialize *.krn | mint | ridx -H | grep A4 | wc -l
    serialize *.krn | mint | ridx -H | grep d5 | wc -l

Questions:

  1. Which of these two spellings of the tritone are more common in the chorales?
  2. How often do octaves (P8) occur in the chorales?
  3. For the diminished fifth, what is the most common direction for the melodic interval, up or down? Here are commands to answer this question:
    serialize *.krn | mint | ridx -H | grep +d5 | wc -l
    serialize *.krn | mint | ridx -H | grep -- -d5 | wc -l

The double dash after grep in the second command indicates the end of options for grep, so that the string "-d5" is treated as the query rather than as the option -d5.

Searching

Create a search index for the chorales:

    tindex *.krn > chorales.index

Search for the melodic sequence "C D E F G A B C", counting how many chorales it occurs within:

   themax -p "cdefgabc" chorales.index | wc -l

To locate the pattern within the music:

   themax -p "cdefgabc" chorales.index --loc | theloc

which should return the result:

  chor190.krn::1	58=10B2-65=11B3
  chor325.krn::1	17=5B1-24=6B4

This means that the melodic pattern "cdefgabc" occurs in two chorales (190 and 325). In both cases, the bass part (::1) has the pattern. The pattern occurs from note 58 to 65 in the bass part to chorale 190 which is from measure 10 beat 2 until measure 11 beat 3. Similarly, the pattern occurs in the bass part of chorale 325 in measure 5 to 6.

The search matches can be marked in the original data:

   themax -p "cdefgabc" chorales.index --loc | theloc -m | less

Each matched note will be prefixed with an "@" sign. Search for these marks in measure 10/11 and 5/6 in the two chorales.

To pull out the measures which contain the matched notes:

       themax -p "cdefgabc" chorales.index --loc | theloc -m | myank --marks

To display matches highlighted in graphical notation:

   themax -p "cdefgabc" chorales.index --loc | head -n 1 | theloc -m \
       | autostem | hum2muse | muse2ps | ps2pdf - -  > output.pdf

Questions:

  1. Search for another pattern, and report your findings.

The themax command can search for other melodic features, such as interval, contour, rhythm, meter. Here are some more example applications:

Tritone

The melodic interval search in themax can be used to locate melodic intervals (see the mint command above). Here are searches for augmented fourths and diminished fifths in the chorales:

  themax -I "A4" chorales.index  --total
  themax -I "d5" chorales.index  --total