1 of 37

Accessing Humdrum data

Craig Stuart Sapp

Music 254/CS275B

Stanford University

30 March 2021

http://bit.ly/humdrum-data

2 of 37

Downloading a single file

humcat h://chorales/chor001.krn

If Humdrum Extras is installed (see https://github.com/humdrum-tools/humdrum-tools), then running the humcat command in a unix terminal will download a Bach chorale:

Notice that the data prints to the terminal. The view on the left shows the end of the downloaded data.

3 of 37

Paging through a single file

humcat h://chorales/chor001.krn | less

| = “pipe” character: takes output from one program and gives as input to the next program

less = unix command to page through a text file on the command-line. Type space bar for next page, or ESC key to exit less program.

See https://en.wikipedia.org/wiki/Less_(Unix)

Also type the command man less to see online documentation for the less command.

Instead of printing the file in one continuous stream to the terminal, it can be sent to the less program, which will display the data one page at a time:

4 of 37

Saving a single file

humcat h://chorales/chor001.krn > chor001.krn

> = File redirection: saves the output of the humcat program into a file rather than printing to the screen. To view saved file:

less chor001.krn

Also, an equivalent result using this pipeline:

cat chor001.krn | less

5 of 37

Downloading multiple files to one file

humcat -s h://chorales > chorales.krns

The -s option is required (to keep data in separate segments). chorales.krns contains all 370 chorales in one file.

less chorales.krns

Page through contents:

All of the 370 chorales in the data set can be downloaded and saved to a single file:

6 of 37

Downloading multiple files to multiple

mkdir chorales

cd chorales

humsplit h://chorales

Downloads a stream of all chorales, but then splits them into separate files. Best to do that in a new directory(=folder).

ls -asCF

mkdir = make a new directory (folder)

cd = change directory (go into chorales directory)

View the files in the terminal:

7 of 37

Split combined file into separate files

humcat -s h://chorales > chorales.krns

humsplit chorales.krns

Files containing multiple works, can be split into separate files after downloading:

The first line downloads all of the chorales and saves to a single files (chorales.krns).

The second line splits the individual files stored in chorales.krns into separate files. After running this command (preferably in an empty directory), you will have 371 files: the chorales.krns combined file, and 370 separate chorale files.

8 of 37

Viewing list of files in directory

ls -asCF

-a = show all files (including hidden ones)

-s = show size of file as number in front of filename (in “blocks” ≅ kB)

-C = show in columns (usually automatic)

-F = show function (appends ‘/’ for directory, ‘*’ for program)

ls is a unix command to list files in a directory (the same as a “folder”). Type man ls to see documentation about options for the ls command.

9 of 37

kernScores

Command-line data is downloaded from http://kern.humdrum.org

Note browse link

10 of 37

Essen folksong collection

http://kern.ccarh.org/browse?l=essen

This “z” button allows downloading

of the Essen collection as a

zip file (may take some time to

zip and download).

11 of 37

Bach chorales on kernScores

http://kern.humdrum.org/data?l=users/craig/classical/bach/371chorales

Shortcut:

http://kern.humdrum.org/data?l=chorales

humcat h://chorales

humcat h://users/craig/classical/bach/371chorales

Files can be downloaded from the command line by taking the value of the “l” parameter in the URL and adding “h://” (or “humdrum://” unabbreviated) to the command-line use:

Also, this “z” button will download a zip file of all works listed on this page.

12 of 37

Location shortcuts

Shortcuts for more interesting repertories

Note shortcut link

13 of 37

Location shortcuts

Shortcuts for more interesting repertories

Note shortcut link

14 of 37

Location shortcuts

humcat -s h://corelli/op1 > corelli-op1.krns

humcat -s h://corelli/op3 > corelli-op3.krns

humcat -s h://corelli/op4 > corelli-op4.krns

humcat -s h://corelli/op5 > corelli-op5.krns

humcat -s h://corelli/op6 > corelli-op6.krns

Humdrum files for Corelli music, converted from MuseData:

See PDF links to scores on http://corelli.ccarh.org

(op.2 is not online)

15 of 37

Github

Humdrum data collection is downloadable from https://github.com/humdrum-tools/humdrum-data

Contains mirror of larger repertories from kernScores.

16 of 37

Bach chorales repository on Github

Humdrum-data is a meta-repository of other repertory-specific repositories.

Example: Bach chorales: https://github.com/craigsapp/bach-370-chorales

17 of 37

Mozart piano sonatas on Github

https://github.com/craigsapp/mozart-piano-sonatas

Command-line download:

humcat -s h://mozart/sonatas > mozart-sonatas.krns

18 of 37

Beethoven piano sonatas on Github

https://github.com/craigsapp/beethoven-piano-sonatas

Command-line download:

humcat -s h://beethoven/sonatas > beethoven-sonatas.krns

19 of 37

Beethoven string quartets on Github

https://github.com/craigsapp/beethoven-string-quartets

Command-line download:

humcat -s h://beethoven/quartets > beethoven-quartets.krns

20 of 37

Scott Joplin on Github

https://github.com/craigsapp/joplin

Command-line download:

humcat -s h://joplin > joplin.krns

(mostly complete)

21 of 37

Josquin Research Project

http://josquin.stanford.edu

(front-end)

Polyphonic music from 1450-1525 (Early Renaissance)

22 of 37

JRP data on Github

https://github.com/josquin-research-project/jrp-scores

23 of 37

Command-line JRP data access

humcat jrp://Jos2721

Download a single file by catalog number:

http://josquin.stanford.edu/work/?id=Jos2721

humcat -s h://jrp/Jos

Download all works by a particular composer (using composer’s three-letter code):

http://josquin.stanford.edu/browse/?home=true

See a list of the composer codes on the jrp-scores github repository, or view the list on the JRP browse page:

24 of 37

Download JRP scores by genre

humcat -s h://jrp/Zso

Download all secular songs (by all composers):

humcat -s h://jrp/Zmo

Download all motets (religious songs):

humcat -s h://jrp/Zma

Download all masses:

25 of 37

Special JRP groupings

humcat -s h://jrp/Jos

Download all works attributed to Josquin:

humcat -s h://jrp/Joa

Download all works securely attributed to Josquin:

humcat -s h://jrp/Job

Download all Josquin works that are not securely attributed to him:

26 of 37

Tasso in Music Project

http://www.tassomusic.org

(front-end)

Digital Edition of the settings of Torquato Tasso's poetry, c. 1570–1640 (Late Renaissance)

27 of 37

Multiple compositions to same poem

Good for word-painting analysis projects

Ruggiero Giovannelli

Giovan Domenico Montella

Carlo Gesualdo

http://www.tassomusic.org/settings/?id=Trm0047

28 of 37

Tasso data on Github

https://github.com/TassoInMusicProject/tasso-scores

Command-line download:

humcat -s h://joplin > joplins.krns

Easy repertory for

style simulation

29 of 37

Verovio Humdrum Viewer scores menu

30 of 37

Music of Chopin

humsplit h://chopin-first-editions

https://verovio.humdrum.org/?file=chopin-first-editions

31 of 37

Verovio Humdrum Viewer data access

http://verovio.humdrum.org/?file=mozart/sonatas

Compare to command-line downloading::

humcat -s h://mozart/sonatas

Same location address can be used in kernScores, command-line or VHV.

32 of 37

Single file download into VHV

http://verovio.humdrum.org/?file=mozart/sonatas/sonata01-1.krn

Compare to command-line downloading::

humcat -s h://mozart/sonatas/sonata01-1.krn

33 of 37

Copy/Paste from Terminal into VHV

In MacOS:

humcat -s h://mozart/sonatas/sonata01-2.krn | pbcopy

Then click in text area on left side of VHV (delete any current text), then paste with command-V or control-V:

34 of 37

Drag-and-drop Humdrum file into VHV

http://doc.verovio.humdrum.org/interface/humdrum

35 of 37

Create a Humdrum file from MusicXML

http://doc.verovio.humdrum.org/interface/musicxml

Scores can be prepared in a music editor (such as MuseScore used in this example), and then exported as MusicXML. Then the MusicXML file can be dragged-and-dropped onto VHV to convert to Humdrum data. After dragging a MusicXML file onto the page, press alt-c (option-c) to “compile” the MusicXML data into Humdrum data.

To save the Humdrum data, copy-and-paste into a text editor, or type “alt-s” to save the Humdrum data to a file in your Downloads directory.

36 of 37

Command-line MusicXML conversion

http://humlib.humdrum.org

The musicxml2hum tool in humlib (see right), can be used to convert multiple MusicXML files to Humdrum format automatically. To install humlib tools (which are a part of VHV, but not yet integrated with Humdrum Extras):

git clone https://github.com/craigsapp/humlib

cd humlib

make

make install

To convert all MusicXML files in a directory using a bash shell for-loop:

for i in *.xml

do

echo Converting $i

musicxml2hum $i > $(basename $i .xml).krn

done

Warning: files ending in .mxl are compressed MusicXML files. Use the unzip program to uncompress them before converting with musicxml2hum.

37 of 37

MIDI conversion to Humdrum

Converting MIDI files into Humdrum is best done by loading the MIDI file into a music editor such as MuseScore (https://musecore.org). Then edit the music if there are any conversion problems and export as MusicXML and convert by drag-and-drop on VHV or by using the musicxml2hum convert on the command line.