Humdrum Extras

transpose manpage


    transpose -- Transpose musical pitch names in **kern data.


    transpose [-t interval | -[k|Ktonic | -b # | -d # -c #[-s list[input[> output]


-b # Transpose the input data by a base-40 interval number. For example, 6 means up a major second and -5 means down a minor second. [more info]
-c # Specify the chromatic interval of the transposition. Also requires the use of the -d option. Should not be used with the -b option. [more info]
-d # Specify the diatonic interval of the transposition. Also requires the use of the -c option. Should not be used with the -b option. [more info]
-k tonic Transpose **kern data in the input so that the first scale degree of the musical key is is transposed to the tonic pitch. For example, -k f means transpose the music to F major or minor. Key tandem interpretations are required in the data in order to use this option. [more info]
-K tonic Aggressive key transposition. Similar to -k, but transpostion amount changes based on subsequent key interpretations rather than only the first key interpretation found before first data line. [more info]
-o # Add an additional octave transposition to the -k, -b or -t transposition. -o 1 means up an octave, while -o -2 would mean down two octaves.
-q Quiet mode: do not generate *Tr markers or alter any existing *Tr transposition indications.
-s list List of spine enumerations to selectively transpose. [more info]
-t interval Transpose the input data by the given musical interval. The interval name consists of three components: (1) a direction with a minus or optional plus sign, (2) a letter indicating the quality of the interval: A = augmented, M= major, m=minor, d = diminished, and P = perfect, and (3) the diatonic interval number in the range of a unison to a ninth. For example -t +P5 means transpose up a perfect fifth, while -t -m6 means transpose down a minor sixth. [more info]
-C Convert score to concert pitch. [more info]
-I Convert a transposed instrumental part to concert pitch, inserting a *ITr marker. Used in conjuction with -t, -b, or -d and -c. [more info]
-W Convert score to written pitch. [more info]


    Transposition by a musical interval

    Using the -t option, all **kern spines in the input data can be transposed by the specified musical interval. Follow the -t option name with one of these example interval abbreviations:

    P1    perfect unison (such as C to C)
    A1    augmented unison (such as C to C-sharp)
    d2    diminished second (such as C to D-double-flat)   
    m2    minor second (such as C to D-flat)
    M2    major second (such as C to D)
    A2    Augmented second (such as C to D-sharp)
    m3    minor third (such as C to E-flat)
    M3    major third (such as C to E)
    P4    perfect fourth (such as C to F)
    A4    augmented fourth (such as C to F-sharp)
    d5    diminished fifth (such as C to G-flat)
    P5    perfect fifth (such as C to G)
    A5    augmented fifth (such as C to G-sharp)
    m6    minor sixth (such as C to A-flat)
    M6    major sixth (such as C to A)
    A6    augmented sixth (such as C to A-sharp)
    m7    minor seventh (such as C to B-flat)
    M7    major seventh (such as C to B)
    A7    augmented seventh (such as C to B-sharp)
    P8    octave

    By default the transposition will be to a higher pitch, but you can be explicit in the direction by placing a plus sign (+) in front of the interval, such as -t +P5 for transposing up a perfect fifth. If you want to transpose down, then prepend a minus sign (-) to the interval, such as -t -P5 to transpose down a perfect fifth. Here is an example of transposing a musical phrase up by a major second:

        transpose -t M2 sarabande-c.krn > sarabande-d.krn
    Where the input and output files are as follows:
    In terms of traditional music notation, here is the input phrase and the output phrase respectively:

    Bach Cello Sarabande in C minor
    Bach Cello Sarabande in D minor

    Transposition to a specific key

    If you know what the new key for the music should be, you can have the transpose program calculate the correct transposition interval for you automatically. To transpose the music from C minor into D minor which will yield the same result as illustrated above:

        transpose -k d sarabande-c.krn > sarabande-d.krn

    In this case -k d requests that the music be transposed into D minor. The option setting -k D would also give the same result of a transposition to D minor rather than D major, since the transpose program does not alter the mode of the music.

    In order to use the -k option for transposition to a new key, a key designation must be present in the file. in the above example the key designation is *c: for C minor. If there is more than one key designation in a file, then the first one found will be used to calculate the transposition. [A -K option may be added in the future to provied dynamic transposition to a single output key from multiple different key regions in the input data.]

    Sharps and flats are represented as in **kern data. You should place single quotes around keys which contain a sharp, such as -k 'F#' to transpose to F-sharp major/minor. This is because the command-line interpreter would otherwise treat everything after the # sign as a comment and ignore it. Alternatively, you can add a backslash before the # sign, such as -k F\#. Transposing to a key containing a flat in the name would be similar to this transposition to A-flat: -k A-, where the dash (-) is the **kern flat symbol.

    The -o option can be used in conjunction with the -k option in order to transpose in the right direction. If the music is in C major, for exmaple, and you want to transpose to G major, then the music will be transposed down by a perfect fourth by default. If you add the option -o 1 to -k G, then the music will be transposed an octave higher than the default transposition.

    Aggressive key transposition

    Aggressive key transposition is done by using -K instead of -k. In this form of transposition, whenever a new key is defined, that will generate a new transposition interval to force the music into the requested key. This option is useful for generating statistics on functional analyses. For example, if you want to calculate the frequency of tonic pitch classes in a file containing modulations, you can use -K to transpose all key regions to C major, and then count the number of C pitches in the resulting data.

    Below is an example of the differences between using -k and -K to transpose music which contains multiple key designations. Using the -k option will transpose with a fixed interval based on the first key marker in the file, while -K will readjust the transposition interval based on each key designation that it find while processing the input file.

    transpose -k c
    transpose -K c

    Transposition by base-40 value

    Base-40 intervals enumerations are built from two values: 5 for minor seconds, and 6 for major seconds. A perfect fifth is composed of 3 major seconds and one minor second, so the base-40 interval value for a perfect fifth is: 6 * 3 + 5 * 1 = 23. Here is a list of possible base-40 interval values within the span of an octave:

    0    perfect unison (such as C to C)
    1    augmented unison (such as C to C-sharp)
    2    doubly augmented unison (such as C to C-double-sharp)
    4    diminished second (such as C to D-double-flat)   
    5    minor second (such as C to D-flat)
    6    major second (such as C to D)
    7    augmented second (such as C to D-sharp)
    8    doubly-augmented second (such as C to D-double-sharp)
    10    diminished third (such as C to E-double-flat)
    11    minor third (such as C to E-flat)
    12    major third (such as C to E)
    13    augmented third (such as C to E-sharp)
    14    major third (such as C to E-double-sharp)
    15    doubly-diminished fourth (such as C to F-double-flat)
    16    diminished fourth (such as C to F-flat)
    17    perfect fourth (such as C to F)
    18    augmented fourth (such as C to F-sharp)
    19    doubly-augmented fourth (such as C to F-double-sharp)
    21    doubly-diminished fifth (such as C to G-double-flat)
    22    diminished fifth (such as C to G-flat)
    23    perfect fifth (such as C to G)
    24    augmented fifth (such as C to G-sharp)
    25    doubly-augmented fifth (such as C to G-double-sharp)
    27    diminished sixth (such as C to A-double-flat)
    28    minor sixth (such as C to A-flat)
    29    major sixth (such as C to A)
    30    augmented sixth (such as C to A-sharp)
    31    doubly-augmented sixth (such as C to A-double-sharp)
    33    diminished seventh (such as C to B-double-flat)
    34    minor seventh (such as C to B-flat)
    35    major seventh (such as C to B)
    36    augmented seventh (such as C to B-sharp)
    37    doubly-augmented seventh (such as C to B-double-sharp)
    38    doubly-diminished octave (such as C to C-double-flat)
    39    diminished octave (such as C to C-flat)
    40    octave

    To transpose by more than one octave, add 40. For example transposing down two octaves is -b -80; transposing up three octaves and a fifth is -b 143. Alternatively, you can use the -o option to indicate octave transpositions in addition to the base transposition with the -b option. For example, -o 3 -b 23 is equivalent to -b 143.

    In order to be compatible with the Humdurm Toolkit program trans the transpose command can also represent transposition values by using the -d and -c options. These two options are used together to indicate the transposition interval. For example, to transpose up a major second (such as from C major to D major), that would mean transposing up one diatonic note (C to D, D to E, E to F, etc.), and up two chromatic notes (two half-steps). Unlike trans, the transpose command cannot do modal transpositions using the -c and -d options.

    Selective spine transposition

    Transposition can be limited to particular spines of data in the input. This is useful, for example, in an orchestral score to transpose a single transposing instrument to concert pitch when doing data input from a written score.

    To transpose a particular spine, use the -s option followed by a spine enumeration. For example, if the first spine on the left in the file is the only one to transpose, then use -s 1. If there are multiple spines to be transpose by the same amount, you can place a command between each spine enumeration in the list, such as -s 1,3,5,8. For a range of spines, you can place a dash between the first and last enumeration in the range, such as -s 4-11. The dollar sign ($) can be used in a similar manner as in the -s spine list in the extractx program. You can include non-kern spines in the list to -s; they will be silently ignored.

    The -s option can be used in conjunction with the -k, -t, and -b options. The following example usage of the transpose program transposes the second spine in the input to E-flat major.

       transpose -k E- -s 2 input.krn > output.krn

    Concert/Written pitch score conversions

    The two options -C and -W can be used to switch between concert-pitch and written-pitch scores. The default storage format for orchestral scores in Humdrum files is concert pitch. However, if you want to print a traditional score or generate printed parts, a written pitch score is desirable.

    The following three files demonstrate how the -C and -W options work. The first file contains a score for a B-flat clarinet which is in concert pitch. The *ITrd1c2 indicates that the written score for the instrument should be transpose up a major second. The second file applies the -W option which converts a concert-pitch score into a written pitch score. Now the music is transpose up a major second as required by the clarinetist in order to play the correct pitches for a scale in C major. Also note the *ITrd1c2 marker has been converted into *Trd1c2 which is a marker indicating that the music has been transposed up by a major second. These markers are used to control the behavior of the -C and -W options. The final file shows that applying -C to a written-pitch score will generate the original file again. Note that applying -W and then -C should generate the original input file.

    original file
    transpose -W
    transpose -C

    The -C option is also useful for data entry from music scanning programs. Output from OMR programs can be edited by hand to add *Tr markers in transposing instruments. Then, the transpose program can be run with the -C option to produce the final score.

    Instrument transposition codes insertion

    When encoding a transposing instrument, the -I option is useful to prepare a final score in concert pitch. Normally a *Tr marker is added to the file indicating the amount of transposition applied to the file using the transpose command. However when using -I, the output parts will instead contain an *Itr marker which can be used to later generate written parts from the sounding score.

    transpose -s 2 -t -M2
    transpose -s 2 -t -M2 -I

    The first example in the above set of files contains a written-pitch score for flute and B-flat clarinet. The two instruments are playing a C major scale in unison, but the clarinet's pitches are transposed up a major second since it is a transposing instrument. In order to transpose the

    Modal transpositions

    The tranpose program understands key interpretations which contain modal information after the colon character. Here is a list of sample keys starting on the pitch C which include modal abbreviations:

    interpretation     namescale
    *C:C major
    C  D  E  F  G  A  B
    *c:C minor
    C  D  E- F  G  A- B-
    *C:mix   C mixolydian   
    C  D  E  F  G  A  B-
    *C:lydC lydian
    C  D  E  F# G  A  B
    *C:ionC ionian
    C  D  E  F  G  A  B
    *c:dorC dorian
    C  D  E- F  G  A  B-
    *c:phrC phrygian
    C  D- E- F  G  A- B-
    *c:aeoC aeolian
    C  D  E- F  G  A- B-
    *c:locC locrian
    C  D- E- F  G- A- B-

    Notice that the letter case of the tonic note in the key interpretation is upper case if the third scale degree is a major third and is lower case if the third scale degree is a minor third. Only constant interval transpositions are possible with the transpose program, so conversion between different modes is not possible. If you want to change the mode of the music, then use the Humdrum Toolkit program called trans.

    transpose -k d input.krn > output.krn
    input file
    output file



    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 standard Humdrum Toolkit transposition program, trans.


    Triple-sharps and triple-flats (and higher-order accidentals) cannot be transposed properly by the transpose program. Also, if the transposed pitch given a particular transposition is a triple sharp or flat, the program will not output correct data.

    The transpose program only works on **kern data, but may be expanded to other exclusive interpretation types in the future.


    The compiled transpose 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 19 Nov 2009. Click here to go to the full source-code download page.