Analysis data generated in the examples below are generated from the Prelude from J.S. Bach's first cello suite in G Major, BWV 1007:
prange bwv1007-01.krnwill give the note-count pitch histogram sorted by pitch from low to high. The first column of the output is the MIDI note number, the second column is the **kern equivalent value for the MIDI note number, and the third column is the count of notes in the score which have the given pitch. (tied notes count as 2 or more pitches in this count):
Note that the lowest note is on key 36 (C2 -- the bottom note of cello), and the highest note is 67 which is the G4 above middle C. The most common note is the A3 below middle C which occurs 113 times in the score.
Now, suppose that you want the pitch which falls in the 33% percentile of the histogram above. To do this use the command option -p 33 (or -p .33):
prange -p 33 bwv1007-01.krnThe result will be 52 which is E3. For the 67% percentile:
prange -p 67 bwv1007-01.krnyou will get 57 which is A3. The average pitch is at the 50% percentile:
prange -p 50 bwv1007-01.krnwhich is 54, or F#3. Notice that the 33% percentile and the 50% percentile pitch are just a whole tone away from each other.
You may also want to weight the importance of a pitch by its duration, so that a lot of short notes do not overpower long sustained notes in the music. To do this you use the -d option to weight the pitches by their durations. For example, here is the pitch histogram for the same piece using the duration weighting:
C2 occurred for a duration of 0.75 quarter notes, and the highest pitch occurred for a duration of 7 quarter notes. A3 still is the most important pitch in the piece since it lasts a total of 28.25 quarter notes.
To get the average pitch:
prange -p 50 -d bwv1007-01.krn 55Compare to not using -d option:
prange -p 50 bwv1007-01.krn 54The 33% percentile based on duration weighting:
prange -d -p 33 bwv1007-01.krn 52The 67% percentile based on duration weighting:
prange -d -p 67 bwv1007-01.krn 57
The prange program can also accept multiple input files so that the pitch profile of an entire corpus can be calculate at the same time. For example, here is the duration-weighted pitch histogram for all 52 of Chopin's Mazurkas:
Displaying fractional histogram values
The -f option is used to add extra information to the basic output when there are no other option flags. In the following example output from the cello prelude, the **fracL indicates the bottom fraction of notes on the given pitch, **fracH indicates the top fraction of notes on the given pitch, and **fracA indicates the average histogram fraction for the given pitch on the line.
prange -f bwv1007-01.krn
Counting pitches in a range
The -c option is useful for counting the number of notes in a give range of pitches. For example, the following command counts the number of notes in the fourth octave which is from MIDI note 60 to 71:
prange -c 60-71 bwv1007.krn 86This can also be done by specifying the **kern start and stop pitches:
prange -c c:b bwv1007.krn 86
Counting the number of pitches below middle C:
prange -c 0-59 bwv1007.krn 571
Counting the number of pitches middle C and higher:
prange -c 60-127 bwv1007.krn 86
Counting pitches in all registers:
prange -c 0-127 bwv1007.krn 657
Counting printed notesBy default, prange counts sounding notes, not printed notes. Sounding notes may be split into multiple printed notes which are connected by ties. If the --print option is added, all printed noteheads will be counted.
Pitch display formatBy default, the prange program will display pitches in the **kern format. Using the --pitch option, the pitch will be displayed in the **pitchpitch format, which is based on ISO 16:1975.
More example usages of the prange program are available on the prange examples page
program file.krnIt can also read the data over the web:
program http://www.some-computer.com/some-directory/file.krnPiped data works in a somewhat similar manner:
cat file.krn | programis equivalent to a web file using ths form:
echo http://www.some-computer.com/some-directory/file.krn | program
Besides the http:// protocol, there is another special resource indicator prefix called humdrum:// which downloads data from the kernscores website. For example, using the URI humdrum://brandenburg/bwv1046a.krn:
program humdrum://brandenburg/bwv1046a.krnwill download the URL:
Musedata Bach Brandenburg Concerto collection.
This online-access of Humdrum data can also interface with the classical Humdrum Toolkit commands by using humcat to download the data from the kernscores website. For example, try the command pipeline:
humcat humdrum://brandenburg/bwv1046a.krn | census -k