Programming Digital Media

Procedural music notation -- Doug Barrett

Procedural music notation — Doug Barrett Doug Barrett has provided four Python scripts that demonstrate the notation techniques he discussed in his talk.

Installation of the scripts

Printing the PostScript music files created by Doug's scripts requires the "Maestro" fonts from MakeMusic. You can download Notepad, a free version of their music notation software that includes the fonts. There will also be a CD at class containing the installation file you can copy.

For each of the four scripts below, click on the script name to download the script. Clicking on the filename following "creates" will download a PDF file that was produced by the running the script and then opening the PostScript file with Preview and saving it out in PDF format.

Running the scripts

Running the script without arguments will print the text below. For example, enter:
    python draw_staff.py 
to see the "usage" message for draw_staff.py.

For each of the scripts, the argument descriptions are surrounded by angle brackets, like this: <output-filename>. This means, for example, that the name of the output file would be specified as an argument at that position in the list of arguments. For clarity, some of the argument lists extend over two lines, but you should specify all the arguments on a single line when you run the script.

Try running each example first, and then make changes to the arguments. Each script creates a PostScript file. Use the open command with the PostScript file as an argument to convert it to PDF format.


draw_staff.py    creates     draw_staff.pdf

 
Usage: draw_staff.py <x> <y> <length> <output-filename> 
 
Draw a musical staff with the lower left corner at <x>,<y> of length 
<length>, writing the PostScript to <output-filename>. 
 
Example: 
 
    python draw_staff.py 36 720 540 draw_staff.ps 
 

random_draw.py    creates     random_draw.pdf

 
Usage: random_draw.py <number-of-notes> <x> <y> <width> <height> 
                            <output-filename> 
 
Place random musical characters in random positions in a box 
<width> by <height> in size, with the lower left corner at <x>,<y>. 
 
Example: 
 
    python random_draw.py 1000 36 36 540 720 random_draw.ps 
 
 

basic_notes.py    creates     basic_notes.pdf

 
Usage: basic_notes.py <x-pos> <note-number> <accidental> <output-filename> 
 
Print a single note.  The note is positioned <x-pos> points from the 
beginning of the staff.  The note number is a note in the C major 
scale, with 0 equal to two octaves below middle C. The accidental sign 
is defined by one of the following numbers: 
 
   -1  Flat 
  -.5  Quarter-tone flat 
    0  Natural 
   .5  Quarter-tone sharp 
    1  Sharp 
 
The PostScript data is written to the file <output-filename>. 
 
Example: 
 
    python basic_notes.py 72 9 1 basic_notes.ps 
 

notes.py    creates     notes.pdf

 
Usage: notes.py <note-count> <start-time> <end-time> 
                <lower-octave> <upper-octave> <output-filename> 
 
Print <note-count> notes.  A single staff is a time unit of 1. The 
octave bounds extend above and below the staff, so "0 1" means notes 
within the staff; "-1 2" extends above and below the staff by an 
octave. The PostScript data is written to <output-filename>. 
 
Example: 
 
    python notes.py 500 0 14 0 1 notes.ps