Music21: Loading a Humdrum file
From the music21 documentation page:
To read a Humdrum file into Music21, first you must import the music21 module in python:
from music21 import *
You can see what functions/variables were imported from music21 by typing this command in the python interpreter:
If you want basic online help for a particular function use the help() command:
NAME music21.converter - Public interface for importing various file formats into music21. FILE /usr/lib/python2.6/site-packages/music21/converter.py DESCRIPTION The most powerful and easy to use tool is the :func:`~music21.converter.parse` function. Simply provide a URL and, if the format is supported, a :class:`~music21.stream.Stream` will be returned.
The music21.converter is used to load in a Humdrum file, either from the hard disk or from a URL:
work = converter.parse('http://kern.ccarh.org/data?l=beethoven/sonatas&file=sonata01-1.krn')
Note that in order to download data from the internet you must first allow auto-downloading in the music21 environment.
or in the shell, download a humdrum file to the hard disk:
wget 'http://kern.ccarh.org/data?l=beethoven/sonatas&file=sonata01-1.krn' -O sonata01-1.krn
humcat h://beethoven/sonatas/sonata01-1.krn > sonata01-1.krn
and then type in python:
work = converter.parse('sonata01-1.krn')
Once the file has been loaded you can display it with the show command: