Musical Information (Mus 253/CS 275A)
Introduction to the Humdrum Toolkit

Humdrum

    [because of the wealth of material about humdrum generated by its author David Huron and by Craig Sapp, much material in this lecture can't escape being at least inspired in some way by those sources. Acknowlegement is presented whenever direct use of such material occurs]

    "Humdrum is a general-purpose software system intended to assist music researchers. " (Humdrum Online Guide)

    Main components: syntax (i.e. kern) and tools or command line programs (i.e. humdrum, transpose).

    Command Reference: http://dactyl.som.ohio-state.edu/Humdrum/commands

File format

    Humdrum files are text files with data grouped in rows and tab separated columns. Every column must have a 'header' consistent of a word preceded by two asterisks (**column) and must be terminated with an asterisk and a hyphen (*-). One of the most common representations is **kern which has a standardized format for pitch height values, durations, and other common music notation items.

    Humdrum Syntax http://csml.som.ohio-state.edu/Humdrum/guide05.html

    Kern http://csml.som.ohio-state.edu/Humdrum/representations/kern.html

Obtaining Information from Humdrum files

    Many questions can be answered through simple regular expression search, followed by counting or classification of some sort; in some cases, modification of files is also necessary, and some way of summarizing results can be useful too. Typical questions are some kind of variation of the following (Humdrum News #1):

      How many different types of _____ are there? What is the most/least common _____? What is the frequency of occurrence for various _____s?

Example

    **foo		**foo		1 *foo
    A		*-		1 *-
    B		A		3 A
    A      sort	A    uniq -c	2 B	rid (humdrum command) can be used to
    A		A		1 C	ignore certain intrepretations.
    C		B			
    B		B		The whole process can be piped (assuming the
    *-		C		initial data exists in a file named foo)
    				
    rid -GLId foo | sort | uniq -c > inventory.foo (exp#1)
    
    What if data appears in different columns?
    **foo	**bar		1 A	A
    A	G		2 A	G	extract (humdrum command) allows 
    B	G		2 B	G	to treat each column independently
    A	G	exp#1	1 C	G	(assume initial data in file foobar)
    A	A		
    C	G		extract -i '**foo' foobar | exp#1
    B	G		extract -i '**bar' foobar | exp#1 	
    *-	*-							or
    			extract -i '**foo' foobar > justfoo
    			extract -i '**bar' foobar > justbar	
    								resulting in
    **foo								
    A								
    B
    A
    A					
    C
    B
    *-								4 A
    **bar			rid -GLId foobar.cat | sort | uniq -c	2 B
    G								1 C
    G								5 G
    G
    A
    G
    G
    *-
    
    

Exercises

    Now together with the command 'census', let's answer some typical questions:
    1. How many measures are there in Corelli's Opus 1, No. 11, first movement?
    2. How many notes are there in the oboe part from the first movement of Bach's Brandenburg Concerto No. 2 (BWV 1047)? Should the oboe player be payed more or less than the cello players?
    3. Which Brandenburg Concerto contains a horn part? Which movements from this concerto don't use the horn?
    4. Which Brandenburg Concerto contains a trumpet part? How long is the longest note played by the trumpet? How long is the shortest note played by the trumpet?
    5. In Brandenburg Concerto No. 3, which movement contains the greatest number of notes in the string parts?
    see files in /usr/ccarh/humdrum/scores/
answers.












Rodrigo Segnini
Revised: 3 Mar 2005