Automatically generate scale degree numbers.

The deg filter analyzes scale degrees in **kern data. The deg filter is similar to the deg tool in the Humdrum Toolkit, with notable exceptions being that the default output of the deg filter interleaves the **deg analysis spines within the input score so that they can be viewed along with the music in VHV. Also, the default minor scale used in the deg filter is the natural minor, while in the Humdrum Toolkit it is the harmonic minor. In addition there are lots of styling options and enhancements described for the **deg representation on this page and also summarized below.

Here is a basic example of scale degrees in C major:

And in A minor:

The interpretation *C: indicates that the music is in C major, so the deg tool will set scale degree 1 to C pitch classes. *a: indicates A minor, so the pitch class A is the starting scale degree. Note that both examples have a key signature with zero sharps or flats: *k[]. The key signature is not used in the analysis of scale degrees; only the key designation interpretations, such as *C: or *a: are used.

Chromatic alterations

Chromatic alterations are displayed as accidentals before the scale degrees by default. These accidentals are relative to the analysis key. For example in C minor, 7+ is the raised 7th scale degree, which would be B natural, since the nominal pitch in C (natural) minor is a B-flat. In music notation this will be shown as “♭7”.

[To do: place the accidental in front of the scale degree and add an option *accrev to allow it displayed after the degree.]

You can add the --arrow option to display chromatic alterations as up/down arrows after the scale degree in music notation.

[To do: add an interpretation *arrrev to place the arrows in front of the scale degree.]

Key interpretations

Modal keys can be used to analyze scale degrees:

Key interpretation Meaning Example pitch-classes
*d:dor D dorian DEFGABCD
*e:phr E phrygian EFGABCDE
*F:lyd F lydian FGABCDEF
*G:mix G mixolydian GABCDEFG
*a:aeo A aeolean ABCDEFGA
*b:loc B locrian BCDEFGAB
*C:ion C ionian CDEFGABC


When the key changes within a score, the scale degrees will be relative to the new key:

[ add an option to ignore modulations, maybe --ignore-modulations ]

Setting a default key

[To do: do not analyze scale degrees when there is no active key. This could be explicitly given with some new interpretation such as *nokey and *Xnokey.]

If the input musical score does not have key designations such as *E: for E major, then the --default-key option can be used to set the key in which the scale degrees should be calculated.

Forcing analysis in a particular key

Similar to setting a default key, you can use the --force-key option to override any key designations in the input data. Modulations to other keys besides the initial key will also be overridden.

Selective analysis

In addition to calculating the scale degrees of all **kern spines in a file, the deg filter can select a subset of the music to analyzed. Spines can be selected either by using -s to select the nth spine in the file, or with -k to select the nth **kern spine in the file.

Selecting spines with -s

Example Meaning
-s 1 Analyze only the first (leftmost) spine in the input data.
-s 1,4 Analyze the first and fourth spine.
-s 2-4 Analyze the second, third and fourth spines.
-s $ Analyze the last spine.
-s 3,$ Analyze the thrid and last spines.
-s 1-4,6,9-$ Analyze the first, second, third, fourth, sixth, and nineth through last spines.
-s $1 Analyze the penultimate spine.
-s $2-$ analyze from two spines before the end to the last spine.

Selecting spines with -k

Example Meaning
-k 1 Analyze only the first (leftmost) kern spine in the input data.
-k 1,4 Analyze the first and fourth kern spine.
-k 2-4 Analyze the second, third and fourth kern spines.
-k $ Analyze the last kern spine.
-k 3,$ Analyze the thrid and last kern spines.
-k 1-4,6,9-$ Analyze the first, second, third, fourth, sixth, and nineth through last kern spines.
-k $1 Analyze the penultimate kern spine.
-k $2-$ analyze from two kern spines before the end to the last kern spine.

Extracting/showing only scale degree analyses

The -I option can be used to output only **deg spines instead of embedding them in the input score. This option by itself cannot be displayed as music notation (currently, but may be implemented in the future).

You can add the --recip option to output a timelines for the **deg spines. This is also not yet displayable, but you can add --kern to display an invisible staff line to display in VHV.


Octave information about the pitches can be preserved in the scale degree analysis by adding the --octave option. The output data will be placed into a **degree spine, similar to the output of the degree tool in the Humdrum Toolkit. These octaves will be displayed as subscript numbers after the scale degree when displayed in music notation.

Note that the middle-C octave is labeled as the 4th octave.


Tied notes do not get labeled with scale degrees by default:

If you want to see scale degrees on secondary tied notes, add the -t option:

[To do: When a scale degree is related to a tied note (other than the starting note of the tie, an underscore is placed before the degree number in **deg spines. You can use the shed filter to colorize the tied scale degrees.]



The --solfege option (short version --solf) can be used to display scale degrees as solfège syllables rather than as numbers.

By default the solfège syllables are relative to the key, so 1=do, 2=re, etc. If you want fixed solfège syllables (C=do, D=re, etc.), then use the --force-key C option:

Solfège syllables are chromatic, where sharped pitch classes typically change the vowel to i, and flatted change the vowel to e (or a if the default syllable uses e, such as di for the raised tonic, or C♯ in fixed do. Only “black keys” have a chromatic syllable name; otherwise, the syllable will be enharmonically changed to the next scale degrees syllable. For example the flatted tonic, or C♭ in fixed do, will be displayed as ti rather than de.

If you do not want chromatic alterations included in the solfège syllables, remove them with the shed before displaying in music notation:

deg --solfege --force-key C | shed -x deg -e "s/[+-]+//g"

[Maybe add an option such as **solfF to display do as ut and ti as si, and so as sol.]

Styling options

There are several options that can be used to add styling for scale degrees in the music notation:


The --circle option will place circles around scale degrees. This is often used on scale degrees in the bass line in music analysis.

If you want to only circle a selection of scale degrees, you can use *Xcircle to stop circling scale degrees. This must be done after running the deg filter, because the styling options are applied once to the entire score. Here is an example of manually highlighting the tonic triad scale degrees:

You can, however, give different styling to different **deg analysis spines by running the deg filter more than once on the score while using the -s or -k options to select **kern spines to analyze

Below is an example of circling the degrees on one staff, but not ones on the other staff:

deg -k1 --circle | deg -k2

The -s option can be used, but is less useful since the spine may numbers change after each pass through the deg filter. These two filter commands will produce the same example output give above:

deg -s1 --circle | deg -s3

For this case, the -s 3 option analyzes the second **kern spine, which changes to the third spine after the first pass through the deg filter.

deg -s2 | deg -s1 --circle

For this case, the first **kern spine remains at the beginning of the line since the **deg spine added in the first pass becomes the third spine in the data.


The --hat option will place carets (circumflexes) over scale degrees in the graphical music notation. These are typically added to the melody line in music analysis.

Here is an example of circling the scale degrees in the bottom part and then hatting the degrees in the top part:

deg -s2 --hat | deg -s1 --circle


The --box option will place a box around in each scale degree.


The --color option can be used to set the color of the scale degrees when displaying with music notation.

**deg spines can be given different colors by selectively running the deg filter, applying one color for each pass through the deg filter:

deg -k1 --color crimson | deg -k2 --color dodgerblue

Place degrees above the staff

By default scale degrees will be displayed below the staff when shown in a musical score. You can add the --above option to show them above the staff.

Here is an example of circling the bottom staff scale degrees, then hatting the degrees on the top staff and placing them above the staff:

deg -k1 --circle | deg -k2 --hat --above

If you want to display both scale degree analyses below the bottom staff, you can use the extract filter to rearrange the **deg spines:

deg -k1 --circle | deg -k2 --hat | extract -s 1,4,2,3

Notice that the order of the **deg spines are from highest staff to lowest staff when they are placed below the staff. If you want to show both **deg spines above the staff, then the order of the **deg spines has to be reversed:

deg -k1 --circle | deg -k2 --hat | extract -s 1,2,4,3

To change the side of the staff within the score, you can edit the score after passing it through the deg filter, adding *below to cancel the *above placement: