Humdrum Extras

sonority manpage


COMMAND

    sonority -- Identify vertical chordal sonority across multiple **kern spines.

SYNOPSIS

    sonority [-n|-t|-i|-r|-f format[-s[-U[input(s)[> output]

OPTIONS

-t Identify only the type of sonority.
-i Identify only the inversion of the sonority.
-r Identify only the root note of the sonority.
-a Append output data to input data.
-f format Format string for analysis output. The default is t:i:r which will print the sonority type followed by a colon (:), then the inversion, another colon, and finally a chordal root.
-n List pitch classes of notes present in sonority.
-N string Pitch-class (option -n) separation character(s). Default is a space.
-o # Print all notes in the same octave when using the -n option (3 = uppercase diatonic names, 4 = lowercase diatonic names).
-P Suppress parentheses around pitch-classes when the -n option is used.
-s Suppress sonority identification if all pitch classes do not start within sonority.
-u char Specifies the character to display for unknown pitch-class sonorities.
-U Lists the pitch-classes present in an unknown sonority surrounded by square brackets after the unknown sonority marker.
-x Display an "x" after interval class names if the sonority contains any note tied over from a previous sonority.
--iv Display sonority as an interval-class vector.
--forte Display Forte nomenclature for interval-class vectors.
--tn Display Tn nomenclature for interval-class vectors.
--tni Display Tn nomenclature for interval-class vectors, including triadic inversions for 3-11 set.

DESCRIPTION

    The sonority program identifies harmonic patterns of pitches which sound at the same time in a musical score. The following excerpt from J.S. Bach's chorale Aus meines Herzens Grunde divided into a sequence of sonorities, each one containing at least one note attack plus any previously sounding pitches.

    Each sonority is identified, if possible, as a chord built on thirds. In this example, only the pitch-class set "C G B D" cannot be categorized:

    sonority -a input.krn > output.krn
    The default output from the sonority program is to print three pieces of information about the chord:
    1. type: the name of the chord
    2. inversion: the lowest pitch in the chord
    3. root: the root note of the chord

    The following table lists the types of chordal sonorities that the program will identify. Following each type is an example set of pitch classes for that type of chord.

    note C

    dyads
    incmaj C E
    incmin C Eb

    triads
    maj C E G
    min C Eb G
    dim C Eb Gb
    aug C E G#
    domsevx5 C E Bb
    minminx5    C Eb Bb

    r rest
    tetrads
    majmaj C E G B
    domsev C E G Bb
    minmaj C Eb G B
    minmin C Eb G Bb
    minmin C Eb G Bb
    halfdim C Eb Gb Bb
    fullydim C Eb Gb Bbb

    augmented sixth chords
    french Ab C D F#
    german Ab C Eb F#
    italian Ab C F#

    X uncategorized

    The inversion is specified as a number, with 0 being root position 1 = first inversion, 2 = second inversion, and 3 being third inversion (if the chord type is a tetrad).

    The -t, -i, and -r options output only the specified portion of the sonority's quality (type, inversion and root respectively).

    sonority -t
    sonority -i
    sonority -r

    The -f option can be used to format the output. Use "t" for printing the sonority type, "i" for the inversion, and "r" for the root. These characters can be reordered, and a different separation character can be used:

    sonority -a -f "r,i" input.krn

    Sonority pitch classes

    The -U option will print a list of the pitch classes present in an uncategorized sonority which are enclosed in square brackets following the "X" symbol, sorted diatonically stating with C:

    sonority -aU input.krn

    Instead of interpreting the chordal quality of a sonority, you can print the pitch-class components of the sonority with the -n option. If the sonority can be categorized, the pitches will be listed in triadic order, starting at the root; otherwise, the pitches will be in alphabetical order starting with C. The lowest note in the sonority is listed in uppercase. If the sonority cannot be identified, the diatonic pitch-class name is doubled. Pitch classes which are sustained from previous sonorities are placed within parentheses, such as "(a)".

    sonority -at input.krn | sonority -an

    The -s option will suppress printing of sonorities which contain sustained pitch classes held over from previous sonorities. In the following example, the first call to sonority places the chord root and sonority type in the first appended column. The next column contains the data generated with sonority -nas which excludes sonorities which do not have note attacks on all constituent pitch classes, and the last column contains the data generated by sonority -na which includes pitch classes from previous sonorities in parentheses:

    sonority -a -f "rt" input.krn | sonority -nas | sonority -na

    The -o option can be used to remove the identification of the bass note in the pitch-class sonority description.

    sonority -n
    -n -o4
    -n -o3
    -nP -o4
    -nP -o3

EXAMPLES

    The data for the plot was extracted with these commands in the bash shell:

       for i in chor???.krn; do
          sonority -t $i | grep -v = | rid -GLId | sort | uniq -c \
                | sort -nr > `basename $i .krn`.son
          ./makecoord `basename $i .krn`.son
       done > data 

    Note the unusual minor outlier with a 48% major and 7% minor sonority composition. This is chorale 75: Das walt mein Gott. It is a short chorale with only 11 measures. The pickup beat is a D minor chord establishing the tonality, but the music quickly modulates to the relative major (F major) in the second beat of the chorale which lasts until a modulation back into D minor in measure 9.

    The most "sonorous" chorale is #102: Du lebensfürst, Herr Jesu Christ which contains 82.3% triadic sonorities (68.6% major, 13.7% minor). The most dissonant chorale is #339: Wer nur den lieben Gott laßt walten which contains 37.6% triadic sonorities (24.6% major, and 13% minor). Statistical descriptions of the major and minor key clusters in the plot above:

    Major sonorities     Minor sonorities
    Major and Minor chorales, combined:
    Mean0.35940.1710
    Median0.35300.1670
    Harmonic Mean0.33830.1358
    Range0.51900.3460
    Std. Deviation0.08840.0692
    Variance0.00780.0048

    Major chorales alone:
    Mean0.41280.1212
    Median0.40450.1180
    Harmonic Mean0.39910.1019
    Range0.44200.2380
    Std. Deviation0.07710.0431
    Variance0.00590.0019

    Minor chorales alone:
    Mean0.29950.2251
    Median0.30500.2240
    Harmonic Mean0.28540.2099
    Range0.39900.3211
    Std. Deviation0.05980.0497
    Variance0.00360.0025

    Example 2

    The following histograms show the relative frequencies of major and minor triads in various inversions in all of the sonorities in 370 Bach chorales. For both major and minor triads, the root inversion is the most common at about 2/3 of the occurrences. First inversions occur about 1/3 of the time for each type of triad, and second inversions occur much less often in both types of triads. An interesting difference between the two triad types is that the second inversion is about two times more common for minor triads than for major ones.

    How to calculate data for the above chart:

      sonority chor???.krn -f t:i | grep ^maj: | sort | uniq -c

      sonority chor???.krn -f t:i | grep ^min: | sort | uniq -c

    Compare the ratios of inversions above with that of a sample of Renaissance music and for Beethoven's string quartets which are shown in the histograms below. For Renaissance music, the root position is much more common than the first inversion, which in turn is much more common than the second inversion. In Beethoven's string quartets, the fraction of first inversions is approximately the same as for the Bach chorales, but the second inversion are higher (and root sonorities consequently less frequent).

    Example 3

    There are three augmented-sixth chord sonorities in the 370 Bach chorales. You can locate them with this bash shell command:
     for i in chor???.krn; do
        sonority -ta $i | ditto -p > `basename $i .krn`.temp
     done
     hgrep -Hbm "french|german|italian" *.temp
    There is an Italian sixth chord in chorale #19, first measure, offbeat of the second beat; a French sixth on beat 2.4 of measure 4 in chorale #146; and a German sixth on the 1.5 beat of measure 10 in chorale #340. The notes in parentheses (added by the ditto command) are held over from previous sonorities in the music.

    You can view the functional position of the chords in the overall tonality of each chorale by transposing the chorales to C major/minor before (or after) doing the sonority analysis:

     for i in chor???.krn; do
        transpose -k c $i | sonority -ta | ditto -p > `basename $i .krn`.temp
     done
     hgrep -Hbm "french|german|italian" *.temp
    In all three cases, the root of the augmented sixth chord occurs as expected on the flatted sixth scale degree (A-flat in C major).

    You can identify the sonority which follows the augmented sixth chord by doing this command:

       egrep -A 1 "french|german|italian" chor???.temp

    The Italian sixth chord resolves to the dominant as expected, while the French and German sixth chords resolve to the second inversion of the tonic (which is a passing sonority of the dominant).

    Example 4

    In chorales which are in a minor key, the following plot shows the relative occurrence of major and minor triads on various scale degrees. For minor chorales, the most common triad is minor on the tonic scale degree. Only two other scale degrees are commonly used for minor triads in the minor chorales: the subdominant and the dominant. About 1/3 of dominant triads are minor, while the other 2/3 are major (with the harmonic minor VIIth scale degree used for the third of the dominant).

    Major triads occur most often on the mediant (III), which primarily indicates a modulation to the relative major. Likewise, major chords on the leading tone (VII) are common, where they typically act as dominants in the relative major key. Submediant (VI) chords are very rare in the minor chorales.

    Data was extracted for the above plots by first separating major and minor chorales which can be accomplished with the help of grep or hgrep:

     hgrep -Dlkt '^\*[a-g][#-]?:' *.krn # list of chorales with minor keys
     hgrep -Dlkt '^\*[A-G][#-]?:' *.krn # list of chorales with major keys
     
    Then running these bash shell commands on the two separate sets:
       for i in chor???.krn; do
          transpose -kc $i | sonority -f t:r | grep -v = | rid -GLId
       done | sort | uniq -c | sort -k2 > minor.dat
       

    For chorales in a major key, the most common triadic sonority is the tonic, followed by the dominant (70% compared to tonic), then the Subdominant (35% compared to tonic). The most common minor triad sonorities occur on the Submediant (VI) at 1/3 the rate of tonic triads, followed by the supertonic (II) at 1/4 the rate of tonic triads.

    Major triads on the supertonic typically function as the dominant of the dominant (V/V), and these are the 4th most common major triad sonorities. Major chords on the mediant are most likely acting as dominants of the submediant.

       for i in chor???.krn; do
          transpose -kc $i | sonority -f t:r | grep -v = | rid -GLId
       done | sort | uniq -c | sort -k2 > major.dat
       

    Example 5

    First-order sonority transitions in Bach chorales. The following list shows the most common sonotory-to-sonority transitions in the Bach chorales (29,906 total sonority pairs):

    frequency
    (percent)
    chord 1 chord 2 functional interpretation
    0.775 (G),(b),(d),f =>C,e,g (V7) => I
    0.642 G,b,d =>C,e,g V => I
    0.642 C,e,g =>C,e,g I => I
    0.589 G,b,d =>(G),(b),(d),f V => (V7)
    0.465 G,b,(d) =>(G),(b),(d),f V => (V7)
    0.461 G,b,d =>C,e-,g V => i
    0.445 G,b,d =>G,b,d V => V
    0.438 G,b,d =>(g),(b),(d),F V => V42
    0.421 C,e-,g =>C,e-,g i => i
    0.401 C,e-,g =>(c),(e-),(g),B- i => (i7)
    0.401 C,e,g =>(c),(e),(g),B I => (I7)
    0.341 C,e,g =>G,b,d I => V
    0.311 (cc),dd,GG =>(G),b,(d) Vsus4 => V
    0.298 C,e,g =>F,a,c I => IV
    0.291 E-,g,b- =>E-,g,b- III => III

    The data for the above table was extracted with the bash shell command:

     for i in chor???.krn; do 
        transpose -kc $i | sonority -nN, | grep -v = \
            | context -n2 | rid -GLId 
     done | sort | uniq -c | sort -nr > output.dat
     
    • Major choral sonority pairs, 17 most common transitions (15,629 total pairs):
      frequency
      (percent)
      chord 1 chord 2 functional interpretation
      1.196 C,e,g=> C,e,g I => I
      1.152 G,b,d=> C,e,g V => I
      1.030 (G),(b),(d),f=> C,e,g (V7) => I
      0.768 C,e,g=> (c),(e),(g),B I => (I7)
      0.646 C,e,g=> G,b,d I => V
      0.595 G,b,d=> (G),(b),(d),f V => (V7)
      0.563 G,b,d=> (g),(b),(d),F V => (V42)
      0.557 C,e,g=> F,a,c I => IV
      0.525 g,B,d=> C,e,g V6 => I
      0.518 C,e,g=> g,B,d I => V6
      0.480 c,E,g=> (cc),(ee),FF,(gg) I6 => X
      0.480 G,b,d=> G,b,d V => V
      0.454 D,f,a=> b,(D),(f) ii => (vii)
      0.435 (g),(b),(d),F=> c,E,g (V7) => I6
      0.416 G,b,(d)=> (G),(b),(d),f V => V(7)
      0.403 A,c,e=> (a),(c),(e),G vi => (vi7)
      0.371 (cc),dd,GG=> (G),b,(d) Vsus4 => V

    • Minor choral sonority pairs, twenty most common transitions (14,277 total pairs):
      frequency
      (percent)
      chord 1 chord 2 functional interpretation
      0.966 G,b,d => C,e-,g V=> i
      0.883 C,e-,g => C,e-,g i=> i
      0.848 C,e-,g => (c),(e-),(g),B- i=> (i7)
      0.609 E-,g,b- => E-,g,b- III=> III
      0.581 G,b,d => (G),(b),(d),f V=> (V7)
      0.539 (G),(b),(d),f => C,e-,g (V7)=> i
      0.518 G,b,(d) => (G),(b),(d),f V=> (V7)
      0.476 B-,d,f => E-,g,b- V/III=> III
      0.455 (G),(b),(d),f => C,e,g (V7)=> I
      0.421 C,e-,g => G,b,d i=> V
      0.406 g,B,d => C,e-,g V6=> i
      0.406 G,b,d => G,b,d V => V
      0.385 c,E-,g => (cc),(ee-),FF,(gg) i6=> X
      0.315 B-,d,f => (b-),(d),(f),A- V/III=> (V42)/III
      0.315 (B-),(d),(f),a-=> E-,g,b- (V7)/III=> III
      0.308 B-,d,f => (B-),(d),(f),a- V/III=> (V7)/III
      0.301 b-,D,f => E-,g,b- V6/III=> III
      0.301 G,b,d => (g),(b),(d),F V=> (V42)
      0.287 F,a-,c => d,(F),(a-) iv=> (vii6)/III
      0.280 C,e-,g => (cc),DD,(ee-),(gg) i => X

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

ONLINE DATA

    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:
           program http://www.some-computer.com/some-directory/file.krn
    Piped data works in a somewhat similar manner:
           cat file.krn | program
    is 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.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

DOWNLOAD

    The compiled sonority 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 16 Mar 2011. Click here to go to the full source-code download page.