Humdrum Extras

prange manpage


    prange -- Generate pitch histogram data from **kern input data.


    prange [-d[-f | -p percentile[input(s)[> output]


-d Generate pitch histograms which are weighted by the duration of the notes.
-f Also print the fraction of total notes contained in one frequency bin. **fracL contains the lowest fractional value, **fracH contains the highest fractional value, and **fracA contains the average fractional value for each pitch bin. Fractions are described from lowest pitch (0.0) to highest pitch (1.0)
-c range Count the number of notes in a given pitch range. The range can either be in MIDI note numbers, such as -c 60-71 for the fourth (middle C) octave, or in terms of **kern pitches: -c c:b where the range separator is a colon (:) or a space (-c "c b") so as not to confuse the dash sign (-) between a range separator and a **kern flat sign. MIDI ranges may substitute the dash with a colon.
-N Normailze the pitch counts.
-p percentile Identify the MIDI note number of the pitch which occurs at the specified percentile in the range of the music.
--pitch Display pitch information in **pitch format.
--print When counting notes, count noteheads occurring in the middle or end of a set of notes tied together.


    The prange program generates a pitch histogram from input **kern data and then displays this histogram, or you can have it display a pitch (as a MIDI note number) which occurs at a given percentile in the histogram.


    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:


    The command:

       prange bwv1007-01.krn
    will 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.krn
    The result will be 52 which is E3. For the 67% percentile:
       prange -p 67 bwv1007-01.krn
    you will get 57 which is A3. The average pitch is at the 50% percentile:
       prange -p 50 bwv1007-01.krn
    which 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
    Compare to not using -d option:
       prange -p 50 bwv1007-01.krn
    The 33% percentile based on duration weighting:
      prange -d -p 33 bwv1007-01.krn
    The 67% percentile based on duration weighting:
       prange -d -p 67 bwv1007-01.krn

    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:

    The duration-weighted median pitch of the Chopin Mazurkas is MIDI note 61 (C#-4) which is a semi-tone above middle C.

    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
    This can also be done by specifying the **kern start and stop pitches:
       prange -c c:b bwv1007.krn

    Counting the number of pitches below middle C:

       prange -c 0-59 bwv1007.krn

    Counting the number of pitches middle C and higher:

       prange -c 60-127 bwv1007.krn

    Counting pitches in all registers:

       prange -c 0-127 bwv1007.krn

    Counting printed notes

    By 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.

    input data
    prange --print
    When measuring the total duration of pitches within the music using the -d option, using or not using the --print option will generate the same results.
    input data
    prange --print

    Pitch display format

    By 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.

    prange h://371chorales/chor001.krn
    prange h://371chorales/chor001.krn --pitch

    More example usages of the prange program are available on the prange examples page


    Input arguments or piped data which are expected to be Humdrum files can also be web addresses. For example, if a program can process files like this:
           program file.krn
    It can also read the data over the web:
    Piped data works in a somewhat similar manner:
           cat file.krn | program
    is equivalent to a web file using ths form:
           echo | 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.krn
    will download the URL:
    Which is found in the 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




    The compiled prange program can be downloaded for the following platforms:
    • Linux (i386 processors) (dynamically linked) compiled on 28 Jun 2012.
    • Windows compiled on 29 Jun 2012.
    • Mac OS X/i386 compiled on 13 Nov 2013.
    • Mac OS X/PowerPC (version 10.2 and higher) compiled on 13 May 2009.

    The source code for the program was last modified on 30 Mar 2013. Click here to go to the full source-code download page.