Humdrum Quick-Start Tutorial


Having installed the Humdrum Toolkit, you will be eager to see Humdrum in action. Begin by changing directories to the Humdrum demonstration directory. This is located in the subdirectory demo under the directory where you installed Humdrum. In most cases, you can change directories by typing the command:
cd /humdrum/demo
This directory holds a number of tutorial files, and also includes a subdirectory containing a selection of musical scores encoded in various Humdrum formats.

Begin by typing:

demo
This demonstration will first ask you whether you have an appropriate MIDI set-up. Answer `yes' only if your system runs Windows 95/98/NT, DOS or OS/2 and has a Roland MPU-401-compatible MIDI card with a MIDI synthesizer connected for sound output. (Answering `no' will restrict the demonstration to outputs that don't involve sound.)

The Humdrum demo will provide a menu of ten sample problems. Each problem will pose and answer some analytic question in real-time. (On older machines, some of the sample calculations may take several minutes to execute.) You can stop the demo at any time by typing one or more control-Cs.

If your system is configured for MIDI output, you might also try changing directories to the scores subdirectory and playing one of the scores. A MIDI version of the first movement of Haydn's string quartet Opus 76, No. 3, is encoded in the file haydn76.hmd.

Begin by typing the command:

perform misc/haydn76.hmd
If your MIDI system is properly configured, you should hear a deadpan performance of the work. Try typing various numbers followed by . This will move the performance immediately to the corresponding numbered measure. (If you enter a number greater than the total number of measures, playback will terminate.) Type plus (+) or minus (-) to move ahead or backward one measure at a time. Press the space-bar to interrupt play. Also try typing `<' and `>' to slow-down or speed-up the tempo. (Notice that you don't have to use the shift-key when typing `<', `>' or `+'.) You might also want to explore the search commands. Try typing a slash (/) followed by the word `Development', followed by . To search backward from the current score position, use the question mark (?) rather than the slash -- as in `?Exposition' . To end, type the escape key . If your MIDI instrument continues to sound after the perform program has ended, type:
tacet
This will turn-off any sounding tones.

You may want to view the accompanying videocassette in order to further familiarize yourself with the capabilities of the Humdrum Toolkit. Ultimately, you will need to begin reading the Humdrum Users' Guide and start working through the tutorial exercises. As with the study of a musical instrument, practice is essential to developing a skill.


How HUMDRUM Works

Some users may be interested in gaining a basic understanding how the Humdrum tools work. The following description provides a general outline of the operation of the Humdrum tools.

The Humdrum tools were developed with several criteria in mind. The foremost criterion was that the tools needed to be easy to program. Most of the tools are written in the AWK programming language -- a "fast prototyping language" whose syntax is very similar to that of the C programming language. AWK was developed by Alfred Aho, Brian Kernighan, and Peter Weinberger (hence the name AWK). AWK is especially well suited to musical applications since AWK provides extensive, yet simple-to-use facilities for matching and manipulating strings patterns.

Since AWK is an interpreted language, AWK programs must invoke the AWK interpreter each time they are executed. The command-line syntax for invoking AWK programs is cumbersome. In order to simplify the command-line syntax, special-purpose "shell scripts" have been used to massage the command invocation, to parse the options, and to provide help screens where appropriate.

Most Humdrum commands cause a shell-script to be executed. Each script invokes the AWK interpreter and calls the appropriate AWK program. The shell-scripts were written in the well-known UNIX Kornshell. On Windows 95/98/NT, DOS and OS/2 these scripts are held in files designated by the .ksh extension. These scripts can also be executed from the Bourne shell, but they are not compatible with the UNIX C shell.

A typical Humdrum command, such as the kern command, is associated with two files: kern.ksh (or just kern on UNIX) and kern.awk. The .awk script acts as both the "source" code and the "executable" code. Both .ksh and .awk files are ordinary ASCII files, and so can be examined and (potentially) modified by the user.

Some more complicated Humdrum commands have been partitioned into several subprograms. For example, the Humdrum extract command consists of four separate programs, extract1.awk, extract2.awk, and so on. The associated shell script (extract.ksh) determines which of the extract programs should be invoked, on the basis of the user-selected options.

More computationally intensive programs have been written in the C programming language. These include Humdrum commands such as perform and simil. On Windows 95/98/NT, DOS, the perform.exe, simil.exe, ... files are executable files, compiled from C programs. The Humdrum distribution disks include the complete source code (.c files) for all of these commands.

In order to be able to execute Humdrum commands, several conditions need to be satisfied. First, either the Kornshell or Bourne shell command interpreter must be available. Second, the AWK language interpreter must be available. Third, four pieces of information must be accessible to the shell: (1) the shell must know where to find the Humdrum commands, (2) it must know where to find the AWK interpreter, (3) it must know where it can store temporary files, and (4) it must be told where to direct standard error outputs (on UNIX normally /dev/tty; on Windows 95/98/NT, DOS this is con. Each of these four pieces of information need to be stored in shell "environment" variables. The variables are named PATH, AWK_VER, TMP, and CON.

When you boot your system, these variables need to be assigned properly, otherwise the installed Humdrum tools will fail to work.


Trouble-Shooting Tips

The table below lists some common errors associated with faulty or incomplete installation of the Humdrum Toolkit. Further information is available to help with trouble-shooting. .cs I 18
 
Error Possible cause
=
Bad command or file name Kornshell has not been installed or PATH
has not been properly set.
glob: EXEC error Install invoked from Windows without
opening a shell.
not found PATH not set correctly or command has
not been copied into the Humdrum directory.
: -f: not found AWK_VER shell variable not set.
: awk: not found "awk" not in current PATH (DOS/OS2).
: nawk: not found "nawk" not in current PATH (UNIX).
awk: script file "<progname.awk>": HUMDRUM shell variable not set, or PATH
no such file or directory not set correctly.
_main: memory allocation failure Input file(s) too big to handle; try breaking
the input into smaller segments (using
`yank'), and process each segment separately.
Assemble back together by using `cat'.
pc: compiler error ... Humdrum `pc' command conflicts with a
Pascal language compiler named `pc'.
Rename Humdrum `pc.ksh' and `pc.awk' files.

Copyright © 1993, 1999 David Huron


UNIX is a registered trademark of Unix System Laboratories Incorporated. PC-DOS and OS/2 are registered trademarks of IBM Corporation. MS-DOS, Windows, Windows 95, Windows 98, and Windows NT are registered trademarks of Microsoft Corporation. Macintosh, Classic, Quadra, Power Mac, Powerbook, and G3 are registered trademarks of Apple Computers Incorporated. MKS and MKS Toolkit are registered trademarks of Mortice Kern Systems Incorporated.